mqtt:
  light:
    - name: "light_le_1"
      state_topic: "tele/light_le_1/STATE"
      state_value_template: "{{ value_json.POWER }}"
      command_topic: "cmnd/light_le_1/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      availability_topic: "tele/light_le_1/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      on_command_type: "brightness"
      brightness_command_topic: "cmnd/light_le_1/Dimmer"
      brightness_state_topic: "tele/light_le_1/STATE"
      brightness_scale: 100
      brightness_value_template: "{{ value_json.Dimmer }}"
      color_temp_command_topic: "cmnd/light_le_1/CT"
      color_temp_state_topic: "tele/light_le_1/STATE"
      color_temp_value_template: "{{ value_json.CT }}"
      qos: 1
      retain: false

    - name: "light_le_2"
      state_topic: "tele/light_le_2/STATE"
      state_value_template: "{{ value_json.POWER }}"
      command_topic: "cmnd/light_le_2/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      availability_topic: "tele/light_le_2/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      on_command_type: "brightness"
      brightness_command_topic: "cmnd/light_le_2/Dimmer"
      brightness_state_topic: "tele/light_le_2/STATE"
      brightness_scale: 100
      brightness_value_template: "{{ value_json.Dimmer }}"
      color_temp_command_topic: "cmnd/light_le_2/CT"
      color_temp_state_topic: "tele/light_le_2/STATE"
      color_temp_value_template: "{{ value_json.CT }}"
      qos: 1
      retain: false

    - name: "light_le_3"
      state_topic: "tele/light_le_3/STATE"
      state_value_template: "{{ value_json.POWER }}"
      command_topic: "cmnd/light_le_3/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      availability_topic: "tele/light_le_3/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      on_command_type: "brightness"
      brightness_command_topic: "cmnd/light_le_3/Dimmer"
      brightness_state_topic: "tele/light_le_3/STATE"
      brightness_scale: 100
      brightness_value_template: "{{ value_json.Dimmer }}"
      color_temp_command_topic: "cmnd/light_le_3/CT"
      color_temp_state_topic: "tele/light_le_3/STATE"
      color_temp_value_template: "{{ value_json.CT }}"
      qos: 1
      retain: false

    - name: "light_le_4"
      state_topic: "tele/light_le_4/STATE"
      state_value_template: "{{ value_json.POWER }}"
      command_topic: "cmnd/light_le_4/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      availability_topic: "tele/light_le_4/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      on_command_type: "brightness"
      brightness_command_topic: "cmnd/light_le_4/Dimmer"
      brightness_state_topic: "tele/light_le_4/STATE"
      brightness_scale: 100
      brightness_value_template: "{{ value_json.Dimmer }}"
      color_temp_command_topic: "cmnd/light_le_4/CT"
      color_temp_state_topic: "tele/light_le_4/STATE"
      color_temp_value_template: "{{ value_json.CT }}"
      qos: 1
      retain: false

    - name: "light_lohas_2"
      state_topic: "tele/light_lohas_2/STATE"
      state_value_template: "{{ value_json.POWER }}"
      command_topic: "cmnd/light_lohas_2/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      availability_topic: "tele/light_lohas_2/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      on_command_type: "brightness"
      brightness_command_topic: "cmnd/light_lohas_2/Dimmer"
      brightness_state_topic: "tele/light_lohas_2/STATE"
      brightness_scale: 100
      brightness_value_template: "{{ value_json.Dimmer }}"
      hs_command_topic: "cmnd/light_lohas_2/HSBColor"
      hs_state_topic: "tele/light_lohas_2/STATE"
      hs_value_template: "{{ value_json.HSBColor.split(',')[0:2]|join(',') }}"
      color_temp_command_topic: "cmnd/light_lohas_2/CT"
      color_temp_state_topic: "tele/light_lohas_2/STATE"
      color_temp_value_template: "{{ value_json.CT }}"
      qos: 1
      retain: false
      effect_command_topic: "cmnd/light_lohas_2/Scheme"
      effect_state_topic: "tele/light_lohas_2/STATE"
      effect_value_template: "{{value_json.Scheme}}"
      effect_list: [0, 1, 2, 3, 4]

    - name: "light_lohas_6"
      state_topic: "tele/light_lohas_6/STATE"
      state_value_template: "{{ value_json.POWER }}"
      command_topic: "cmnd/light_lohas_6/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      availability_topic: "tele/light_lohas_6/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      on_command_type: "brightness"
      brightness_command_topic: "cmnd/light_lohas_6/Dimmer"
      brightness_state_topic: "tele/light_lohas_6/STATE"
      brightness_scale: 100
      brightness_value_template: "{{ value_json.Dimmer }}"
      hs_command_topic: "cmnd/light_lohas_6/HSBColor"
      hs_state_topic: "tele/light_lohas_6/STATE"
      hs_value_template: "{{ value_json.HSBColor.split(',')[0:2]|join(',') }}"
      color_temp_command_topic: "cmnd/light_lohas_6/CT"
      color_temp_state_topic: "tele/light_lohas_6/STATE"
      color_temp_value_template: "{{ value_json.CT }}"
      qos: 1
      retain: false
      effect_command_topic: "cmnd/light_lohas_6/Scheme"
      effect_state_topic: "tele/light_lohas_6/STATE"
      effect_value_template: "{{value_json.Scheme}}"
      effect_list: [0, 1, 2, 3, 4]

  sensor:
    - name: "light_le_1_wifi"
      availability_topic: "tele/light_le_1/LWT"
      device_class: signal_strength
      payload_available: "Online"
      payload_not_available: "Offline"
      state_topic: "tele/light_le_1/STATE"
      unit_of_measurement: "%"
      value_template: "{{ value_json.Wifi.RSSI }}"

    - name: "light_le_2_wifi"
      availability_topic: "tele/light_le_2/LWT"
      device_class: signal_strength
      payload_available: "Online"
      payload_not_available: "Offline"
      state_topic: "tele/light_le_2/STATE"
      unit_of_measurement: "%"
      value_template: "{{ value_json.Wifi.RSSI }}"

    - name: "light_le_3_wifi"
      availability_topic: "tele/light_le_3/LWT"
      device_class: signal_strength
      payload_available: "Online"
      payload_not_available: "Offline"
      state_topic: "tele/light_le_3/STATE"
      unit_of_measurement: "%"
      value_template: "{{ value_json.Wifi.RSSI }}"

    - name: "light_le_4_wifi"
      availability_topic: "tele/light_le_4/LWT"
      device_class: signal_strength
      payload_available: "Online"
      payload_not_available: "Offline"
      state_topic: "tele/light_le_4/STATE"
      unit_of_measurement: "%"
      value_template: "{{ value_json.Wifi.RSSI }}"

    - name: "light_lohas_2_wifi"
      availability_topic: "tele/light_lohas_2/LWT"
      device_class: signal_strength
      payload_available: "Online"
      payload_not_available: "Offline"
      state_topic: "tele/light_lohas_2/STATE"
      unit_of_measurement: "%"
      value_template: "{{ value_json.Wifi.RSSI }}"

    - name: "light_lohas_6_wifi"
      availability_topic: "tele/light_lohas_6/LWT"
      device_class: signal_strength
      payload_available: "Online"
      payload_not_available: "Offline"
      state_topic: "tele/light_lohas_6/STATE"
      unit_of_measurement: "%"
      value_template: "{{ value_json.Wifi.RSSI }}"

  # ## Switch
  switch:
    - name: "light_le_1_fade"
      availability_topic: "tele/light_le_1/LWT"
      command_topic: "cmnd/light_le_1/FADE"
      icon: mdi:gradient
      payload_available: "Online"
      payload_not_available: "Offline"
      qos: 1
      state_topic: "tele/light_le_1/STATE"
      value_template: "{{ value_json.Fade }}"

    - name: "light_le_2_fade"
      availability_topic: "tele/light_le_2/LWT"
      command_topic: "cmnd/light_le_2/FADE"
      icon: mdi:gradient
      payload_available: "Online"
      payload_not_available: "Offline"
      qos: 1
      state_topic: "tele/light_le_2/STATE"
      value_template: "{{ value_json.Fade }}"

    - name: "light_le_3_fade"
      availability_topic: "tele/light_le_3/LWT"
      command_topic: "cmnd/light_le_3/FADE"
      icon: mdi:gradient
      payload_available: "Online"
      payload_not_available: "Offline"
      qos: 1
      state_topic: "tele/light_le_3/STATE"
      value_template: "{{ value_json.Fade }}"

    - name: "light_le_4_fade"
      availability_topic: "tele/light_le_4/LWT"
      command_topic: "cmnd/light_le_4/FADE"
      icon: mdi:gradient
      payload_available: "Online"
      payload_not_available: "Offline"
      qos: 1
      state_topic: "tele/light_le_4/STATE"
      value_template: "{{ value_json.Fade }}"

    - name: "light_lohas_2_fade"
      availability_topic: "tele/light_lohas_2/LWT"
      command_topic: "cmnd/light_lohas_2/FADE"
      icon: mdi:gradient
      payload_available: "Online"
      payload_not_available: "Offline"
      qos: 1
      state_topic: "tele/light_lohas_2/STATE"
      value_template: "{{ value_json.Fade }}"

    - name: "light_lohas_3_fade"
      availability_topic: "tele/light_lohas_3/LWT"
      command_topic: "cmnd/light_lohas_3/FADE"
      icon: mdi:gradient
      payload_available: "Online"
      payload_not_available: "Offline"
      qos: 1
      state_topic: "tele/light_lohas_3/STATE"
      value_template: "{{ value_json.Fade }}"

    - name: "light_lohas_6_fade"
      availability_topic: "tele/light_lohas_6/LWT"
      command_topic: "cmnd/light_lohas_6/FADE"
      icon: mdi:gradient
      payload_available: "Online"
      payload_not_available: "Offline"
      qos: 1
      state_topic: "tele/light_lohas_6/STATE"
      value_template: "{{ value_json.Fade }}"

automation:
  - alias: Lighting · Sync Tasmota states on start-up
    initial_state: true
    trigger:
      platform: homeassistant
      event: start
    action:
      - service: mqtt.publish
        data:
          topic: "cmnd/tasmotas/STATE"
          payload: ""
