This was really useful. Especially since I’ll also be using this for my keuken! Many thanks.
I’m trying to configure a rotary encoder as described above, but it did not work for me. Then I simplified the code (see below), just to check if I would get a log message and not even that worked. I also tested with and without the debounce filter and using inverted and pullup as both true and false. None of the combinations worked for me. My encoder does not have a breakout board, as it would not fit the limited space I have, but I think this should not be a problem, as the ESP32 already has pullup in its breakout board. I did check the encoder for continuity with a meter and it seems ok., so it is not a faulty component.
Here is the code I used:
sensor:
- platform: rotary_encoder
name: "dim_Lucas"
pin_a:
number: 18
inverted: true
mode:
input: true
pullup: true
pin_b:
number: 19
inverted: true
mode:
input: true
pullup: true
id: dim_lucas
resolution: 1
min_value: 0
max_value: 25
on_clockwise:
- logger.log: "Turned Clockwise"
on_anticlockwise:
- logger.log: "Turned Anticlockwise"
Any ideas on how to solve this?
How do you have things wired? Is the light controlled by the same esp board that the rotary encoder is on? You only show the rotary encoder part of your code so what type of light are you using? What hardware are you using? Is there a mosfet in here?. You’ve only given half the equation here. There are several eats to do this but if the light Is on the same board, is it even dimmable, do uou have the hardware to dim it, the type of light, etc all matter if you
Are you even seeing the rotary encoder values change in your logs? That’s how you know if it’s working or not. No need to speculate or wonder if it’s working, just look at the logs. The number should increase when spun one direction and decrease the other direction. Are you sure it’s a rotary encoder and not a potentiometer? They can look identical but function completely different. You’ve not provided much information, that’s why no one is answering youm
Thanks @Fallingaway24 for the reply.
The hardware is based on mosfet boards powering up COB LEDs, controlled by the same ESP32 connected to the rotary encoder. The lights work fine when controlled directly by HA but I’m struggling with the rotary encoder. I found the cause of the problem I mentioned earlier, it was related to the ESP pins I used. I was not even getting anything from it in the logs, but when I changed the pins to 32 and 33 it started working.
The problem now is how to get a stable signal from the rotary encoder. I created a new post, as this is a different problem. I will either have to replace the cable or add a new ESP32 closer to the encoder and use a different programming approach.