We have moved at community.getvera.com

Author Topic: Virtual Device as Trigger to Enable/Disable many Scenes at once - LUUP examples?  (Read 2704 times)

Offline Aaron

  • Hero Member
  • *****
  • Posts: 1985
  • Karma: +61/-193
I have several scenes that are based on Schedules, but 'tied' to a house "status". To simplify things, I'd like to use Virtual Devices (switches) to turn enable/disable them in batches.

For instance...

I have 6 Scenes for AWAY status, and 5 Scenes for VACATION status -- thus, I'd like to have one virtual device for each status, AWAY & VACATION, and have a single scene that monitors for status changes and enables/disables the proper scenes accordingly.

I was thinking something like the below code. If you can help me complete this, or have an easier way, please let me know.

thx for the help!

Code: [Select]
local VACATION=67
local AWAY=68

local AWAYmode = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", AWAY)
local VACATIONmode = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", VACATION)

if (AWAYmode == "1") then
  <code to enable scenes goes here>
  else
  <code to disable scenes goes here>
end
if (GuestMode == "1") then
  <code to enable scenes goes here>
  else
  <code to disable scenes goes here>
end

Offline chixxi

  • Hero Member
  • *****
  • Posts: 1036
  • Karma: +37/-14
What do you mean by "enable/disable a scene"?! Basically you can only "run" these, and not enable or disable these.

I just add these lines to a scene which I want to prevent from running:
Code: [Select]
local autoswitch = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",11)
--disable when autoswitch is off
if (autoswitch == "0") then
  return false
end

If the virtual switch is set to "off" and the scene is triggered, this will prevent the scene from running.
Developer of Plugins: Virtual Switch, Variable Container, Popcorn Hour Remote, Vacation Ghost. => PLUGINS HAVE BEEN UNPUBLISHED BY ME.

Offline Aaron

  • Hero Member
  • *****
  • Posts: 1985
  • Karma: +61/-193
What do you mean by "enable/disable a scene"?! Basically you can only "run" these, and not enable or disable these.

OK, I thought that might be the case... which sux.

I just add these lines to a scene which I want to prevent from running:
Code: [Select]
local autoswitch = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",11)
--disable when autoswitch is off
if (autoswitch == "0") then
  return false
end

If the virtual switch is set to "off" and the scene is triggered, this will prevent the scene from running.

Thank you, this will help - though, I'd much prefer a way that did not include adding code to each and every Scene. It would be MUCH nicer to have a single "house mode" Scene that enabled/disabled other Scenes.

One other thought I had...
Can we enable/disable 'Schedules" using code?
- if we can, then we could maybe do it using a single Scene?


Offline RichardTSchaefer

  • Community Beta
  • Master Member
  • ******
  • Posts: 10091
  • Karma: +764/-143
You can do this with Program Logic Event Generator plugin.
Have all of your scenes be initiated from the Condition Satisfied outut event of the Program Logic Event Generator plugin.

Scene1Trigger = HOUSE_OCCUPIED and (Existing scene1 trigger expression)
...
SceneNTrigger = (HOUSE_OCCUPIED and (Existing sceneN trigger expression)

Than use a Virtual Switch to set the HOUSE_OCCUPIED trigger.

Offline Aaron

  • Hero Member
  • *****
  • Posts: 1985
  • Karma: +61/-193
You can do this with Program Logic Event Generator plugin.
Have all of your scenes be initiated from the Condition Satisfied outut event of the Program Logic Event Generator plugin.

Scene1Trigger = HOUSE_OCCUPIED and (Existing scene1 trigger expression)
...
SceneNTrigger = (HOUSE_OCCUPIED and (Existing sceneN trigger expression)

Than use a Virtual Switch to set the HOUSE_OCCUPIED trigger.

I'll definitely look at this method this weekend... and report back.

Thanks!!!