Switchs toogled on HA start-up

For unknown reason, some of my switches, regardless it is SONOFF or IKEA, are switch-on and switch-off sometimes switch-off or on a third time during HA start-up.

so first they toggled with no reason and second in some situation they are not even back to their initial status which is even more a problem.

This is not only cumbersome but quite scaring.
Any idea how to fix and have my switches left alone during HA reboot?

Are these switches used as triggers in any automations?

This can often happen when a trigger is written with a blank before: state as they are going unknown → off which may trigger things.

none of them are used as triggers in automation…

You posted in the genral Zigbee section without stating which Zigee implementation or which is the Zigbee Coordinator that you are using. If you had posted in the ZHA section then would have assumed the ZHA integration but without that info guess could be using Home Assistant’s ZHA integration, Zigbee2MQTT, deCONZ, or another Zigbee solution.

Anyway, I would just resetting the problem devices to their factory settings according to manufacturers instructions and then re-pairing them again after (all without removing them from Home Assistant).

Also, upgrade firmware on Zigbee Coordinator just as a best practice troubleshooting measurement.

If those don’t work then would post debug logs to → https://github.com/home-assistant/core/issues

I have however not seen such state change myself when using Home Assistant’s ZHA integration.

Probably not related but FYI, support for start_up_on_off will be added next zigpy release which will contain “Update ZCL with changes from v7 spec” so a startup option feature could be to ZHA after that:


  • start_up_on_off and start_up_current_level attributes, which control the power-on behavior of devices.

none firmware were updated (I strictly avoid that if something works), back to factory settings and re-pairing didn’t help here.

I was indeed posting here prior to raise an issue, in case this would be an obvious settings in HA or zigbee2mqtt, for instance a “Last Will” or “Testament” on reboot, or “On start up” instruction played during HA/mqtt/zigbee2mqtt start-up.

And thanks for the info on zipy which indeed give more control to user :grinning:.

I’ve run into this as @crlogic says with automations that trigger on “state” without specifying the from state when HA starts up.

I’ve used this to make a switch toggle something, e.g., I don’t care about the state, but if it changes I toggle the light. When HA starts up it goes from unknown to off and that triggers the automation. Note that this is not the state of the switch in the automation, but the state of something else that triggers the switch.

But beyond that I’ve never had turning on problems with IKEA wall plug switches (I have about 20 of them) when running on deconz.

But it is not working as it should, so would suggest upgrading firmware on your Zigbee Coordinator before doing any further troubleshooting. Zigbee Coordinator firmware also contains many bug-fixes regardless.

The mentioned new feature in zigpy is however only related to the Home Assistant’s ZHA integration.

Speaking about devices firmware, not the coordinator or HA +add-on which are maintained with latest stable version of course… like your installation I presume.

So no-one has a clue what could cause mqtt commands on HA/mqtt start-up.
I do see some advanced configuration on zigbee2mqtt regarding mqtt cache on start-up, which may deserve some investigations.

I might have found what was going on:
it seems that for 2 devices MQTT was retaining a “toogle” command message since ever.

I have deleted both messages thanks to MQTT-Explorer… and tests so far show I don’t get those unwanted switch-on-off on reboot.

Time will tell.