Zigbee2MQTT - Aqara Door Sensor keeps triggering automations when state hasn't changed

I switched from my old HUSBZB-1 to a Sonoff Dongle-P the other day and also switched from ZHA to Zigbee2MQTT. Everything worked well on the old coordinator but after switching all the door sensors seem to be triggering state changes in automations even when they don’t change state. Looking at the history for the sensor you can see where it says there was a change but it will be closed and changed to closed. It seems to happen ever 1-2 hours.

This behavior is triggering automations in a few of them, some closet lights set to turn on when the door is opened but turn off if it’s been open for more than 10 minutes which if I leave them open will eventually be turned on again for 10 minutes and front door notifications keep getting sent that the door was closed.

I’m still really new to Zigbee2MQTT and MQTT so I’m a bit lost in figuring this out. Is this just the sensors waking and sending an updated status through MQTT? If so is there a way to mitigate this problem?

The do work normally for when I actually open and close them too. No delay or connection issues seem apparent, so I’m thinking it’s something to do with the MQTT part.

I figured this one out after some digging. The Aqara sensors have a “device temperature” that would regularly change a few degrees up and down. This was triggering a state change because of they way zigbee2MQTT/MQTT sends messages (which I didn’t really understand at first).

The solution was to just make sure I had a from: in my triggers that was missing from a few of my automations. And for the one that was part of an HACS integration where I didn’t want to change the automation (keymaster), I just filtered all the attributes except contact in Zigbee2MQTT.

I never understood why they even have the device temperature anyway. Doesn’t seem to be particularly useful or important.