I am making a dimmer with ESPHome.
An ESP12e with rotary encoder.
I can dim the LED with the rotary encoder, I can dim with the slider in the menu.
The only problem is that the slider does not move when I turn the rotary encoder.
I once made this with push buttons and the slider does move with it.
How can I fix this?
This is my code:
A couple of things in your config, which don’t answer your question, but you should probably fix anyway:
You should remove your global x as this is defined automatically by ESPHome for each sensor.
Your first lambda does nothing so you should remove it completely. This is because your rotary encoder min and max values already limit the output values between 0 and 52. You don’t need to “return x;” either.
I don’t think you’ll ever see 52 because you’ve used “delta 10”. You’ll only see 0, 10, 20, 30, 40 and 50.
Your first lambda does nothing so you should remove it completely. This is because your rotary encoder min and max values already limit the output values between 0 and 52. You don’t need to “return x;” either.
I have remove the first lambda (didn’t nothing) , if I remove the . "return x/52;" then did’t work dimming the led with the rotary.
I don’t know what else I must place in “level”
I don’t think you’ll ever see 52 because you’ve used “delta 10”. You’ll only see 0, 10, 20, 30, 40 and 50.
Thanks that’s the solution.
Now I can finetune the code and toggle on/off.
Do you know how it’s possible that I can’t change " x " in id(global_dim)
lambda : Perform a simple mathematical operation over the sensor values. The input value is x and the result of the lambda is used as the output (use return ).