itavero / homebridge-z2m

Expose your Zigbee devices to HomeKit with ease, by integrating 🐝 Zigbee2MQTT with 🏠 Homebridge.
https://z2m.dev
Apache License 2.0
308 stars 49 forks source link

[Bug] Running the Mac OS - Homebridge Zigbee2MQTT - doesn't really start up when the Mac OS boots up. #844

Open DarkGrey88 opened 5 months ago

DarkGrey88 commented 5 months ago

Is there an existing issue for this?

Describe the bug

I have installed Homebridge on a Mac OS Monterey. I have Mosquitto and Zigbee2MQTT configured. Mosquitto and Zigbee2MQTT - works at system startup which is visible thanks to MQTT Explorer. I installed the plugin - z2m and prescribed the mqtt address. The plugin rebooted after changing the settings and everything worked! Hooray? No. After the reboot it turned out that it didn't work properly. The Homebridge log says it's fine. [3/14/2024, 7:33:24 PM] [homebridge-z2m] Connected to MQTT server [3/14/2024, 7:33:29 PM] [homebridge-z2m] Zigbee2MQTT is ONLINE [3/14/2024, 7:33:30 PM] [homebridge-z2m] Using Zigbee2MQTT v1.36.0 (identified via zigbee2mqtt/bridge/info) but the accessories section was empty. I restarted the child bridge z2m and everything worked again. [3/14/2024, 7:35:16 PM] [homebridge-z2m] Process Ended. Code: 143, Signal: null [3/14/2024, 7:35:23 PM] [homebridge-z2m] Restarting Process... [3/14/2024, 7:35:24 PM] [homebridge-z2m] Launched child bridge with PID 1094 [3/14/2024, 7:35:24 PM] Registering platform 'homebridge-z2m.zigbee2mqtt' [3/14/2024, 7:35:24 PM] [homebridge-z2m] Loaded homebridge-z2m v1.11.0-beta.3 child bridge successfully [3/14/2024, 7:35:24 PM] Loaded 1 cached accessories from cachedAccessories.0EBEC2A64B1B. [3/14/2024, 7:35:24 PM] [homebridge-z2m] Connecting to MQTT server at mqtt://10.0.1.28:1883 [3/14/2024, 7:35:24 PM] [homebridge-z2m] Restoring accessory: test_sw (0xa4c138f3271bad89) [3/14/2024, 7:35:24 PM] Homebridge v1.7.0 (HAP v0.11.1) (homebridge-z2m) is running on port 59590. [3/14/2024, 7:35:24 PM] [homebridge-z2m] Connected to MQTT server [3/14/2024, 7:35:24 PM] [homebridge-z2m] Zigbee2MQTT is ONLINE [3/14/2024, 7:35:24 PM] [homebridge-z2m] Using Zigbee2MQTT v1.36.0 (identified via zigbee2mqtt/bridge/info)

And so it is every time. To make everything work, after each system reboot you need to reboot z2m.

Related devices

No response

Related Devices

No response

Steps To Reproduce

No response

Expected behavior

z2m works correctly at system startup - automatically

Device entry

No response

Status update

No response

Messages from this plugin

No response

This plugin

1.93

Homebridge

1.7

Zigbee2MQTT

1.36

Homebridge Config UI X (if applicable)

No response

itavero commented 5 months ago

I think this is an issue with your setup. Is Homebridge started after both your MQTT broker and Zigbee2MQTT are online or not? Does your MQTT broker support persistent messages and is Zigbee2MQTT using them?

DarkGrey88 commented 5 months ago

I'm not sure. how do I check it? What is the correct order and how to set it? Could you please advise?

I think this is an issue with your setup. Is Homebridge started after both your MQTT broker and Zigbee2MQTT are online or not?

itavero commented 5 months ago

That really depends on how you've setup your system.

Personally I'm using a Docker compose file, in which you can explicitly set the dependencies between containers.

I would think however that the order itself shouldn't be a problem of the (important) messages from Zigbee2MQTT are persistent on the broker.

mrmaximas commented 5 months ago

I'm not sure. how do I check it? What is the correct order and how to set it? Could you please advise?

I think this is an issue with your setup. Is Homebridge started after both your MQTT broker and Zigbee2MQTT are online or not?

Can you provide the plugin configuration? I use this plugin with catalina on intel mac mini 2012 for two years approx, then last month on mac mini m2 with sonoma without the same problem

DarkGrey88 commented 5 months ago

I'm not sure. how do I check it? What is the correct order and how to set it? Could you please advise?

I think this is an issue with your setup. Is Homebridge started after both your MQTT broker and Zigbee2MQTT are online or not?

Can you provide the plugin configuration? I use this plugin with catalina on intel mac mini 2012 for two years approx, then last month on mac mini m2 with sonoma without the same problem

Do you mean JSON in Homebridge?

{ "mqtt": { "base_topic": "zigbee2mqtt", "server": "mqtt://10.0.1.28:1883", "reject_unauthorized": false, "keepalive": 60, "version": 4, "disable_qos": false }, "defaults": { "exclude": false }, "exclude_grouped_devices": false, "platform": "zigbee2mqtt", "_bridge": { "username": "0E:72:96:DB:C4:11", "port": 33132 } }

or configuration.yaml

permit_join: true mqtt: base_topic: zigbee2mqtt server: mqtt://10.0.1.28:1883 serial: port: /dev/tty.usbserial-0001 advanced: homeassistant_legacy_entity_attributes: false legacy_api: false legacy_availability_payload: false device_options: legacy: false devices: '0xa4c138f3271bad89': friendly_name: '0xa4c138f3271bad89' '0xa4c138832fe9427a': friendly_name: '0xa4c138832fe9427a' '0xa4c13892197b3125': friendly_name: '0xa4c13892197b3125' '0xa4c1381b4edceb12': friendly_name: '0xa4c1381b4edceb12' '0xa4c1385fc16bb6b6': friendly_name: '0xa4c1385fc16bb6b6' '0xa4c13899e56ce666': friendly_name: '0xa4c13899e56ce666' cache_state: false frontend: true

mrmaximas commented 5 months ago

@DarkGrey88 It's weird, visually it's the same as my config but try to cache_state: true

DarkGrey88 commented 5 months ago

I'm not sure. how do I check it? What is the correct order and how to set it? Could you please advise?

I think this is an issue with your setup. Is Homebridge started after both your MQTT broker and Zigbee2MQTT are online or not?

Can you provide the plugin configuration? I use this plugin with catalina on intel mac mini 2012 for two years approx, then last month on mac mini m2 with sonoma without the same problem

Yesterday I started from scratch. And it seems to me that as long as I just added zigbee devices and rebooted my mac at the same time, everything worked fine. The problem appeared after I enabled child bridge for the z2m plugin. And then after rebooting my mac the devices did not appear again until I rebooted the child bridge z2m plugin.

DarkGrey88 commented 5 months ago

@DarkGrey88 It's weird, visually it's the same as my config but try to cache_state: true

it works the same even without that line(

stale[bot] commented 4 months ago

It appears that this issue did not have an update in quite some time. Please check if you can provide any additional information to help resolve this issue. If there isn't any activity in the next two weeks, this issue will be closed automatically. Thank you for your contributions!

LaurentCole commented 3 months ago

Hi everyone, I think I'm in the right place to ask my question. I have Homebridge running on Mac OS Sonoma. Trying to make my Sonoff Zigbee 3.0 usb dongle plus work I installed Aedes embedded MQTT Broker & Homebridge Zigbee2MQTT My broker is properly configured because I have a few mqtt switches which work fine Just put the broker info into Zigbee2MQTT Can't make it work Am I missing a step ? I can read there's a yaml file, where? Any precious help would be much appreciated. A very detail procedure would be awesome ! Thx

Capture d’écran 2024-05-21 à 15 28 38 Capture d’écran 2024-05-21 à 15 31 13
mrmaximas commented 3 months ago

Hi everyone, I think I'm in the right place to ask my question. I have Homebridge running on Mac OS Sonoma. Trying to make my Sonoff Zigbee 3.0 usb dongle plus work I installed Aedes embedded MQTT Broker & Homebridge Zigbee2MQTT My broker is properly configured because I have a few mqtt switches which work fine Just put the broker info into Zigbee2MQTT Can't make it work Am I missing a step ? I can read there's a yaml file, where? Any precious help would be much appreciated. A very detail procedure would be awesome !

Does your mqtt broker use authorisation?

itavero commented 3 months ago

@LaurentCole Do you also have Zigbee2MQTT running (e.g. can you access its frontend to see that the dongle works)?

LaurentCole commented 3 months ago

Hi everyone, I think I'm in the right place to ask my question. I have Homebridge running on Mac OS Sonoma. Trying to make my Sonoff Zigbee 3.0 usb dongle plus work I installed Aedes embedded MQTT Broker & Homebridge Zigbee2MQTT My broker is properly configured because I have a few mqtt switches which work fine Just put the broker info into Zigbee2MQTT Can't make it work Am I missing a step ? I can read there's a yaml file, where? Any precious help would be much appreciated. A very detail procedure would be awesome !

Does your mqtt broker use authorisation?

I have a username and a password

LaurentCole commented 3 months ago

@LaurentCole Do you also have Zigbee2MQTT running (e.g. can you access its frontend to see that the dongle works)?

no I can't access the frontend. How to ?

mrmaximas commented 3 months ago

I have a username and a password

the text configuration of the plugin does not show this

mrmaximas commented 3 months ago

@LaurentCole Do you also have Zigbee2MQTT running (e.g. can you access its frontend to see that the dongle works)?

no I can't access the frontend. How to ?

you need to install zigbee2mqtt first https://www.zigbee2mqtt.io for Sonoff Zigbee 3.0 usb dongle plus I would recommend that you flash test fw [20240315] file name CC1352P2_CC2652P_launchpad_coordinator_20240315.hex from https://github.com/Koenkk/Z-Stack-firmware/discussions/496

itavero commented 3 months ago

@LaurentCole Do you also have Zigbee2MQTT running (e.g. can you access its frontend to see that the dongle works)?

no I can't access the frontend. How to ?

There's a rough outline of the steps needed to set this up on the plug-in website: https://z2m.dev/install.html

More information about the Zigbee2MQTT frontend, can be found on the Zigbee2MQTT website: https://www.zigbee2mqtt.io/guide/configuration/frontend.html

LaurentCole commented 3 months ago

@LaurentCole Do you also have Zigbee2MQTT running (e.g. can you access its frontend to see that the dongle works)?

no I can't access the frontend. How to ?

you need to install zigbee2mqtt first https://www.zigbee2mqtt.io for Sonoff Zigbee 3.0 usb dongle plus I would recommend that you flash test fw [20240315] file name CC1352P2_CC2652P_launchpad_coordinator_20240315.hex from Koenkk/Z-Stack-firmware#496

my dongle is already uptodate will try try to install zigbee2mqtt do I choose the python method ?

mrmaximas commented 3 months ago

@LaurentCole Do you also have Zigbee2MQTT running (e.g. can you access its frontend to see that the dongle works)?

no I can't access the frontend. How to ?

you need to install zigbee2mqtt first https://www.zigbee2mqtt.io for Sonoff Zigbee 3.0 usb dongle plus I would recommend that you flash test fw [20240315] file name CC1352P2_CC2652P_launchpad_coordinator_20240315.hex from Koenkk/Z-Stack-firmware#496

my dongle is already uptodate will try try to install zigbee2mqtt do I choose the python method ?

FYI factory fw is not good two year ago i'm using this installation method https://kinori.tech/blog/en/2021/11/19/install-and-run-zigbee2mqtt-on-your-mac/

LaurentCole commented 3 months ago

@LaurentCole Do you also have Zigbee2MQTT running (e.g. can you access its frontend to see that the dongle works)?

no I can't access the frontend. How to ?

you need to install zigbee2mqtt first https://www.zigbee2mqtt.io for Sonoff Zigbee 3.0 usb dongle plus I would recommend that you flash test fw [20240315] file name CC1352P2_CC2652P_launchpad_coordinator_20240315.hex from Koenkk/Z-Stack-firmware#496

my dongle is already uptodate will try try to install zigbee2mqtt do I choose the python method ?

FYI factory fw is not good two year ago i'm using this installation method https://kinori.tech/blog/en/2021/11/19/install-and-run-zigbee2mqtt-on-your-mac/

So I finally manage to install zigbee2mqtt, thx to you for the link I then install Homebridge Zigbee2MQTT into Homebridge (do I really need it)

Then launched zigbee2mqtt via terminal

zigbee2mqtt@1.37.1 start node index.js

[2024-05-21 17:54:06] info: z2m: Logging to console, file (filename: log.log) [2024-05-21 17:54:06] info: z2m: Starting Zigbee2MQTT version 1.37.1 (commit #cda867a) [2024-05-21 17:54:06] info: z2m: Starting zigbee-herdsman (0.46.6) [2024-05-21 17:54:06] info: zh:zstack:znp: Opening SerialPort with {"path":"/dev/tty.usbserial-1460","baudRate":115200,"rtscts":false,"autoOpen":false} [2024-05-21 17:54:06] info: zh:zstack:znp: Serialport opened [2024-05-21 17:54:07] info: z2m: zigbee-herdsman started (resumed) [2024-05-21 17:54:07] info: z2m: Coordinator firmware version: '{"meta":{"maintrel":1,"majorrel":2,"minorrel":7,"product":1,"revision":20230507,"transportrev":2},"type":"zStack3x0"}' [2024-05-21 17:54:07] info: z2m: Currently 0 devices are joined: [2024-05-21 17:54:07] warning: z2m: permit_join set to true in configuration.yaml. [2024-05-21 17:54:07] warning: z2m: Allowing new devices to join. [2024-05-21 17:54:07] warning: z2m: Set permit_join to false once you joined all devices. [2024-05-21 17:54:07] info: z2m: Zigbee: allowing new devices to join. [2024-05-21 17:54:07] info: z2m: Connecting to MQTT server at mqtt://192.168.1.43:1883 [2024-05-21 17:54:07] info: z2m: Connected to MQTT server [2024-05-21 17:54:07] info: z2m: Started frontend on port 8080 [2024-05-21 17:54:07] info: z2m: Zigbee2MQTT started!

I can access the frontend but I can't add devices Thought my coordinator was up to date but apparently not, do I really need to. thx

Finally succeeded to add a device.

Do you have a link to easily update the coordinator on a mac.

Thx again for all your helps

LaurentCole commented 3 months ago

Hi guys, thx for your help, everything works fine now. Still I have an issue with the plist file. I copied & paste the plist lines Saved the file as 'zigbe2mqtt.application.plist' Put it in the Launch Deamons folder

But zigbee2mqtt doesn''t start when I restart the mac

Do I need to modify this line : ![CDATA[/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin]]>

:-)

mrmaximas commented 3 months ago

Hi guys, thx for your help, everything works fine now. Still I have an issue with the plist file. I copied & paste the plist lines Saved the file as 'zigbe2mqtt.application.plist' Put it in the Launch Deamons folder

But zigbee2mqtt doesn''t start when I restart the mac

Do I need to modify this line : ![CDATA[/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin]]>

:-)

my plist located in /Library/LaunchDaemons/zigbee2mqtt.plist is: Screenshot 2024-05-22 at 17 38 42

where /Users/m/ is the z2m installation dir also check the permissions of the plist: owned with r/w by system read-only group wheel

to stop manually (change daemon name to you own) : sudo launchctl bootout system/zigbee2mqtt

to update z2m (change path to z2m dir you own): sudo /Users/m/zigbee2mqtt/update.sh

to run manually (change plist file name to you own): sudo launchctl bootstrap system /Library/LaunchDaemons/zigbee2mqtt.plist

LaurentCole commented 3 months ago

Hi guys, thx for your help, everything works fine now. Still I have an issue with the plist file. I copied & paste the plist lines Saved the file as 'zigbe2mqtt.application.plist' Put it in the Launch Deamons folder But zigbee2mqtt doesn''t start when I restart the mac Do I need to modify this line : ![CDATA[/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin]]> :-)

my plist located in /Library/LaunchDaemons/zigbee2mqtt.plist is: Screenshot 2024-05-22 at 17 38 42

where /Users/m/ is the z2m installation dir also check the permissions of the plist: owned with r/w by system read-only group wheel

to stop manually (change daemon name to you own) : sudo launchctl bootout system/zigbee2mqtt

to update z2m (change path to z2m dir you own): sudo /Users/m/zigbee2mqtt/update.sh

to run manually (change plist file name to you own): sudo launchctl bootstrap system /Library/LaunchDaemons/zigbee2mqtt.plist

thx will try that & tell you the result

mrmaximas commented 3 months ago

will try that & tell you the result

I'm using Sonoma on M2 Mac Mini, our work dirs and file names may be different.

LaurentCole commented 3 months ago

Hi guys, thx for your help, everything works fine now. Still I have an issue with the plist file. I copied & paste the plist lines Saved the file as 'zigbe2mqtt.application.plist' Put it in the Launch Deamons folder But zigbee2mqtt doesn''t start when I restart the mac Do I need to modify this line : ![CDATA[/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin]]> :-)

my plist located in /Library/LaunchDaemons/zigbee2mqtt.plist is: Screenshot 2024-05-22 at 17 38 42 where /Users/m/ is the z2m installation dir also check the permissions of the plist: owned with r/w by system read-only group wheel to stop manually (change daemon name to you own) : sudo launchctl bootout system/zigbee2mqtt to update z2m (change path to z2m dir you own): sudo /Users/m/zigbee2mqtt/update.sh to run manually (change plist file name to you own): sudo launchctl bootstrap system /Library/LaunchDaemons/zigbee2mqtt.plist

thx will try that & tell you the result

How do I set these persons via terminal ?

LaurentCole commented 3 months ago

will try that & tell you the result

I'm using Sonoma on M2 Mac Mini, our work dirs and file names may be different.

I need to write this in terminal to make it work manually :

plex@mac-mini-de-plex ~ % cd /Applications/zigbee2mqtt plex@mac-mini-de-plex zigbee2mqtt % npm start

Then my plist file is like that but cannot make it work.

Capture d’écran 2024-05-22 à 22 31 02
LaurentCole commented 3 months ago

will try that & tell you the result

I'm using Sonoma on M2 Mac Mini, our work dirs and file names may be different.

Hi, thx for the help but still cannot make my plist file working at boot. I have correct permissions on the plist file

Do you have any idea what is wrong, could you help me a bit more? :-)

DarkGrey88 commented 3 months ago

will try that & tell you the result

I'm using Sonoma on M2 Mac Mini, our work dirs and file names may be different.

Hi, thx for the help but still cannot make my plist file working at boot. I have correct permissions on the plist file

Do you have any idea what is wrong, could you help me a bit more? :-)

I used another program. I have installed Windscribe(VPN). When it was installed, it created and placed its plist in the autoloader. Then I disabled autorun in the program settings and replaced the contents of the plist file with what I needed.

LaurentCole commented 3 months ago

Hi I have this error when sudo launchctl bootstrap system /Library/LaunchDaemons/zigbee2mqtt.plist

Bootstrap failed: 5: Input/output error

LaurentCole commented 3 months ago

Hi guys,

I finally succeeded making my .plist file working with the help of LaunchControl App.

Here is my .plist file :

Capture d’écran 2024-05-30 à 12 21 03

Thx for the help!