I am not understanding something about how templating is working in an automation. I have a Xiaomi switch with three click types. Single, Double and long press. That’s working fine. I have tested how to code for these three events in another automation which works well.
I would like single click to toggle a light, I would like a double click to turn on the light to a specific brightness and temperature setting and long click to turn on to a different brightness and temp setting. Here’s my code
I have left the settings for brightness and temp blank for single click (toggle) because I don’t want them specified when the light is toggled on.
The result of this is that the turn_on commands work perfectly, but the toggle doesn’t. Nor does it work if I change toggle to turn_off, nor does it work if I take out the IF statement for single click…
Thanks.
So I guess the only solution is to have 2 automations right? One to handle the single click event and the other to handle the other types of click?
Unless there is syntax that lets me template out the brightness_pct and kelvin lines altogether but I don’t think I can right?
Great. Many thanks.
And thanks for the improved code. I knew if I posted here, someone would be kind enough to give me the neatest code rather than my version which fills my whole screen!