Does anyone know how I can create a device that keeps variables that are changable from luup?
I’ve tried to create a device Description: "System"and left all other fields empty.
Then I created a Variable: Service: “SystemDevice1”, variable: “Mode”, value: “out”
And I am trying to change this variable from luup code with no great success:
luup.variable_set(“SystemDevice1”, “Mode”, “home”, 28)
You may not be doing anything wrong. If you are following the variable’s value in the Advanced tab, then you won’t see it change. But it is changing. To see it change in real time you’d have to get the variable to display on the dashboard by creating a Static JSON file.
local var1=luup.variable_get(“serviceTest”, “variableTest”, 28)
if (var1==“1”) then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “0”}, 17)
return false
else
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “50”}, 17)
return false
end
[/code]
This code results in a dimming level of 50% which means that the variable ‘var1’ is not equal to “1”.
Am I allowed to use such simple service names as only “serviceTest”?
What am I doing wrong here?
ok I actually got the above code working while using a static JSON file (D_PluginName.xml) while creating the device.
However it does not update the variable under advanced tab dynamically. I did not fully understand how to solve this?
What is there to solve? The Advanced tab doesn’t update in real time. It isn’t meant to. There is no workaround except looking at your variable some other way (static JSON, or by triggering a lamp as you did).
Service IDs can be any string. They are URNs only by convention to protect people from picking colliding namespaces.
Best Home Automation shopping experience. Shop at Ezlo!