Considering https://community.home-assistant.io/t/homeassistant-number-how-does-it-work/842982/10 let's make the device independent from HA, i.e. add the possibility to dim the LED. The most intuitive way is perhaps a rotary button.
This can be done easily and just requires two GPIOs:
The code needs to be added to the sensor section.
sensor:
- platform: rotary_encoder
name: "Rotary Button"
pin_a: GPIO4 #D2
pin_b: GPIO5 #D1
min_value: 0
max_value: 100
on_clockwise:
- light.dim_relative:
id: red_led
relative_brightness: 5%
transition_length: 500ms
on_anticlockwise:
- light.dim_relative:
id: red_led
relative_brightness: -5%
transition_length: 500ms
The code is pretty self-explanatory.
This also turns up in the sensors field in HA. But to dim it from HA, the red LED needs to be clicked.
![](https://cdn.hackaday.io/images/9233911739216279106.png)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.