In this example I won’t go through the details for adding controls to a panel. This is simple enough and the details that are important here is how to get a control on one panel to control another device on another panel that isn’t even a Virtual Panel. This is true for any command that you would like to call from an action within Vera. So add a new Horizontal Slider to any Virtual Panel on your Vera.
- Select the Virtual Panel you are editing for the Device under the Device Variable to monitor section.
- Select or type urn:rstrouse-com:serviceId:VirtualPanel1 into the Service Id field
- Type in a variable name that is unique within the panel. I chose MasterSlider in this case.
Under the command section choose Execute Lua from the Action Dropdown. An edit field will appear to accept luup code to be performed when the slider is moved.
Below is the code that is executed for me when the master slider is moved.
luup.variable_set("urn:rstrouse-com:serviceId:VirtualPanel1", "MasterSlider", context.controlValue, context.panelDeviceId)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {["newLoadlevelTarget"] = context.controlValue}, 27)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {["newLoadlevelTarget"] = context.controlValue}, 11)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {["newLoadlevelTarget"] = context.controlValue}, 30)
luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {["newLoadlevelTarget"] = context.controlValue}, 31)
if(tonumber(context.controlValue) ~= nil and tonumber(context.controlValue) > 15) then
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {["newTargetValue"] = "1"}, 42)
else
luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {["newTargetValue"] = "0"}, 42)
end
From the list above the number 27, 11, 30, and 31 are the device ids for each of the sliders on the panel. 42 is the side door light binary switch which I have turn on if the dimming level is greater than 15 and off if it is less than or equal to 15. Notice the use of context.controlValue. This is the current slider position.
In the first statement I am persisting the slider value so that it stays where I last set it. I use the context.panelDeviceId value since I am storing this value on the Outdoor panel itself. The screenshot below is the definition for my master slider.