Smart Home Automation Forum
Pulse Counter Sensor - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=1)
+--- Forum: KC868-A series and Uair Smart Controller (https://www.kincony.com/forum/forumdisplay.php?fid=6)
+--- Thread: Pulse Counter Sensor (/showthread.php?tid=6769)



Pulse Counter Sensor - remiasz - 09-23-2024

ESPHome has Pulse Counter Sensor.
In yaml I can set count_mode to increment or decrement.
Can I change count_mode in runtime
My yaml file:

Code:
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);

I want add precise position to "Feedback Cover" by counting impulses from motor sensor.
But this konfiguration always count up in opening and closing cover.