Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 105975

Determine if rotary encoder sensor is moving or not

$
0
0

I’m trying to make a sensor that determines if a rotary encoder is turning (sensor.esphome_web_5355c8_encoder). Does anybody have a clue for me, please?

sensor:
  - platform: template
    sensors:
      rotary_encoder_turning:
        friendly_name: "Rotary Encoder Turning"
        value_template: >
          {% set current_position = states('sensor.esphome_web_5355c8_encoder') | float %}
          {% set previous_position = state_attr('sensor.rotary_encoder_turning', 'previous_position') | default(0) | float %}
          {% set threshold = 1.0 %}  # Adjust this threshold as needed
          {{ (current_position - previous_position) > threshold }}
        attribute_templates:
          previous_position: "{{ states('sensor.esphome_web_5355c8_encoder') }}"

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 105975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>