Is there any support for conditional execution in scripts available or planned?
I’d like to push some of the logic I have in automation into scripts, mainly for re-use purposes. For example, I would like a script that does something like the following (pseudocode)
set house mode to "evening" (I have an input_select that tracks a mode variable)
if anyone present then
turn on downstairs lights
else
turn on single front light
if (heating_enabled) then
turn on heating
endif
endif
A script like the above I can use for 3 things:
- Run automatically at sunset
- Manual activation if someone is home
- Run automatically when someone arrives home
At present I can create rules for the automatic actions, but it will take several entries instead of 2, and there is no way to run that same script manually.
I took a look at templates but I don’t think they can help here - please let me know if I am wrong.
As an alternative to scripts supporting this, is there a way to call out into a python snippet that just contains the logic without having to create a new domain?
If this isn’t available or planned I’ll add it to the feature request forum.