below is my automation. I assumed it would do the following: if switch.kueche_wandschalter_center would be turned on, it would turn switch.abzug on, and if the switch would be turned off, it would turn off the switch.
However, this automation only works if switch.kueche_wandschalter_center and switch.abzug are currently off. If so, it will turn on the abzug switch when the wandschalter one has been turned on. However, nothing will happen when turning it off.
In case anybody else cares, this seems to be the solution (haven’t been able to test it yet due to not being physically there to actually push the button, but it doesn’t throw any more errors this way)
Someone will come along shortly to point this out anyway I have no doubt, but this can be radically simplified by having a single trigger for the switch, with nothing entered for the state.
The service call to mirror the state of the switch can then be templated:
Yes! I didn’t know what exactly to search for in order to find this part ( - service: 'switch.turn_{{ trigger.to_state.state }}'), but it was my initial thought as well - just didn’t know how to “phrase” it. This is perfect.
Someone really needs to start a simple blog with all these “shortcuts” on them, because the official documentation, doesn’t really make it obvious just what can actually be templated, WITH examples.
I have a Growing notepad of snippets of code from @123 just over the last 3 weeks!
That is a great suggestion! Do you have your snippets up somewhere? I have some automations that I don’t feel are the most elegant and could likely be improved and shortened with shortcuts like these.
They are just in Google Keep right now, so I could easily find them again as I keep my laptop in the bedroom now, and use a Chromebook when I am downstairs during the day.
Long ago, the service option didn’t support templates and you had to use a different option called service_template. It was deprecated after service was enhanced to support templates.
You could say that this example uses "service with a template" or simply a “templated service call” (although the word “templated” is technical jargon).
Most of my automations were built long ago as well. I didn’t have any experience with trigger ids or choose until today. But Home Assistant (or the developers) keep amazing me with things like this fix you provided. That combined with trigger.to(...) makes it possible to keep things short and make them easily reusable.