Show the status of light on the button

Hi,

I’m struggling with some ledvance lights to put on a dashboard correctly.
Adding “Light” card works Ok, no problem here, BUT, when I turn on the lights, the lights are turned on with the previous brightness and color, and of course this is a normal behavior.

I need to put a button on dashboard to turn on the light at a specified brightness and color.
Of course, I’ve made a script based on “call a service” and the service is “light:toggle”.

I’ve put a button on the dashboard that is calling the previous created script and all ok, except that the button does not show the status of the light (on or off).
When I touch the button, the script is launched, the lights are up, the button is also lit up, but after 2 seconds the icon of the button shows the off state.
Touching again the button, turns off the light correctly, but the icon is lit up for 2 seconds, then turned off.

I need to see the real status of the light on the button/icon (on or off) and I don’t know what to do.

Here is the button:

show_name: true
show_icon: true
type: button
tap_action:
  action: toggle
entity: script.sufranoapte
name: SUFRA NOAPTE
show_state: true

and here is the script:

alias: SufraNoapte
sequence:
  - service: light.toggle
    data:
      color_temp: 500
      brightness: 5
    target:
      entity_id: light.sufra8
mode: single
icon: mdi:ceiling-light-outline

I need a solution with a button able to correctly display the status (on/off) of the specified entity/light.

Thank you,

Costin

This should do it. The card entity is the light, so it shows the light state and the tap action is to call your script.

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: script.sufranoapte
entity: light.sufra8
name: SUFRA NOAPTE
show_state: true

You had the script as the card entity, so the state shown would be the script state, I.e. briefly blink on when the script was running.

Clever ! Thank you !

1 Like