Pulse Counter have config option “count_mode”.
It can be set to increment or decrement counter.
Can “count_mode” be setting in runtime?
I try extend “Feedback Cover” to precise location.
I have “opening” and “closing” signal and motor generate impulses on running.
My yaml file below:
sensor:
- platform: pulse_counter
name: "impulse_counter"
id: motor_pulse_counter
pin:
...
update_interval: 1s
total:
name: "Total"
binary_sensor:
- platform: gpio
name: "input01"
id: opening
pin: ...
on_press:
then:
- lambda: |
id(motor_pulse_counter).set_rising_edge_mode(esphome::pulse_counter::PulseCounterCountMode::PULSE_COUNTER_INCREMENT);
- platform: gpio
name: "input02"
id: closing
pin: ...
on_press:
then:
- lambda: |
id(motor_pulse_counter).set_rising_edge_mode(esphome::pulse_counter::PulseCounterCountMode::PULSE_COUNTER_DECREMENT);