Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call_service() function does not accept action arguments #108

Closed
toggledbits opened this issue Apr 2, 2019 · 4 comments
Closed

call_service() function does not accept action arguments #108

toggledbits opened this issue Apr 2, 2019 · 4 comments

Comments

@toggledbits
Copy link
Contributor

I feel like I'm missing something, because this is really basic, but here goes:

The call_service() function accepts a device, service Id, and action, but no parameters for the action in question. Many Vera actions have parameters. How are they to be passed?

@toggledbits
Copy link
Contributor Author

OK. I see that set_service_value() is actually an action call that accepts a single parameter, and can only execute actions the name of which begins with the string "Set". That's... interesting. It still doesn't address other actions, or multiple parameters.

@pavoni
Copy link
Collaborator

pavoni commented Apr 4, 2019

call_service gives access to the full api where needed set_service_value is largely there because most of the devices only needed this reduced functionality, so when the call_service call was added we retained this for DRY reasons.

Open to a PR if you feel something more functional than set_service_value but less rich than call_service is required.

Closing this for now.

@pavoni pavoni closed this as completed Apr 4, 2019
@toggledbits
Copy link
Contributor Author

toggledbits commented Apr 4, 2019

call_service gives access to the full api

OK. What am I missing? Let me give an example:

The RunLua action in urn:micasaverde-com:serviceId:HomeAutomationGateway1 accepts (requires) a single parameter, Code, which contains the Lua fragment to run.

It is not possible to use set_service_value() to run this action because the name of the action does not begin with "Set", which is hard-coded in that function (i.e. the function would make a Luup request for to run the SetRunLua action, which does not exist).

The call_service() function does not accept parameters, so you can try to invoke the RunLua request using it, but you cannot pass the required Code parameter that contains the Lua code to be run, because the function does not accept (and therefore does not append to the request) parameters for the action.

Not all actions are related to state variables. Not all actions that take parameters are named "Set" plus the parameter/state variable name. Not all actions take zero or 1 parameters. These are all assumptions and limitations of these two calls as currently written.

I'll open a PR.

@pavoni
Copy link
Collaborator

pavoni commented Apr 4, 2019

My note should have referred to vera_request rather than call_service, apologies.

Generally I think it's good practice to add parameters as they are needed, so no problem adding an extra parameter if you need it for something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants