Is there any way to force a Zigbee device to report over MQTT

Hey there,

I use a few Zigbee Temp and Window sensors with a Sonoff Zigbee Bridge over MQTT.
They always report when something changes.
Is there a way to force them reporting ?

Thx


What I understand it's not possible.

Battery powered Zigbee devices will only report when there's a change in the sensor data or on regular base. Depend on the device but this is roughly every hour.
Or you can press the button on the sensor to send the data to the Tasmota bridge, however this is not what you want.

Why?, because these type of battery powered Zigbee sensors are deep sleeping the whole day and do not listen to incoming data to preserve battery life.

I want to check at 22:00 o'clock if any door or window is closed.
But sometimes a door sensor is showing "open" but the door is closed.
Maybe the device did not catch the signal I think.
So when it is possible to ask the device about the state I can fix this problem.
Do you have an other idea ?

Are you sure that is not a problem in your flow? If you add debug nodes showing the events coming in via MQTT and set the debug nodes to log to the console then you can look back when something is not correct and check whether you ever received the event or not.

I am pretty sure that there is no problem in my Flow, because the problem is not regular.
1st I thought that there is to much space between the reed contact, but the most of the time it is working properly.
But the hint with the debug note can help, to investigate. A troublesome thing...

Are the topics of type Retained? If not then when you restart node-red the values will revert to default rather than being initialised with the current state.

When I restart Node Red, everything is initialized with the default value. So the state is useless until the first report of the sensor.
Is there an easy possibility to remember the old values ?

Read what Colin wrote. retained is the key.
This you can find in the mqtt node.

The retained flag needs to be set by the publisher. Then when a subscriber connects it will be given the most recent value automatically.

Afaik retain is the default by Tasmota.

I m not sure if I catch you right, I use a MQTT in node.
Retain is only available for the MQTT out node, I think.
So I had to configure the retain option on the Tasmota Zigbee Bridge ?

It has to be configured in whatever publishes the value. It may or may not be the default.
The feature also has to be enabled in the MQTT broker, if you are using Mosquitto then it is enabled by default. Are you using Mosquitto?

Hi,
i don't know which sensors you use.

I have an aqara temp /hum/press sensor and I can get information from the sensor if I send the command ZBStatus3 <device id or (friendly)name or number in order>.

The incoming message is in the stat topic!

Yes I use Mosquitto. I use mostly the Sonoff SNZB

If you run, on the machine running mosquitto
mosquitto_sub -t "the/topic"
where the/topic is the topic containing the value, then if it is retained then you will immediately get a value. If it is not retained then you won't get a value until the device sends it again.

I use Mosquitto with Home Assistant, is SSH the only way go get a command line ?

That is not a question that can be answered with the available information, but if you haven't got terminal access to the device I can't imagine how you can maintain it.
You can also run mosquitto_sub remotely by specifying the ip address of the mosquitto server
mosquitto_sub -t "the/topic" -h "host_name_or_ip_address_of_mosquitto"
You will need the mosquitto client installed on the machine you want to run the sub of course.

Alternatively, and possibly easier, is to install MQTT Explorer which is a great piece of s/w which I use all the time and it will show you whether it is retained

image

According the Tasmota Zigbee help page: ZbStatus x Display Zigbee devices seen on the network since boot.
If I read this this will suggest that the information (Zbstatus) is coming from the Zigbee bridge his memory and not from the device.
Maybe you can test this by removing the battery from the sensor or trow it out of the window and see if the status is still actual.
Can't test it myself because I don't use the Tasmota Zigbee bridge anymore because it was soooo slow.

A little investigation:

  • after starting(power up) Zigbee2Tasmota (Z2T):
    • last read values are displayed on the web interface (obviously retained)

If the ZBStatus3 command is executed before the sensor has sent any data after starting Z2T, we have in the answer, among other things: "Reachable": false.

If the sensor sent data, we have a reading of all values, and also "Reachable": true.

Full message as respond to command ZBStatus3 immediately after power up Z2T and before sensor send 1st tele message:

{
	"ZbStatus3": [
		{
			"Device": "0xC492",
			"Name": "Temp1",
			"IEEEAddr": "0xXXXXXXXxxxxxx",
			"ModelId": "lumi.weather",
			"Manufacturer": "LUMI",
			"Endpoints": [
				1
			],
			"Config": [
				"T01"
			],
			"TempTarget": -327.68,
			"Temperature": 26.86,
			"Pressure": 1012,
			"Humidity": 51.82,
			"Reachable": false,
			"BatteryPercentage": 86,
			"LastSeen": 97,
			"LastSeenEpoch": 1611758099,
			"LinkQuality": 168
		}
	]
}

Full message as respond to command ZBStatus3 after power up Z2T and after sensor send 1st tele message:

{
	"ZbStatus3": [
		{
			"Device": "0xC492",
			"Name": "Temp1",
			"IEEEAddr": "0xXXXXXXXxxxxxx",
			"ModelId": "lumi.weather",
			"Manufacturer": "LUMI",
			"Endpoints": [
				1
			],
			"Config": [
				"T01"
			],
			"TempTarget": -327.68,
			"Temperature": 24.21,
			"Pressure": 1012,
			"Humidity": 54.65,
			"Reachable": true,
			"BatteryPercentage": 86,
			"LastSeen": 3,
			"LastSeenEpoch": 1611758460,
			"LinkQuality": 141
		}
	]
}

So,
if you send ZBStatus3 and get data in which Reachable is true, your temp / hum / press data is currently read.