#Automation only works once in a while when button is pressed multiple times in succession

1 messages · Page 1 of 1 (latest)

sly dirge
#

This is my automation:

alias: Toggle Light with R5 Button 6 Single Press - Any Change
trigger:
  - platform: state
    entity_id: sensor.sonoffr5ble_r5_1_button_6
condition:
  - condition: template
    value_template: "{{ trigger.to_state.state == '.6-SINGLE' }}"
action:
  - service: light.toggle
    target:
      entity_id: light.yeelight_ct_bulb
mode: single

I'm using a text sensor to toggle a lightbulb.
The sensor in changes state correctly in the overview but the automation is having problems

#

It'll toggle the light if i press the button approximately 20 times rapidly

#

Even that isn't guaranteed

mental shore
#

Does the sensor actually change state?

little tapir
#

All the 'single' mentions imply that there are perhaps double or triple taps

mental shore
#

so from something to .6-SINGLE?

sly dirge
#

I've found out just now It triggers only if the sensor state changes from something else to .6-single but not if it I press it while it's already .6-single

#

Yes there are double and hold taps

#

How do I solve this?

mental shore
#

What provides these sensors? Is that a specific integration?

sly dirge
#

I'm using esphome on an esp32 that decodes the signals from the sonoff r5 switch buttons

mental shore
#

Normally a button would provide an event entity, which has the last time it occurred as it's state, and an an event_type attribute which specifies which even occurred.

#

ESPHome also supports event entiteis

sly dirge
#

Thanks I'll try that out

little tapir
#

I also suggest that if you're rapidly pressing the button, it might be interpreting the presses as double or triple taps that won't trigger that automation

mental shore
#

so create an event entity, and then use event.trigger to update it