Finally! A Tasmota WiFi Dimmer with MQTT

To anyone that is using this in Home Assistant, with the big help of wkd2639 on the DrZzs Discord channel we were able to get a better brightness template to help deal with the way Tasmota reports the dimming to HomeAssistant. The previous version would cause some cosmetic errors to show up in your HomeAssistant logs. I’ve updated the template on the GitHub page as well as posting it here.

Change the brightness template entities to match your entity name as well as the topic names.

- platform: mqtt
  name: "TuyaDimTest"
  state_topic: "stat/TuyaDimTest/POWER"
  command_topic: "cmnd/TuyaDimTest/POWER"
  availability_topic: "tele/TuyaDimTest/LWT"
  brightness_state_topic: "stat/TuyaDimTest/RESULT"
  brightness_command_topic: "cmnd/TuyaDimTest/Dimmer"
  brightness_scale: 100
  brightness_value_template: >
    {% if value_json.Dimmer is defined %}
      {{ value_json.Dimmer }}
    {% else %}
      {% if state_attr('light.tuyadimtest','brightness') == none %}
        0
      {% else %}
        {{ state_attr('light.tuyadimtest','brightness') / 255 * 100 }}
      {% endif %}
    {% endif %}
  qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  payload_available: "Online"
  payload_not_available: "Offline"
  retain: false
1 Like