toggle on/off of virtual switch

[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 :slight_smile:

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.

Hi,

Hi ive had to do a factory reset after upgrading to UI7 and now I cant remember the Luup for toggling the state of my boiler relays. I need to create a scene to trigger the toggle by running a scene. Ive read the old thread on virtual switches and I think I used this as the basis last time but I cannot get it to work.

http://forum.micasaverde.com/index.php?topic=11349.0

The commands that can be used are “heater_heat” and “heater_off”. The other vairables are “ModeStatus” and “ModeTarget”. Has anyone got this to work? It is a pretty common boiler switch.

John