How to restart zigbee2MQTT after a Home Assistant Restart

I am new to Home Assistant, started migrating everything across at Christmas.

What I am looking for is a way to get Home Assistant to automatically restart zigbee2MQTT after Home Assistant has undergone a restart. I am sure it is possible just not figured it out yet and hoping for a pointer :slight_smile:

Issue

I have noticed every time I use the Home Assistant Developer Tools/Restart/Restart Home Assistant when Home Assistant comes back up all the zigbee2MQTT devices are unavailable in Home Assistant, all are working fine in zigbee2MQTT but all lost in Home Assistant.

I have worked around this by remembering ( most of the time) to restart zigbee2MQTT in the Add ons.

Desired outcome

But would like to find a way of avoiding the issue, ie some other restart method or automate the zigbee2MQTT restart once Home Assistant comes back up.

I have searched but not found anything that fits so far.

Relevant data
Core 2024.2.3
Supervisor 2024.02.0
OS 11.5
Frontend 20240207.1
zigbee2MQTT 1.35.3

Any ideas of what I am doing wrong or an automated workaround?

Something like this:

- id: '1565194745362'
  alias: Status starting HA
  trigger:
  - event: start
    platform: homeassistant
  action:
  - service: hassio.addon_restart
    data:
      addon: 45df7312_zigbee2mqtt
2 Likes

Thanks for the response - much appreciated.

New to Home Assistant …

Is this yaml? and do I just create an automation, edit in yaml and paste it in there?

Do you have it set to start on boot?

It’s still interesting though since the add-on shouldn’t be affected by a restart of Home Assistant. It would be affected by a reboot of the host though.

it is an automation, so this should work:

1 Like

yeh

It is a consistent issue, took me while to understand why my graphs on Dashboards were failing, I am using Node Red from my standalone zigbee2MQTT days so the Home Assistant automations, I have very few of them, were not having an impact.

I don’t always remember to restart zigbee2MQTT so a bit of a pain

Is this useful

from the zigbee2MQTT log

[16:39:08] INFO: Preparing to start…
[16:39:09] INFO: Socat not enabled
[16:39:09] INFO: Starting Zigbee2MQTT…

Sorry to be a pain - where do I find the add-on name for my installation?

Could be a misconfiguration

MQTT config :

and Zigbee2MQTT status

So Zigbee2MQTT knows HA has restarted.

1 Like

Settings → Add-ons → Zigbee2MQTT. Look in the URL

I found it in the url - I use the Mac App - would never in a million years found that! Thanks.

It doesn’t like something - sorry for being a noob.

Screenshot 2024-02-26 at 17.44.03

zigbee2MQTT config looks good without any changes - default install

Where MQTT config options above? I cannot find that config page

You could simple paste it in automations.yaml. Sorry, I don’t use the automation editor.

Ok… that will be a first for me :slight_smile:

Setting → Devices & Services → MQTT → Configure → Reconfigure MQTT , second page.

Thanks you ar taking me to dark corners of config I had not previously seen :slight_smile:
Looks Ok

I took everything default install

But it can…

And in case you want to import yanl:

description: “”
mode: single
trigger:
  - platform: homeassistant
    event: start
condition: []
action:
  - service:hassio.addon_restart
    metadata:
    data: 
      addon: 45df7312_zigbee2mqtt

2 Likes

You are barking up the wrong tree as z2m does not need to be restarted on HA restart.

1 Like

Ok

How do you get Home Assistant to not lose all the zigbee2MQTT devices after Home Assistant restarts?

At the moment every time Home Assistant restarts, short of a complete shutdown, restart, Home Assistant loses all zigbee2MQTT devices.

Everything is setup as default, so if any ideas on how to get Home Assistant to behave as you stated I would be greatly appreciated.

Perfect!,

Done and dusted, will keep on trying to work out how get Home Assistant to not lose zigbee2MQTT devices after a restart, but this will keep it going in the meantime.

Many thanks all!

Mike