Double press in a short time as trigger (Brightness change)

Hi!

I have the following setup:

  • 1 wemos d1 mini with remote reciever
    binary_sensor.galben_2 ( entity) with instant ON/OFF when the button is pressed
  • 1 sonoff dimmer
    light.sonoff_1000dbb5a7 (entity)
  • 1 automation
    if binary sensor is ON then toggle light
  • desired automation:
    if the remote button is pressed twice (ON-OFF-ON-OFF) in less than a second or maybe two, then if brightness is low make it high and reverse.

I have tried to achieve that also in esphome, also in homeassistant, I had no succes, all info about this idea is poor on documentation and also on internet. I have no ideea to make a trigger for less than desired time (in my case 1-2 seconds).

Any suggestions? I feel I am waisting so much time on this issue and I need some help.

Thank you!

I have seen such a function with buttons in tasmota. https://tasmota.github.io/docs/Buttons-and-Switches/ Please see this. There are more options .

There is something similar on esphome under double click and multi click options but I can’t manage to work in my setup. Thanks!

I had some inspiration in this morning and the solution is pretty simple - wait for trigger - timeout

 alias: Lustra telecomanda
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.galben_2
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: light.toggle
    data: {}
    entity_id: light.sonoff_1000dbb5a7
  - wait_for_trigger:
    - platform: state
      entity_id: binary_sensor.galben_2
      from: 'off'
      to: 'on'
    timeout: '1'
    continue_on_timeout: false
  - service: light.turn_on
    data:
      brightness: >
          {% if states.light.sonoff_1000dbb5a7.attributes.brightness|default(255) < 100  %}
          255
          {% else %}
          1
          {% endif %}
    entity_id: light.sonoff_1000dbb5a7
  mode: single
2 Likes