Smart Home Automation Forum

Full Version: Create light switch in home assistant using MQTT
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If I create a switch, it works ok,
switch:
  - name: 'a16-kcs-output-1'
    unique_id: a16-kcs-output-1
    state_topic: 'KC868_A16/B0B21CCF0978/STATE'
    command_topic: 'KC868_A16/B0B21CCF0978/SET'
    payload_on:  '{"output1":{"value":true}}'
    payload_off:  '{"output1":{"value":false}}'
    value_template: '{{ value_json.output1.value }}'
    state_on: true
    state_off: false

But if I create a "light",
light:
  - name: 'my_led'
    unique_id: a16-kcs-output-led-wc-1
    state_topic: 'KC868_A16/B0B21CCF0978/STATE'
    command_topic: 'KC868_A16/B0B21CCF0978/SET'
    payload_on:  '{"output1":{"value":true}}'
    payload_off:  '{"output1":{"value":false}}'
    state_value_template: '{{ value_json.output1.value }}'

the UI in home assistant showed "Unknown" status. [attachment=3105]
Please help!
i think you can use "switch", just change UI for "light" ico is better.
Thank you, it works!
(09-20-2023, 10:10 PM)admin Wrote: [ -> ]i think you can use "switch", just change UI for "light" ico is better.

But, if I have to do "light" in my config.yaml?
Please, help!!!