I have a shelly 1 behind a wall switch, This switches the light behind it, but I have also managed to make automations to do stuff when the switch is changed 2 and 3 times in a row. But therefore I have to make 3 automations and one extra for every extra value (4, 5 etc).
I want to trigger the automation when the counter is on a value (larger than 1) for more than 1 second. Problem is the for statement needs the to statement and that is a string (as far as i can tell)
I would like something like this to work:
trigger:
platform: state
entity_id: counter.counter_eetafel
to: >2
for: 00:00:01
action: etc
How could I do this?
The complete code for up to 3 times state changing of the switch:
- alias: Update Counter Eetafel
hide_entity: true
trigger:
platform: state
entity_id: sensor.lamp_schakelaar_eetafel
action:
service: counter.increment
entity_id: counter.counter_eetafel
id: update_counter_eetafel
- alias: Reset Counter Eetafel
hide_entity: true
trigger:
- platform: state
entity_id: sensor.lamp_schakelaar_eetafel
to: "1"
for: 00:00:02
- platform: state
entity_id: sensor.lamp_schakelaar_eetafel
to: "0"
for: 00:00:02
action:
service: counter.reset
entity_id: counter.counter_eetafel
id: reset_counter_eetafel
- alias: Turn of all lights when counter hits 2
hide_entity: true
trigger:
platform: state
entity_id: counter.counter_eetafel
to: "2"
for: 00:00:01
action:
- service: scene.turn_on
entity_id: scene.woonkamer_uit
- service: counter.reset
entity_id: counter.counter_eetafel
id: turn_off_lights_when_counter_hits_2
- alias: Turn on eetafel and woonkamer_lezen when counter hits 3
hide_entity: true
trigger:
platform: state
entity_id: counter.counter_eetafel
to: 3
for: 00:00:01
action:
- service: scene.turn_on
entity_id: scene.woonkamer_lezen
- service: switch.turn_on
entity_id: switch.lamp_eetafel
- service: counter.reset
entity_id: counter.counter_eetafel
id: turn_on_eetafel_light_and_woonkamer_lezen_when_counter_hits_3