Hi All,
I have an ANO Directional Navigation and Scroll Wheel rotary encoder that I’m using with an ESP32 Dev board to try and control my daughters RGBW lights, but I would like it to be pretty flexible and interchangeable with other devices in the future, so instead of calling specific automations I want it to return its current state in home assistant.
So far I have two text sensor entities, one that returns button clicks: Left, Right, Up, Down, Center, Double Click and Held.
And another that returns the direction of rotation: Anticlockwise or Clockwise.
While this works great so far, I cannot figure out how to return “Off” or “Stationary” from the second entity when the wheel has finished turning for say 0.5s.
My code is as follows:
sensor:
- platform: rotary_encoder
name: "Rotary Encoder"
id: rotary_wheel
pin_a:
number: GPIO13
mode:
input: True
pullup: True
pin_b:
number: GPIO12
mode:
input: True
pullup: True
max_value: 100
min_value: 0
resolution: 4
on_clockwise:
- text_sensor.template.publish:
id: encoder_direction
state: "Clockwise"
on_anticlockwise:
- text_sensor.template.publish:
id: encoder_direction
state: "Anticlockwise"
text_sensor:
- platform: template
name: "Button Pressed"
id: button_pressed
- platform: template
name: "Encoder Direction"
id: encoder_direction
I have not included the button YAML as I am comfortable with their operation. Any help would be greatly appreciated, I am quite new to ESPHome and YAML code and though I have tried to resource solutions myself, I feel as though I am exhausting my options because I just don’t know what to look for.
Any ideas?