Good day, a lot of my automations include: trigger: something. condition: switch=off, action: switch:=on
But this gets very verbose if I want three switches because I need three identical automations because of the switch check condition.
Would it be possible for home-assistant to not switch a switch if the switch already has that state? So basically a check on quite a low level.
This would automations with lots of switches (or even switching a group) much more elegant.
PS. I have to do the checking, because for example zwave switches (but I can imagine a lot of bus-system switches) take a bit of time and bandwidth to do the switch, so switching 20 items very often is undesired.
PS2. This item is ofcourse valid for all states, not just on/off
PS3. This only makes sense for switches with a reported state, not for an assumed state
But as you already can see from your answer, everything gets very verbose. And different solutions for a group (you loop over the group) or just a bunch of switches.
Basic outcome on discord: everything can be scripted if you try (and type) long enough. But I did not get a counter argument why this should not be implemented.
Basically to keep the files clean and really reduce implementation time for new automations. Like you said: your not an expert at templating, neither am I. So everything just takes a long time now to implement.
do you receive errors if switching on when already on?
I ask because in several scripts and scenes I use, i set the specific needs for that scene, especially lights and switches turning on and off respectively.
Selecting another scene, obviously with other switch and light settings might have identical settings for several entities. A same switch or light must be turned on or off.
That never raises an error, and seems to go fine. switching a switch that is already on simply does nothing, turning on a light already on is default behavior when changing attributes settings for that light, so isnt an issue either?
fwiw, my switches are Zwave’s also, but on a dedicated Hub I read over mqtt and set using command_line api calls.
@nickrout I am exactly trying to make things less complicated. Just a simple: if door open, lights on. (for example). Without the need for if light is not on conditions.
@eXtatic No, I don’t want that, what is wrong with the current switch.turn_on? It just make sense if it does that check ifself
@Mariusthvdb No everything works fine! It just takes long if you have a lot of switches you want to switch. Because every command is still send over the zwave network. This is what I am trying to prevent.