Smart Home Automation Forum
KC868-D8 home assistant configuration.yaml update - Printable Version

+- Smart Home Automation Forum (https://www.kincony.com/forum)
+-- Forum: Technical Support (https://www.kincony.com/forum/forumdisplay.php?fid=1)
+--- Forum: News (https://www.kincony.com/forum/forumdisplay.php?fid=5)
+--- Thread: KC868-D8 home assistant configuration.yaml update (/showthread.php?tid=1152)



KC868-D8 home assistant configuration.yaml update - admin - 11-17-2021

follows support turn ON/OFF lamp by click "lamp" ico in home assistant.
   

light:
  - platform: mqtt
    name: dimmer1
    unique_id: dimmer1
    schema: template
    command_topic: "dimmer/xxxxxxxxxxxxxxxxxxxxxxxxxxxx/set"
    state_topic: "dimmer/xxxxxxxxxxxxxxxxxxxxxxxxxxxx/state"
    command_on_template: >
      {%- if brightness is defined -%}
      ,{"dimmer1":{"value":{{(brightness / 255 * 100) | int - 1}}}
      {%- else -%}
      ,'{"dimmer1":{"value":99}}'
      {%- endif -%}
     
    command_off_template: '{"dimmer1":{"value":0}}'

    state_template: >
      {%- if value_json.dimmer1.value == 0 -%}
        off
      {%- else -%}
        on
      {%- endif -%}
    brightness_template: '{{(value_json.dimmer1.value / 99 * 255)| int}}'