[quote=“garrettwp, post:15, topic:172221”][quote=“LightsOn, post:14, topic:172221”]Hi JVilla,
yes this is all new and chalengeing to me also - however - good news i have a soloution working
create 2 scenes, one that turns the virtual switch on and one that turns it off - simple enough. now creat yet anouther scenen (this will be the toggle button for the virtual switch. in the toggle button scene add the below luup code:
Name_of_action = luup.variable_get(“urn:upnp-org:serviceId:VSwitch1”,“Status”,ADD_DEVICE_ID)
if(Name_of_action==“1”)then
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“RunScene”,{SceneNum=“ADD_SCENE_NUMBER”},0)
else
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“RunScene”,{SceneNum=“ADD_SCENE_NUMBER”},0)
end
change your device id, scene number, and add a name for the action - or leave name of action as is as it will still work.
you now can toggle a virtual switch - happy days ;D
now time for a sit down and a brain relax for me…[/quote]
Try this:
status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status", DEVICE_ID)
if(status=="1")then
luup.call_action("urn:upnp-org:serviceId:VSwitch1", "SetTarget", {newTargetValue = "0"}, DEVICE_ID)
else
luup.call_action("urn:upnp-org:serviceId:VSwitch1", "SetTarget", {newTargetValue = "1"}, DEVICE_ID)
end
No need for two additional scenes. Just create the one scene and add the luup code.
- Garrett[/quote]
sorry for my confusion. what would this luup code do? turn the VS on and off at certain times? i created a simple scene and scheduled the VS to turn on at sunset daily so that my light scenes will run and turn VS at around 5am. also, how do i use these codes for the VS to arm/disarm door sensors? thanks.