I’m trying to change the state of the icon based on whether the status is “on” or “off”. The icon should be amber or gray depending on whether the lights are on or off. Unfortunately, the icon stays blue. What am I doing wrong? I can’t figure it out.
Hello again @Didgeridrew and, of course, all other users.
Since you’ve been so great in helping me with my previous challenge, I’m taking the liberty to ask a follow-up question.
I’m struggling to program the “Hold Action” in a way that when I use it, all lights are turned off. I’ve found some information here and there, but it’s not working out yet. Perhaps there’s a simpler way to achieve this action. Any help is, of course, very much appreciated.
automation:
- id: lights_off_long_press
alias: Turn Off Lights on Long Press
trigger:
platform: state
entity_id: input_boolean.on_state # Replace with the actual entity ID of your button
to: 'on'
for:
seconds: 3 # Adjust the duration for a long press as needed
action:
- service: light.turn_off
entity_id: all
As mentioned, perhaps I’m trying to make it too complicated. What I don’t understand in the ‘automation’ for example is the action ‘service: light.turn_off’.
Can you explain your reasoning for the automation? Are there other inputs that you want to turn off all the lights? Are you planning on adding conditional logic to assess when and when not to turn off the lights? I ask because, if not, you’ve chosen a somewhat unusual structure. If you want a button that always turns off all the lights no matter what, there is no reason to route it through a script or automation.
As for the service call, it should be:
service: light.turn_off
target:
entity_id: all
Was there a specific question you have about it, or maybe service calls in general?
No specific reason for this approach. Google and chat-gpt pointed me there.
I just want to keep it simple and turn off all the lights when we go to bed early for example. Normally the lights are all turned off at 23.00. But as it happens, because we are aging, is that we go to bed at 10 Then the button comes in to be handy.