i got this pulsecounter , and when i have 520 pulses , i want to to an action via : on_value_range
this is not working
sensor:
- platform: pulse_counter
pin: GPIO14
name: "Pulse Counter"
id: pulse_counter0
update_interval: 500ms
total:
name: "Total Pulses"
id: totalpulses
unit_of_measurement: "pulses"
accuracy_decimals: 0
filters:
- multiply: 1
on_value_range:
above: 520.0
below: 530.0
then:
- switch.turn_off: cmd_omlaag
- switch.turn_off: cmd_omhoog
- delay : 2s
- pulse_counter.set_total_pulses:
id: pulse_counter0
value: 0
on the other hand , i have a entity as binary sensor , that has an error inside it , but is works
binary_sensor:
- platform: template
id: gate_open
name: "GateOpen" #Condition must consist of key-value mapping! Got None.
lambda: |-
if (id(totalpulses).state >= 520 && id(totalpulses).state <= 550) {
// Gate is open.
return true;
} else {
// Gate is closed or closing.
return false;
}
on_state:
then:
- switch.turn_off: cmd_omlaag
- switch.turn_off: cmd_omhoog
- delay : 2s
- pulse_counter.set_total_pulses:
id: pulse_counter0
value: 0
what is wisdom to solve this to 1 correct yaml code and working code