Tasmota Hub MQTT Discovery

Hello All,
I recently started getting into Home Assistant and most of the integrations are working fine - I have a zigbee hub thats running tasmota and im having some difficulty getting it to discovery my temperature sensors

I’ve installed the mosquitto mqtt broker on my HA install and I’ve configured the MQTT section of the Tasmota interface - HA has automatically added the Tasmota card for me but i cant see any devices.

using mosquitto-sub command line tool, I can see messages going to the broker from the tasmota hub, but im not sure how to get the individual sensors to show up on HA

I see regular updates coming into MQTT on this topic:

stat/tasmota_2D4904/RESULT {"ZbStatus1":[{"Device":"0x1F24","Name":"Room"}]}
stat/tasmota_2D4904/RESULT {"ZbStatus3":[{"Device":"0x1F24","Name":"Room","IEEEAddr":"0xA4C138054C9FF9FF","ModelId":"TS0201","Manufacturer":"_TZ3000_xr3htd96","Endpoints":[1],"Config":["T01"],"Temperature":23.17,"Humidity":33.18,"Reachable":true,"BatteryPercentage":100,"BatteryLastSeenEpoch":1713851447,"LastSeen":1190,"LastSeenEpoch":1713864372,"LinkQuality":107}]}

any pointers would be appreciated

There is no autodiscovery for Zigbee devices in Zigbee2Tasmota. You have to define them in .yaml

tasmota.github.io

Zigbee - Tasmota

Documentation (Wiki) for Tasmota

https://thehelpfulidiot.com/how-to-use-zigbee2tasmota-with-home-assistant

Ah thats annoying that I have to do it manually :smiley: - So the “Tasmota” card that’s been added seems pretty useless for me as all my devices are via the hub and not individual Wifi enabled tasmota devices?

Thanks for those links - I tried SetOption 89 to make the topic be more useful, but it doesnt seem to have changed how it reports

That said, I’ve added this to my configuration.yaml but it still doesnt seem to recognise it

mqtt:
  sensor:
    - name: "Tasmota Temperature"
      state_topic: "stat/tasmota_2D4904/RESULT"
      value_template: "{{ value_json['ZbStatus3'].Temperature }}"
      unit_of_measurement: "°C"  
      availability_topic: "tele/tasmota_2D4904/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      device_class: temperature
      unique_id: "{{ value_json['ZbStatus3'].IEEEAddr }}"

As an aside, this looks like i wont be able to do multiple devices unless i can actually get the topic to be unique per device?

For simplicity of reading, this is a formatted version of the JSON i see on MQTT

stat/tasmota_2D4904/RESULT
{
    "ZbStatus3": [
        {
            "Device": "0x1F24",
            "Name": "Room",
            "IEEEAddr": "0xA4C138054C9FF9FF",
            "ModelId": "TS0201",
            "Manufacturer": "_TZ3000_xr3htd96",
            "Endpoints": [
                1
            ],
            "Config": [
                "T01"
            ],
            "Temperature": 23.23,
            "Humidity": 32.89,
            "Reachable": false,
            "BatteryPercentage": 100,
            "BatteryLastSeenEpoch": 1713865757,
            "LastSeen": 885,
            "LastSeenEpoch": 1713865757,
            "LinkQuality": 107
        }
    ]
}

OK, I’ve made a little bit of progress here…

Re the topic - The blog you linked me to was missing part of the command… on my Tasmota console I ran this
ZbDeviceTopic SetOption89

Which seems to correctly result in telemetry updates having the device ID in the topic:
tele/tasmota_2D4904/1F24/SENSOR

So, with that, I’ve added the following to my main configuration.yaml

mqtt:
  sensor:
    - name: "Room Temperature"
      unique_id: "0x1F24"
      state_topic: "tele/tasmota_2D4904/1F24/SENSOR"
      value_template: >
        {% if value_json['ZbReceived']['1F24']['Temperature'] > 0 %}
          {{ (value_json['ZbReceived']['1F24']['Temperature']|float + 1.8) + 32 }}
        {% else %}
          {{ states(entity_id) }}
        {% endif %}
      unit_of_measurement: "°C"  
      availability_topic: "tele/tasmota_2D4904/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      device_class: temperature

However, if I go into the MQTT integration and look at the devices/entities - if I select the new entity, it says Unknown and shows a last update of over 30 minutes ago with no data in the graph… I can see events coming into MQTT under the state topic so I’m not quite sure what I’ve missed here

Topic: tele/tasmota_2D4904/1F24/SENSOR
Data:

{
    "ZbReceived": {
        "0x1F24": {
            "Device": "0x1F24",
            "Name": "Room",
            "Temperature": 23.89,
            "Humidity": 31.89,
            "Endpoint": 1,
            "LinkQuality": 105
        }
    }
}

Presumably I’ll get similar events for Battery when the value changes, but for now I wanted to focus on just getting Temperature logged and I’ll fix humidity/battery once I have that working

Any further advice on how to get this working (Without switching to ZHA, as I have other things that poke the Tasmota API)

Try it so

mqtt:
  sensor:
    - name: "Room Temperature"
      unique_id: "0x1F24"
      state_topic: "tele/tasmota_2D4904/0x1F24/SENSOR"
      value_template: >
        {% if value_json['ZbReceived']['0x1F24']['Temperature'] > 0 %}
          {{ (value_json['ZbReceived']['0x1F24']['Temperature']|float + 1.8) + 32 }}
        {% else %}
          {{ states(entity_id) }}
        {% endif %}
      unit_of_measurement: "°C"  
      availability_topic: "tele/tasmota_2D4904/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      device_class: temperature

You need the correct strings, replacing 0x1F24 with 1F24 is no good

1 Like

AHH! Such a simple oversight on my part not using the correct key from the variable… Thanks!

image

For anyone elses benefit using Zigbe2Tasmota

  1. Set up an MQTT Broker (I used the Add-On built into Home Assistant called “Mosquitto broker”
  2. Set up your Tasmota hub to connect to this MQTT Broker
  3. Add the MQTT Integration and connect it to your broker
  4. Optional, but makes it easier to differentiate devices, set your Tasmota to publish the device name in the topic - ZbDeviceTopic SetOption89
  5. Add this to your config… This is for temperature but should be easy to adapt once it works (Note I’m using a different device ID here than before)
mqtt:
  sensor:
    - name: "Room Temperature"
      unique_id: "0x8282"
      state_topic: "tele/tasmota_2D4904/8282/SENSOR"
      value_template: >
        {% if value_json['ZbReceived']['0x8282']['Temperature'] > 0 %}
          {{ value_json['ZbReceived']['0x8282']['Temperature'] }}
        {% else %}
          {{ states(entity_id) }}
        {% endif %}
      unit_of_measurement: "°C"
      availability_topic: "tele/tasmota_2D4904/LWT"
      payload_available: "Online"
      payload_not_available: "Offline"
      device_class: temperature

Thank you for your help here @francisp !!