Luup url parameter

Hi there !

I’m trying to do a scene with a generic luup script.
Basicly, I want to toogle a urn:schemas-upnp-org:device:DimmableLight:1 off if it’s on and on if it’s off.

That’s not a big deal, the problem comes when I want to pass the deviceId via the url when I call the API.

The scene script :

local id = 5 –> replace this static id with something like get_url_param(“deviceId”)
local old_status = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, id)
local new_status = “0”
if old_status == “0” then
new_status = “1”
end
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”, “SetTarget”, {newTargetValue = new_status }, id)

The url :

http://192.168.0.120:3480/data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=1&deviceId=5

Is there anything that allows us to pass a parameter to the Luup script when we call it ?

There is no way I am aware of to send parameters into a scene.

If it is just a device you want to effect, you could always send:

http://192.168.0.69:3480/data_request?id=lu_action&DeviceNum=3&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1

Thank you for your answer.

Yes I already thought using the SetTarget on the Device but to switch the state I’ll need to do two request instead of one and put the logic on the client side.

Is there an alternative, maybe without scene ?

Not that I am aware of.

If you are intending to set a device to a specific state, why check it before changing? Just go ahead and set it.

If you do need to see the state of a device, there are HTTP requests that can be sent that will do it.

There is an Api to send and the execute LUA code.

Because I want to set a device off if it’s on and on if it’s off. (with only one button)
I’m not really interested in the state on the client side.

Interesting, do you have any documentation about that ?

Makes sense. Have you considered creating a scene on Vera that toggles that light, then initiating the scene (using HTTP run scene command) from your remote device?

Search for the Run LUA action:

http://wiki.micasaverde.com/index.php/Luup_UPnP_Variables_and_Actions

[quote=“RichardTSchaefer, post:8, topic:183849”]Search for the Run LUA action:

http://wiki.micasaverde.com/index.php/Luup_UPnP_Variables_and_Actions[/quote]
Perfect, I’ll check that and keep you posted (it might takes a little long). Thank you for the info.

Yes I did that too but the problem is, as RichardTSchaefer said, that you can’t send any parameter to the scene. So I would have to create a scene for each device I want to switch and unfortunately I can’t effort this.