Hello my friends!
I have followed the ws2812b led driver instruction on github. I have completed the hardware and loaded the code. The module has now worked perfectly. It supports control via MQTT and many advanced customizations with JSON MQTT commands. Unfortunately, in the following section, the author instructed the Home Assistant, with only a little of my knowledge, can only control the lights and turn off, the remaining advanced effects are supported via JSON MQTT commands, I do not know how to do. how to do it despite trying to see examples of JSON MQTT.
I hope that you will help me how to complete it. The following is a document from github: GitHub - dullage/ESP-LED-MQTT: ESP8266 firmware to control WS2812 LEDs over MQTT. Works well with Home Assistant.
Home Assistant Examples
light: Basic control of a light.
- platform: mqtt
name: Lamp
state_topic: "light/lamp/state"
command_topic: "light/lamp"
rgb_state_topic: "light/lamp/rgb/state"
rgb_command_topic: "light/lamp/rgb"
availability_topic: "light/lamp/availability"
payload_not_available: "0"
payload_available: "1"
payload_off: "0"
payload_on: "1"
retain: false
Note: The recovery topic does not need to be used in the Home Assistant config.
input_select: UI to allow user to trigger an animation.
lamp:
name: Lamp
options:
- "Select..."
- "Warm Light"
- "Strobe"
- "Fire"
- "Colour Phase"
- "Sparkle"
- "Shoot / Drip"
- "Rain"
- "Rainbow 1"
- "Rainbow 2"
initial: "Select..."
automation: Sends the appropriate MQTT command when a mode is selected and then returns the input select back to ‘Select…’
- alias: "Lamp Mode"
trigger:
platform: state
entity_id: input_select.lamp
action:
- service: mqtt.publish
data_template:
topic: "switch/stairs"
payload: >
{% if trigger.to_state.state == 'Warm Light' %}
{0:2,2:[255,147,41]}
{% elif trigger.to_state.state == 'Strobe' %}
{0:3}
{% elif trigger.to_state.state == 'Fire' %}
{0:4}
{% elif trigger.to_state.state == 'Colour Phase' %}
{0:5,3:15}
{% elif trigger.to_state.state == 'Sparkle' %}
{0:6,2:[50,50,50],3:0,4:5,5:0}
{% elif trigger.to_state.state == 'Shoot / Drip' %}
{0:7,2:[255,147,41],8:0,10:1,9:30, 5:0 ,4:255,3:0,12:5,7:0}
{% elif trigger.to_state.state == 'Rain' %}
{0:8,11:1100}
{% elif trigger.to_state.state == 'Rainbow 1' %}
{0:12}
{% elif trigger.to_state.state == 'Rainbow 2' %}
{0:13}
{% else %}
{}
{% endif %}
retain: false
- service: input_select.select_option
data:
entity_id: input_select.stairlamp_mode
option: 'Select...'
My items:
Switch Bedroom_Light “Light” (Bedroom, gLight) [“Lighting”, “Switchable”] => I use the user interface to create Things and turn it on and off via topic: light/lamp
Number item = Bedroom_Light_Color
My Sitemap:
Switch item = Bedroom_Light label=“Bedroom Light” icon=“light”
Selection item = Bedroom_Light_Color label=“Light Color” icon=“rgb” mappings = [1 = “Warm Light”, 2 = “Strobe”, 3 = “Fire”, … 13 = “Rainbow 2”]
At this point, I don’t know how to get it to work with effects, which components I am missing? What are its rules like?
I hope you will take some time to give me a specific example in this case so that I can understand what works.
Sorry for my english! Thank you very much.