GitXplorerGitXplorer
a

esphome-light-gradient

public
2 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
7cf6f56c2ed457aa9bac77cf9f2679cb3580cf78

Add brightness support

aa0s committed 2 years ago
Verified
41d23573c0efca494edef7f17da22311996f429e

Update README.md

aa0s committed 2 years ago
Verified
2043df0bb9d6f6677c0815fc5afc96441481907d

Update README.md

aa0s committed 2 years ago
Verified
cfa57e83175ac3855b4c5270e2dc0975b87fe233

Update README.md

aa0s committed 2 years ago
Verified
f19c91ec5eb740b2b9aa10facffa6f9d379068bf

Update README.md

aa0s committed 2 years ago
Verified
ff8590d4f8271e3f2d005baecbbe8ca7641de9c0

Update README.md

aa0s committed 2 years ago

README

The README file for this repository.

ESPHome Light Gradient šŸŒˆ

An example how to create color (or brightness) gradient with regular FastLED and Home Assistant (HASS)

Devices

In both devices, I was forced to replace their native controllers (Tuya and Magic Home) with regular esp8266. No additional power tricks were needed. Both devices use ws2812b, or their clones. The pinout was determined with the help of an oscilloscope.

How it works

In the current solution, each device in the HASS interface is represented by three entities. Two RGB Lights are used to determine the color at the beginning and end of the gradient. The Template Select is employed to switch between different operating modes of the LED strip, as well as to turn it off.

HASS entity list

Screenshot 2023-05-24 at 00 26 45Screenshot 2023-05-24 at 00 26 30

The RGB Light isn't real, we're just using this entity as an interface for color selection on the HASS side. To use it, we need a fake output:

esphome:
  includes:
    - esphome/NullOutputComponent.h
output:
  - platform: custom
    type: float
    lambda: |-
      auto my_output = new NullOutputComponent();
      App.register_component(my_output);
      return {my_output};
    outputs:
      id: null_output_float

āš ļø To be able to set a specific color for each LED, we use Addressable Light over FastLED Light. Addressable Light supports so-called pages, on which different content can be presented. It's these pages that we switch using Template Select. All the magic of rendering happens in the description of the pages. The RGB Lights are used as a color source for the start and end of the gradient.

The LED strip is defined using fastled_clockless. The restore_mode: ALWAYS_ON mode is used so as not to interfere with the operation of addressable_light.

Don't forget to update the mosaic_leds_count variable with the actual number of LEDs. Also, update the GPIO pin to the one you are using.

Disadvantages

  • To control one light source, you need to visit three popup dialogs in HASS. Here, scenes help a little.
  • To control two different light sources, you need to have a full copy of the source codes with differing IDs. This is quite error-prone when copy-pasting.
  • It's impossible to adequately control the colors from the ESPHome web interface. The necessary controls are simply not available: Screenshot 2023-05-24 at 10 59 43