Override switch on timer

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
felix63
Posts: 244
Joined: Monday 07 December 2015 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Gouda
Contact:

Override switch on timer

Post by felix63 »

Has someone already made a script for the following use-case:

One or more devices switch on and off at specific times. However under certain conditions (rain/wind) it doesn't make sense for the devices to be on. However when the rain/wind ceases the normal timer function should be restored. So if the device was on before and based on the timer it should still be on it will be switch back on. If the timer has since expired the device can remain off...

The more flexibility and the simpler the script the better... I have something, but it relies on extra dummy switches making things not very simple.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Override switch on timer

Post by waaren »

felix63 wrote: Sunday 05 July 2020 23:34 Has someone already made a script for the following use-case:
maybe I overlook something but what fails your requirement in this pseudo code?

every minute at timewindow

if rain/wind ok and device == off then switch on device
elseif device == on and rain/wind nok then switch off device
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
boum
Posts: 136
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Override switch on timer

Post by boum »

I guess that if you want to use the native timer web interface, you'll still need a virtual switch for every "planning". Then in your script the normal state of the real device can be set using the virtual switch.
If the specific times are most always fixed and you don't mind editing a script to change them, Waaren's option gets rid of the virtual switch. Another options could be to store the times in user variables.
User avatar
felix63
Posts: 244
Joined: Monday 07 December 2015 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Gouda
Contact:

Re: Override switch on timer

Post by felix63 »

@waaren... you are right. That does work. The only thing doesn't work for is if the device was switched on manually. But you could ask yourself the question if that isn't safer anyway. But instinctively I don't like scripts to run on every minute. I have the unfounded idea that it will adversely impact performance but given how scripting work that is probably not true.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Override switch on timer

Post by waaren »

felix63 wrote: Tuesday 07 July 2020 11:16 ... instinctively I don't like scripts to run on every minute.
If you want the switch to react instantly on changing conditions you could also have the script triggered on updates of the wind-/rain devices and within the declared window.
If you don't' have the requirement to have the switch react immediate to changing conditions you could decrease the script's frequency to execute every n minutes.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest