However I would like to add some logic to check an additional parameter or switch to disable or ignore the time limit. So if deviceXYZ is on then the time period should be ignored.
I know I can do this entirely in code but can this be done in de on= or devices= section?
gerardvs wrote: ↑Tuesday 12 January 2021 21:32
partial code below I use to check a device during nighttime. This works great.
However I would like to add some logic to check an additional parameter or switch to disable or ignore the time limit. So if deviceXYZ is on then the time period should be ignored.
I know I can do this entirely in code but can this be done in de on= or devices= section?
Not exactly what you ask but maybe it will help. There is no way you can do this entirely without code.
What is your use case?
Thanks for your reply. Although I have to test I think your nice example could/should work.
My use case is in short:
In our building there are a lot of PIR, door and window sensors. These are passively monitored 24x7. During the nighttime I want to monitor a subset of doors and windows and when active send a (telegram & email) message. But in some occasions I want to activate the nighttime behavior during daytime. To (de)activate I use a (dummy)switch which I remotely control via Telegram.
The only thing missing in this was some logic to omit the time window when needed.
I will do some experiments with your example and let you know.
Thanks again,
Gerard
**edit** Just now I see some warnings in the docs about calling the 'active=' part. So, maybe everything in code is a better (only) way?
gerardvs wrote: ↑Wednesday 13 January 2021 0:14
**edit** Just now I see some warnings in the docs about calling the 'active=' part. So, maybe everything in code is a better (only) way?
That would always be my preferred way. Using a function in the active = part works but the function can be called quite frequent if you you have an active system. Not a big problem is you have this for only a couple of scripts and when the functions only return one or two attributes but most of the time it can be easily prevented by coding it in the execute function.
ok, moved it to execute and it works (of course, it's only a one-liner).
Maybe in a future release there will be a place for some logic in the on= event part to get "cleaner/leaner" code.
Thanks again for your help.
--Gerard