hobbyquaker / homekit2mqtt

HomeKit to MQTT bridge 🏡📱
MIT License
349 stars 71 forks source link

No HAP connection after kill and restart? #136

Closed abrownsword closed 3 years ago

abrownsword commented 5 years ago

My homekit2mqtt and accessory were working well, and I was experimenting with all sorts of commands via Siri and the Home.app. Then I killed homekit2mqtt using kill -SIGHUP for the first time (usually I had been using kill -9). Now when I restart all the mqtt communication seems to work perfectly (I can see the message traffic in my logs and via an MQTT viewer client), all the debug output from homekit2mqtt looks fine... but HomeKit says “no response” from my accessories. The command line options haven’t changed, the storage dir hasn’t changed and its content is untouched. I’ve tried restarting the Home.app, the AppleTV hub and so forth. The only thing I haven’t yet restarted is my Linux host running homekit2mqtt and my accessory.

hobbyquaker commented 5 years ago

Hmmm... That should not happen. I would suggest to delete everything in the Home App, start homekit2mqtt again - but with a new --username and see if the issue occurs again.

abrownsword commented 5 years ago

I’ve done that. 3-4 times now because it seems to keep happening even though my json config files shouldn’t have changed, and certainly the names of the accessories, rooms and services haven’t. I’ve had a couple of recent restarts where this problem has not occurred. I haven’t figured out what the correlation is, but one change is which signal I’m using to kill homekit2mqtt — I’ve changed from SIGHUP to SIGTERM. Don’t know if this was the actual source of the problem. I’m not keen to recreate my HomeKit config yet again at the moment.

On Oct 9, 2018, at 11:04 AM, Sebastian Raff notifications@github.com wrote:

Hmmm... That should not happen. I would suggest to delete everything in the Home App, start homekit2mqtt again - but with a new --username and see if the issue occurs again.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

abrownsword commented 5 years ago

The problem just recurred again, and this time I’m more certain about what changed and what didn’t.

I need to describe what I’m doing. I have a C++ application that is my home automation system, running on a Linux host. This application has an internal representation of the house which is uses to build the JSON file for homekit2mqtt, which it then launches as a child process. The JSON file is re-written every time the program executes, but it is identical from run to run unless the base configuration is changed. The system works and lets me create a HomeKit ‘home’ with all my accessories (about 20 rooms, 60 light fixtures, 30 or so sensors).

The problem I’ve been having is that if I re-start my service, when homekit2mqtt is back up and running it doesn’t communicate with HomeKit anymore. Home.app just reports “No Response”. If I delete the house in HomeKit and re-create from scratch, then it all works again (interestingly I do have to delete the original otherwise the accessory doesn’t show up at all).

So why is this happening?

hobbyquaker commented 5 years ago

Perhaps a problem with the persistence files (--storagedir) where HAP-Nodejs stores the information about paired devices etc?

abrownsword commented 5 years ago

Yes, I thought of that, but I’ve checked the command line generated each time to launch homekit2mqtt, and it is correct and stable. The two files cached in that directory also remain there.

s3po-ger commented 5 years ago

Hi there, I think I might have run into a similar problem. I start homekit2mqtt as service using systemd on a ubuntu server. I use the included example configuration. I've added the bridge as from a completly empty configuration in the home app. then I just shutdown the server and restart it. After that all the accessories/devices are not responding anymore. After deleting the bridge and all the depending devices in the home app, the bridge cannot be found anymore. When I start homekit2mqtt I provide the storagedir argument but there is no file in the provided directory path. I don't know if there should be any files or if this is suspicous anyhow.

Thanks in advance. I really appreciate your work

s3po-ger commented 5 years ago

oh wow. I really ran into this problem several times before. I just connected the server via a ethernet connection to my network instead of wifi. When i reboot now the issue seems to be gone. I never could get the bridge to reconnect automatically before that. Sorry for the confusion

abrownsword commented 5 years ago

I am always connected via ethernet cable and switches.

SandroK commented 1 year ago

You ever figured this out?

abrownsword commented 1 year ago

I did not, and transitioned to an actively supported solution fairly soon thereafter (https://github.com/arachnetech/homebridge-mqttthing).

SandroK commented 1 year ago

Thanks, will check that out!