I have a GE remote scene controller, and as I understand it, the ‘Off’ buttons won’t actually turn the scenes off if programmed through Vera. So, I was hoping to come up with a LUUP code that basically works like this: when the scene is triggered by the remote, it will check if the lights are on. If they’re off, it will turn them on. But if they’re already on, it will turn them off.
So I came up with this code for the ‘if on’ then ‘turn off’ trigger:
local lul_lghtstat = luup.variable_get(“urn:schemas-upnp-org:device:DimmableLight:1”,“LoadLevelStatus”, 2)
if (lul_lghtstat) > 0) then
luup.call_action(“urn:schemas-upnp-org:device:DimmableLight:1”, “SetTarget”, {newTargetValue = “0”}, 2)
end
I think so. But I am not sure your syntax is correct. I think “DimmableLight:1” Should be “DimmableLight1”. I am no luup expert, but think that is the correct syntax for the unpnp device.
I know this works with the handheld remote. I am not sure whether you are talking about a handheld or a wall mount.
Once you have your scene programmed in the Vera, re-include the scene controller. Vera then programs the remote to directly control any lights in the scene. In this way, the off side of the scene button works.
[quote=“wscannell, post:3, topic:170472”]I know this works with the handheld remote. I am not sure whether you are talking about a handheld or a wall mount.
Once you have your scene programmed in the Vera, re-include the scene controller. Vera then programs the remote to directly control any lights in the scene. In this way, the off side of the scene button works.[/quote]
yeah, i’m using the battery remote. I tried setting up the scene and having the button on the remote be the trigger, but it would only turn on the scene (a scene controlling only lights)… it wouldn’t turn them off when pressing the ‘off’ side of the button.
thanks everyone for the advice on the code. i’ll try cleaning up my syntax.
will this luup code only run if the condition is met? otherwise, the scene will operate as normal? (ie, the scene is set to turn on lights, but if the lights are already on, then it will turn off lights).
[quote=“stylekyle, post:6, topic:170472”]thanks everyone for the advice on the code. i’ll try cleaning up my syntax.
will this luup code only run if the condition is met? otherwise, the scene will operate as normal? (ie, the scene is set to turn on lights, but if the lights are already on, then it will turn off lights).[/quote]
i’m still getting a code error when i test it, so i’m assuming something is still wrong with my syntax. do ‘spaces’, or ‘line breaks’ matter, or does LUA ignore them?
cool, i modified the weather one, and the code works when tested using the LUA test code, it comes back ‘Message sent successful’. However, When i created a scene, and put the code in the LUUP section, and Run the scene, nothing happens. It doesn’t matter if the light is on or off first. Nothing happens. Here is my code…
local lul_lghtstat = luup.variable_get("urn:schemas-upnp-org:serviceId:DimmableLight1", "LoadLevelStatus", 5)
if (lul_lghtstat == 0) then
luup.call_action("urn:schemas-upnp-org:serviceId:DimmableLight1", "SetLoadLevelTarget", {newLoadLevelTarget = "100"}, 5)
else
luup.call_action("urn:schemas-upnp-org:serviceId:DimmableLight1", "SetLoadLevelTarget", {newLoadLevelTarget = "0"}, 5)
end
seems like this should work…? is there a difference between LoadLevelTarget vs Target Value?
Check the serviceId string… character-for-character
If it doesn’t exactly match the string from the spec, or the examples provided for DimmableLight1, then it won’t work. When in doubt, hover your most over the Label for any Variable in the Advanced tab of the Device’s Dialog. The Bubble help shows the exact string to use.
There are now examples for both SwitchPower1 (Light Switches) and Dimmable1 (Dimmers), I’ve created example code snippets that demonstrate how to work with these Variables (get values, request changes). Presumably we can continue to augment these examples for the other variables that people commonly work with.
I have no preference as to where these examples go, or what format their in, but putting them here at the point where the variables are defined seems to make sense.
This should clarify, since many users can simple cut/paste these, and change the relevant device#.
Hover your mouse over the Label on the left of the Variable your interested in, in the Advanced Tab of the Device. A bubble hint will appear with the service id
EDIT: Pictures attached, wording changed to include reference to “Advanced Tab of the Device”
I’ve attached images to the above to show it under UI4 and UI5, as well as amending the wording to make it clearer where these can be seen within the UI.
oh, i get it. thanks for the picture. i didn’t realize the list in the advance tab was broken up. i was at the top and nothing happens up there. I’ve found the variables section midway down, and sure enough, the service ID shows up when i hover over one of the variables.
looks like there are different service id’s for different variables. so, for ‘LoadLevelTarget’, the serviceid is ‘urn:upnp-org:serviceID:Dimming1’. i’m assuming that is what i’ll use in my code for changing the light level.