Smart Home Automation Forum
Create light switch in home assistant using MQTT - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=20)
+--- Forum: KC868-A16 (https://www.kincony.com/forum/forumdisplay.php?fid=25)
+--- Thread: Create light switch in home assistant using MQTT (/showthread.php?tid=3298)



Create light switch in home assistant using MQTT - truongdq54 - 09-20-2023

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.     
Please help!


RE: Create light switch in home assistant using MQTT - admin - 09-20-2023

i think you can use "switch", just change UI for "light" ico is better.


RE: Create light switch in home assistant using MQTT - truongdq54 - 09-22-2023

Thank you, it works!