{"id":19310971,"url":"https://github.com/a0s/esphome-light-gradient","last_synced_at":"2026-04-09T08:36:27.285Z","repository":{"id":168810323,"uuid":"644609581","full_name":"a0s/esphome-light-gradient","owner":"a0s","description":"An example how to create gradient with regular FastLED and Home Assistant","archived":false,"fork":false,"pushed_at":"2023-05-29T20:26:03.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-06T02:12:10.536Z","etag":null,"topics":["esp32","esp8266","esphome","esphome-light","hass","home-assistant","ws2812b"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a0s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-23T22:12:40.000Z","updated_at":"2024-10-20T20:29:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"e9d64874-fb6b-45ad-9200-7b1c9e94e2d4","html_url":"https://github.com/a0s/esphome-light-gradient","commit_stats":null,"previous_names":["a0s/esphome-light-gradient"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a0s%2Fesphome-light-gradient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a0s%2Fesphome-light-gradient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a0s%2Fesphome-light-gradient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a0s%2Fesphome-light-gradient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a0s","download_url":"https://codeload.github.com/a0s/esphome-light-gradient/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240412024,"owners_count":19797191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esp32","esp8266","esphome","esphome-light","hass","home-assistant","ws2812b"],"created_at":"2024-11-10T00:27:09.338Z","updated_at":"2026-04-09T08:36:22.254Z","avatar_url":"https://github.com/a0s.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESPHome Light Gradient 🌈\nAn example how to create color (or brightness) gradient with regular [FastLED](https://esphome.io/components/light/fastled.html) and [Home Assistant](https://esphome.io/guides/getting_started_hassio.html) (HASS)\n\n\u003cimg width=\"40%\" src=\"https://github.com/a0s/esphome-light-gradient/assets/418868/ddd13978-b596-45c1-b3b1-fd2ce66dc9f5\"\u003e\n\u003cimg width=\"40%\" src=\"https://github.com/a0s/esphome-light-gradient/assets/418868/0ad3c38d-1cdf-456a-947e-2c53c720e060\"\u003e\n\n## Devices\n- [WiFi Smart LED Light Bar RGB Atmosphere Light Music Synchronization 12 Modes TV Wall Computer Game Room Decoration Night Light](https://www.aliexpress.com/item/1005004983859307.html)\n- [RGB Bluetooth LED Hexagon Light Indoor Wall Light APP Remote Control Night Light Computer Game Room Bedroom Bedside Decoration\n](https://www.aliexpress.com/item/1005003380581309.html)\n\nIn 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.\n\n## How it works\n\nIn the current solution, each device in the HASS interface is represented by three entities. Two [RGB Lights](https://esphome.io/components/light/rgb.html) are used to determine the color at the beginning and end of the gradient. The [Template Select](https://esphome.io/components/select/template.html) is employed to switch between different operating modes of the LED strip, as well as to turn it off.\n\n\u003cimg width=\"90%\" alt=\"HASS entity list\" src=\"https://github.com/a0s/esphome-light-gradient/assets/418868/2410da65-ff24-4ebd-9c83-258cff03907e\"\u003e\n\n\u003cimg width=\"40%\" alt=\"Screenshot 2023-05-24 at 00 26 45\" src=\"https://github.com/a0s/esphome-light-gradient/assets/418868/c805eeef-70bb-4d85-a751-4c98f6aa0b5f\"\u003e\u003cimg width=\"40%\" alt=\"Screenshot 2023-05-24 at 00 26 30\" src=\"https://github.com/a0s/esphome-light-gradient/assets/418868/63f27b74-5b3e-4d77-a1b5-3ee0279f5905\"\u003e\n\n\nThe 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/NullOutputComponent.h):\n\n```yaml\nesphome:\n  includes:\n    - esphome/NullOutputComponent.h\noutput:\n  - platform: custom\n    type: float\n    lambda: |-\n      auto my_output = new NullOutputComponent();\n      App.register_component(my_output);\n      return {my_output};\n    outputs:\n      id: null_output_float\n```\n\n⚠️ To be able to set a specific color for each LED, we use [Addressable Light](https://esphome.io/components/display/addressable_light.html) over FastLED Light. Addressable Light supports so-called pages, on which different content can be presented. It's these pages that we [switch](/esphome/set_action.yaml) using Template Select. All the magic of rendering happens in the [description of the pages](/esphome/display_pages.yaml). The RGB Lights are used as a color source for the start and end of the gradient.\n\nThe 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.\n\nDon't forget to update the [mosaic_leds_count](https://github.com/a0s/esphome-light-gradient/blob/main/esphome.yaml#L2) variable with the actual number of LEDs. Also, update the [GPIO pin](https://github.com/a0s/esphome-light-gradient/blob/main/esphome.yaml#L43) to the one you are using.\n\n## Disadvantages\n\n- To control one light source, you need to visit three popup dialogs in HASS. Here, [scenes help a little](/home-assistant/scenes.yaml).\n- 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.\n- It's impossible to adequately control the colors from the ESPHome web interface. The necessary controls are simply not available: \u003cimg width=\"400\" alt=\"Screenshot 2023-05-24 at 10 59 43\" src=\"https://github.com/a0s/esphome-light-gradient/assets/418868/69883e08-2be6-4bca-a82f-0208fafb7bab\"\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa0s%2Fesphome-light-gradient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa0s%2Fesphome-light-gradient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa0s%2Fesphome-light-gradient/lists"}