I’m trying to make a dimmer with an esp and a rotary encoder.
Does anyone give me an hint.
I have a Rotary Encoder
sensor:
- platform: rotary_encoder
name: "Rotary Encoder"
pin_a: D1
pin_b: D2
min_value: 0
max_value: 100
resolution: 2
and
light:
- platform: monochromatic
name: "Ceiling light"
output: output_component1
output:
- platform: esp8266_pwm
id: output_component1
pin: D6
Invidually is this working but I want to dim the lights with the rotary-encoder but how must I program this in the ESP?
I don’t understand the lambda language, is there anywhere an explanation of it?
nickrout
(Nick Rout)
March 25, 2020, 2:46am
4
It is c++ - look at the custom component pages on esphome.io
I am a little further with the dimmer .
If I turn the rotary encoder , the led dim.
The only thing whet’s not work is the following:
The slider in HA did not correspond with the rotary encoder.
what I’m doing wrong?
sensor:
- platform: rotary_encoder
name: "Rotary Encoder"
pin_a: D1
pin_b: D2
min_value: 0
max_value: 52
resolution: 4
filters:
- or:
- debounce: 0.1s
- delta: 10
- lambda: |-
if (x < 0.0) return 0.0;
if (x > 52.0) return 52.0;
return x;
on_value:
then:
- output.set_level:
id: pwm_output
level: !lambda "return x/53.0;"
- logger.log:
format: "pwm_output set to %.1f%s"
args: [ 'x*100/53.0', '"%"' ]
light:
- platform: monochromatic
output: pwm_output
name: "LED-Lamp"
output:
- platform: esp8266_pwm
pin: D6
inverted: true
frequency: 1000 Hz
id: pwm_output