esphome-m5stickC icon indicating copy to clipboard operation
esphome-m5stickC copied to clipboard

Upgrade to change the brightness from HA

Open casamarbar opened this issue 3 years ago • 1 comments

Thanks for your job It would be possible to add a sensor to be able to change the brightness from HA of the screen?

casamarbar avatar Nov 09 '22 12:11 casamarbar

Create an input_number helper entity in Home Assistant called lcd_brightness that stores a value between 0 and 100, and then add the following to your esphome config to set the backlight level when the value changes:

sensor:
  - platform: axp192
    id: backlight
    …

  - platform: homeassistant
    id: brightness
    entity_id: input_number.lcd_brightness
    internal: true
    on_value:
      then:
        lambda: |-
          id(backlight).set_brightness(id(brightness).state/100.0);
          id(backlight).update();

c99koder avatar Feb 06 '23 17:02 c99koder