How to control the LED with MQTT?

Help!
I can’t understand how to control the RGB LED with mqtt.
state_topic = ‘/LED’ format 4 numbers separated by commas (turn on/off (0/1) , R(0-255), G(0-255, B(0-255))
command_topic = ‘/LED/Set’
for example:
to turn on the red payload = ‘1, 255, 0, 0’
to disable payload = ‘0’

does not work :frowning: this is not a switch, but a light. And the example as light does not work because all the examples with the characteristics of JSON, and I need RAW.

1 Like

Then use MQTT Light.

What have you tried so far?

light:

  • platform: mqtt
    schema: template
    name: “led flokk1”
    unique_id: “flokk1_led_ble”
    command_topic: “/LED/Set”
    state_topic: “/LED”
    command_on_template: “1,{{ red|d }},{{ green|d }},{{ blue|d }}”
    command_off_template: “0”
    state_template: “{{ value.split(’,’)[0] }}”
    red_template: “{{ value.split(’,’)[1] }}”
    green_template: “{{ value.split(’,’)[2] }}”
    blue_template: “{{ value.split(’,’)[3] }}”

is different to /LED

Also it’d helpful if you told us what device you are trying to control.

thanks, but it didn’t help

the object is visible in the developer panel:

light.mqtt_template_light off friendly_name: led flokk1
supported_features: 56

I don’t understand how to manage this

/config/ui-lovelace.yaml:
- type: light
entity: light.mqtt_template_light
name: flokk1_led

Log:

Logger: homeassistant.components.mqtt.light.schema_template
Source: components/mqtt/light/schema_template.py:177
Integration: MQTT (documentation, issues)
First occurred: 14:28:51 (1 occurrences)
Last logged: 14:28:51

Invalid state value received


no one knows why it doesn’t work?

No response from you.

Please read this How to help us help you - or How to ask a good question

device: thingy52
connected via ble2mqtt

Really you are difficult to help. No logs, no idea what messages you are receiving from mqtt, no link to what a thingy52 is or what ble2mqtt is, or whether it supports home assistant discovery, or anything useful at all,

Heavens you can’t even be bothered formatting your text.

this is how it works, but only when you specify a specific color:

  - platform: mqtt
     schema: template
     name: "flokk1_led"
     command_topic: "/LED/Set"
     command_on_template: "1,255,0,0"
     command_off_template: "0"

Those don’t look like templates to me.