Blink a (binary) light once without HA state change

Hi,

I have a usecase where I want to blink a ceiling light once for confirmation of a user action (in this case: long-pressing the light switch to temporarily deactivate an auto-off timeout). The blinking itself is not a problem, but I would like to avoid having a reported state change of the light in HA.

Reason for that is that I trigger another action as soon as the light is being switched off and I want to avoid triggering this action by the confirmation blinking.

Now I am sure I can find a rather complicated solution to this but I was wondering if there is a simple way to just locally control the relay for the short blinking without the binary light even changing its state.

Any ideas?
Regards, Daniel

let it wait, it has to be off for 2 second or so

Not all lights have this, but some do, so it’s worth a try. You can send a ‘flash’ to a light when you turn it on. This will cause it to blink once. AFAICT, the light will then return to it’s default ‘on’ state, which may be the previous state or some other state that is set as default. The ‘flash’ isn’t counted as a change to an ‘off’ state.

Thanks for the suggestion, that would be exactly what I need. Unfortunately it does not work in this case:
While I can call the turn_on service with data: flash: short, it will only blink once when the light was off before. If the light is already on it does nothing :frowning: I’m not exactly sure if this is the intended behaviour. Maybe a candidate for an esphome feature request…

Does anybody know if I can for example manipulate the output which is used in a binary light in esphome directly without changing the status of the light? That would allow me to create an esphome automation to get the intended effect.

Jep, that would be a workaround. Anyway I would rather keep it a bit less complicated if I can, making reuse of this functionality easier. Thanks for the suggestion anyway!

You could declare the actual light as internal so that HA can’t see it, and then “proxy” it with a template switch.

That was a good hint. What I now finally did was similar:

  • The light remains visible as before
  • I created an intermediate “template output” which is controlled by the light
  • This intermediate output controls the actual gpio output
  • I created a template button which, when pressed, switches the gpio output on and off with a short delay
  • the button automation checks if the light was on or off and acts accoringly

Code snippet:

output:
  - platform: gpio
    id: output_1
    pin: GPIO4
  - platform: template
    id: output_1_intermediate
    type: binary
    write_action:
      - if:
          condition:
            lambda: return (state);
          then:
            - output.turn_on: output_1
          else:
            - output.turn_off: output_1
    
light:
  - platform: binary
    id: thislight
    output: output_1_intermediate
    name: "EG Gang Nachtlicht"
    
button:
  - platform: template
    id: button_blink_once
    name: EG Gang Nachtlich blinken
    on_press: 
      then:
        if:
          condition:
            - light.is_off: thislight
          then:
            - output.turn_on: output_1
            - delay: 0.5s
            - output.turn_off: output_1
          else:
            - output.turn_off: output_1
            - delay: 0.5s
            - output.turn_on: output_1

Works like a charm and is easy to maintain and transparent for the user while being still visible as a normal light.
Thanks to everyone for the ideas!

2 Likes