Zigbee2MQTT service restart turn all registered bulbs ON

I’m using OPENHAB 3.0 + Mosquitto as a Broker and Zigbee2Mqtt with CC2531 USB stick.
ISSUE:
When I restart the zigbee2mqtt.service on my Raspberry PI 4, all registered Zigbee2Mqtt bulbs will turn on. How can I prevent this from happening?

  • The bulbs were all OFF beforehand.
  • This is happening only with bulbs registered via Zigbee2Mqtt
  • Other MQTT devices like Shelly and Meross and Tuya will stay in their actual state.

**How can I prevent this behavior after restarting the zigbee2mqtt.service?

my state.json before starting the zigbee2mqtt.service clearly says “state”: OFF on the bulbs.
Or are e.g. the brightness state values forcing the bulbs to turn on?
{
“0x60a423fffef48cd4”: {
“occupancy”: true,
“battery”: 87,{
“0x60a423fffef48cd4”: {
“occupancy”: true,
“battery”: 87,
“update”: {
“state”: “idle”
},
“update_available”: false
},
“0x5c0272fffe52c1e2”: {
“update”: {
“state”: “idle”
},
“update_available”: false,
“state”: “OFF”,
“brightness”: 254
},
“0x5c0272fffe579b5d”: {
“brightness”: 15
},
“0x5c0272fffe628e1d”: {
“update”: {
“state”: “idle”
},
“update_available”: false,
“state”: “OFF”,
“brightness”: 254,
“color_temp”: 500
},
“0x086bd7fffe2f0f61”: {
“state”: “OFF”,
“update”: {
“state”: “idle”
},
“update_available”: false,
“brightness”: 251.46
},
“0x000b3cfffefda26b”: {
“update”: {
“state”: “idle”
},
“update_available”: false,
“state”: “OFF”,
“brightness”: 250
}
}

Other MQTT devices like Shelly and Meross

Sorry, this is OOT - but which Meross devices use your MQTT server? Ones you configured via @albertogeniola or @bytespider utilities?

I had this problem once, turned out I had some messages on my mqtt server with retain flags that were picked up each time I restarted z2m which were turning on the lights. Maybe something you should check…

Indeed, it was my persistent configuration of my MQTT Mosquitto Server.
After deleting the mosquitto.db and changing the persistent configuration as shown below, the annoying problem was gone.

The item states in openhab doesn’t seem to be affected by this configuration change as I’m using inside openhab MapDB and RRD4J as persistent service anyway.

Place your local configuration in /etc/mosquitto/conf.d/

A full description of the configuration file is at
/usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence true → changed it to false now !!!
persistence_location /var/lib/mosquitto/
autosave_on_changes true

log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d

see here - - Meross: python library with mqtt - #23 by betahydri - Solutions - openHAB Community