Like most, I have a bunch of automations for my lights. For instance, the kitchen lights are motion activated, and turn off if there has been no motion for three minutes. I move like a sloth though, thus the lights keep on turning off while I’m eating breakfast. Oppositely, my wife likes to eat in the dark, so she keeps swearing at the damn light turning on all the time.
So I wanted a “light state lock” but couldn’t find one, so I tried it myself and had some success using conditional cards, custom-fields and card-mod, but its extremely messy and doesn’t work all that well, and it looks terrible in the companion app.
Someone must have already made this functionality, right? Or else, I would appreciate any helpful tip on how to make this work well, logically, and responsively at the same time.
I made a template switch that turns the related set of automations on and off, then in my dashboard button I use double_tap to toggle that template switch. My button conditionally shows the lightbulb icon when the template switch is off, and the lightbulb with a small A next to it when it’s on. The light itself toggles with normal press of the button and changes the button background color appropriately.
Sure thing. I wasn’t at my computer last time, but I am now.
Note, the normal dashboard button doesn’t have scripting, so I am using the excellent custom button card that I got via HACS. If you don’t want to use a custom card you can probably achieve the dynamic icon with another template entity to represent your light. It’s worth the time to learn the custom button card though, as it is quite powerful. I have another topic I created that explains a lot more about how I’m using the custom button card if you are curious. I have a few other related posts too, which you should be able to find if you drill into my profile.
template switch to control the set of automations, defined in configuration.yaml