Page 1 of 1

Override switch on timer

Posted: Sunday 05 July 2020 23:34
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.

Re: Override switch on timer

Posted: Monday 06 July 2020 0:01
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

Re: Override switch on timer

Posted: Monday 06 July 2020 11:23
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.

Re: Override switch on timer

Posted: Tuesday 07 July 2020 11:16
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.

Re: Override switch on timer

Posted: Tuesday 07 July 2020 11:34
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.