How do I enable/disable a schedule using LUUP?
This can be done manually and therefore I suppose that it also can be done by some programming ? but how do I do it?
I have a number of scheduled scenes running my heating system during the week. I also have a vacation-scene that turns down the heat when we are away for a longer period. Of course, when this vacation-scene is active I don?t want the normal scheduled scenes to run.
I am planning to use a Google Calendar event to trigger start of the vacation-scene including disabling schedules that normally controls the heating system. And of course, everything should automatically go back to normal just before we get home again.
If you’re setting the state of your devices via a scene, you can leverage the fact that if the LUUP for a scene returns “false”, then the scene won’t execute.
In my mind, though, you’d be better off building this using PLEG. That’ll give you an easy way to build logic that can combine schedules with other logic (like the state of your Google Caledar plugin). I use the Google Calendar plugin to set states on a couple virtual switches (another plugin) - things like school vacation days (to alter the light schedules on days we won’t be up early).
Thank you for the reply. I am aware of the possibility of using PLEG (with which I am not familiar) but I was looking for a ‘quick fix’ :-). I understand programming in general but not LUA in particular, so: How do I force LUUP to return FALSE?
If you install the Virtual Switch (VS) plugin, you can use the state of a VS device to prevent your scenes from running. For example, if you have a VS as device number 32, the following code placed in a scene’s Luup will prevent it running if the VS is turned on:
local dID = 32
local status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",dID)
return status == "0"
You can set the state of the VS device using other scenes or from Vera UI.
Great. Thank you
[quote=“RexBeckett, post:4, topic:178305”]If you install the Virtual Switch (VS) plugin, you can use the state of a VS device to prevent your scenes from running. For example, if you have a VS as device number 32, the following code placed in a scene’s Luup will prevent it running if the VS is turned on:
local dID = 32
local status = luup.variable_get("urn:upnp-org:serviceId:VSwitch1","Status",dID)
return status == "0"
You can set the state of the VS device using other scenes or from Vera UI.[/quote]
So, if I wanted to prevent the scene from running if the VS is turned off, would "return status == “1”?
As I understand LUA, the operator == returns True or False. So Return status == “0” returns True if the switch is off (Status = 0) and False if the switch is on (status=1).
Anyway, the shown code works perfectly if you change the device no. and device name to the actual values in your own system.
So, if I wanted to prevent the scene from running if the VS is turned off, would "return status == "1"?Yes - that is exactly how to do it. You are off and running with Lua. :)
[quote=“sorenbs, post:7, topic:178305”]As I understand LUA, the operator == returns True or False. So Return status == “0” returns True if the switch is off (Status = 0) and False if the switch is on (status=1).
Anyway, the shown code works perfectly if you change the device no. and device name to the actual values in your own system.[/quote]
I forgot to add “and vice versa” - therefore your guess must be right.