Sensors update in Z2M but not in HA via MQTT

I’ve been trying to figure this out of a long time and been playing with a lot of settings and even different sensor manufactures. Some work some fail. I would really appreciate some help.

Coordinator: Sonoff Zigbee 3 USB dongle plus V2
Sensor: Sonoff SNZB-03 (I have same issue with OSRAM motion sensor also)
Both sensor are joined to the coordinator directly.
The sensor show in Z2MQTT and show updated status when motion is detected.

The sensor show a status of clear in HA but don’t detect any changes.
I have permit join checked. (I saw another post showing that as a fix).


you can see the last seen changed 31 seconds ago when I triggered it.

you can see the HA value didn’t change to detected 31 seconds ago when it should have been triggered.

Its probably my fault somehow but I don’t know what the problem is?

I’m not a big fan of using the automatic sensor creation feature of Home Assistant’s MQTT and other sensors. That said, it does save a lot of typing…

To your issues, are you sure you are looking at the same entity in Home Assistant?
I see a friendly name name of “Utility_Motion_Sonoff” in Zigbee2MQTT, however you seem to be looking at “UtilitySensorZBSonoff” in Home Assistant…

Good hunting!

The friendly names are consistent but the entity names match. I’ve been using the update homessistant option.

I will do further testing and report back but I have been doing the same function for all. Some work some don’t.

Thank you so much for reviewing and advising.

If you have not already, I would have a look at your MQTT broker and see what topic and message Zigbee2MQTT is publishing to the MQTT broker for the device. I find the tool ‘MQTT Explorer’ very helpful, link below.

I’m not an expert on how Home Assistant’s automatic sensor creation works, however I believe you should see something similar to picture below in your MQTT broker. I think under the “homeassistant/sensor” topic, a couple of topics per device, one should be JSON data structure with the automatic configuration info, including the MQTT topic where the sensor should be publishing. And then the second subtopic should be the reading from the sensor. Good hunting!

1 Like

I’m sorry in my last post I meant to say the friendly names were NOT consistent. I was replying from my phone while rushing out.
I can monitor my MQTT from container logs and I did do that before when trouble shooting and I didn’t see any entires but on checking again after your post they messages were appearing but I also notice the status was also updating.

I’m very confused while it started to work as soon as I asked for help but I will monitor and update.

Thank you very much dproffer!!

1 Like

Thank you very much for your help. I used the tool to determine a few errors I had like not using homeassistant for the topic which is needed for discovery, I also had the wrong status topic.

Thanks again the tool helped and without your help I would have been lost.

EDIT: I was wrong it worked for a while but now still doesn’t update the entity status of detected into home assistant even when its registered in z2mqtt. I will keep looking it this and report if I figure it out.

1 Like

Ok with future testing I tried changing my channel from 25 to 11 at first it looked great as it always does but then one of the sensors would re pair and I tried adding a new device and it wouldnt pair either.
If I restart zigbee2mqtt then try and pair a new device right away it works though.

I’m still investigating.

I know no one is reading this anymore but I have found some clues.
Screenshot 2023-12-24 130153

The device goes missing when my system does it backup (3am) and when it comes back its there and shows in zigbee2mqtt with its correct status but in HA it fails to update UNLESS i manually Restart Zigbee2MQTT from the UI, then it* works perfectly again. (it being 2 different motion sensors one sonoff the other ozram).

When I tinker to fix it I often restart z2m which makes me think I fixed it with my trial and error BUT then it goes offline the next day. Oh and all my other zigbee devices work fine, its just these two that do this.

Because I don’t know what the problem is I could short term just create an automation to restart MQTT. If thats possible from the default automation software? I don’t use nodered.

This script works… if I ever figure this out I will update this post.

alias: Restart MQTT
description: total hack job
trigger:
  - platform: time
    at: "04:30:00"
condition: []
action:
  - service: hassio.addon_restart
    data:
      addon: 45df7312_zigbee2mqtt
mode: single