Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After restoring a homebridge instance from a backup created in homebridge-config-ui-x failure to connect to hub #562

Open
pkmnct opened this issue Jan 4, 2023 · 4 comments

Comments

@pkmnct
Copy link

pkmnct commented Jan 4, 2023

Hello!

I recently had a hardware failure of the main homebridge instance in my smart home, which required me to restore this instance from a backup taken via homebridge-config-ui-x. Since restoring, I seem to be getting intermittent connectivity issues with the Alexa skill and any separate homebridge instances in my smart home.

I can see the request come into the main homebridge instance, where it shows in the logs as follows:

[1/4/2023, 12:47:44 AM] [Alexa] PowerController TurnOn CC:22:3D:E3:CE:30 undefined Error: ERROR: HB Instance not found
    at /usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:135:18
    at _populateCache (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:201:5)
    at _mdnsLookup (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:129:5)
    at HAPNodeJSClient.HAPcontrolByDeviceID (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:269:3)
    at alexaHome.alexaPowerController (/usr/local/lib/node_modules/homebridge-alexa/lib/alexaActions.js:339:14)
    at EventEmitter.emit (node:events:513:28)
    at MqttClient.<anonymous> (/usr/local/lib/node_modules/homebridge-alexa/lib/alexaLocal.js:74:28)
    at MqttClient.emit (node:events:513:28)
    at MqttClient._handlePublish (/usr/local/lib/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:1547:12)
    at MqttClient._handlePacket (/usr/local/lib/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:535:12)
    at work (/usr/local/lib/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:438:12)
    at Writable.writable._write (/usr/local/lib/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:452:5)
    at doWrite (/usr/local/lib/node_modules/homebridge-alexa/node_modules/readable-stream/lib/_stream_writable.js:409:139)
    at writeOrBuffer (/usr/local/lib/node_modules/homebridge-alexa/node_modules/readable-stream/lib/_stream_writable.js:398:5)
    at Writable.write (/usr/local/lib/node_modules/homebridge-alexa/node_modules/readable-stream/lib/_stream_writable.js:307:11)
    at TLSSocket.ondata (node:internal/streams/readable:766:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at TLSSocket.Readable.push (node:internal/streams/readable:234:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)

I've noticed a few other issues opened with the ERROR: HB Instance not found that suggest re-running "discover devices," and while this discovery request shows up in the logs as well, the issue still remains with controlling devices on separate instances. I've attempted to restart the main and other instances several times and remove/reconfigure the alexa-homebridge integration, but the issue remains.

@NorthernMan54
Copy link
Owner

The error ERROR: HB Instance not found is saying that it can't find a homebridge instance with the identifier CC:22:3D:E3:CE:30. Within the home skill on the Amazon Alexa side it caches details of the homebridge accessory, and that is where this is coming from.

I'm thinking that you may have a bunch of duplicate devices on the Amazon side as a result of the restore. Have you looked in the app to see what devices you have ? And one of the duplicates has an incorrect / old homebridge instance associated with it. To resolve, you would need to delete it, then ask Alexa to discover devices again.

@pkmnct
Copy link
Author

pkmnct commented Jan 4, 2023

Hey there! So the homebridge instance with the identifier CC:22:3D:E3:CE:30 still exists on my network and works fine through the Home app on iOS, just not through homebridge-alexa. The only homebridge instance that was restored was my main instance that hosts homebridge-alexa and some other plugins (identifier 0E:72:B1:CD:46:DC).

After restoring initially, I was facing the same connectivity issue as reported above, but after restarting and tweaking instances (I wish I recall my exact steps) I had it working for a couple of days. When I applied the latest homebridge-alexa update yesterday, it seems to have reverted to the same error (sent in the previous post), and I have not been successful in getting it working again since.

It seems that the issue comes down to communication from the main homebridge instance to other instances. Can you clarify what steps/protocols/etc the homebridge-alexa integration uses to try to discover/connect to the other instances, and what could potentially interrupt the ability for the main instance to "find" or "see" the other instances? I did have to re-setup the OS for the main instance's hardware that failed, so perhaps there's something in the OS itself that has changed and is blocking the communication (I've disabled the firewall for debugging).

I do not have any duplicate devices showing up in the Alexa app, and all of my routines/voice control and things work for the main homebridge instance, just not any other homebridge instance in the household. I really despise needing to re-setup all the devices in Alexa again (what's the point of having a backup at that stage?). Is there a way to tell the instance hosting the homebridge-alexa integration to clear its cache or anything for the other homebridge instances?

@NorthernMan54
Copy link
Owner

When the plugin restarts it resets the local cache which maps the instance to the physical address, and then refreshes this every 15 minutes.

For connectivity from the plugin to the Homebridge instances it uses the same protocol and transport as the home app. ie mDNS for discovery and the homebridge port for communications

Can you enable the debug flag and restart the plugin ?

During the first minute of startup it discovers all your instances, and the debug log includes the gory detail. If you can share the log it should show the discovery of CC:22:3D:E3:CE:30 and any issues

PS Are you on 0.6.2, there was an issue with ipv6 and 0.6.1

@Budgie66
Copy link

Budgie66 commented Feb 8, 2024

after my restoration I had the same issue , luckily for me I managed to get it back by disabling the Alexa skill then deleting the plugin on homebridge and also removing all the devises that wasn't responding for the Alexa app rescanned and it was all back , hoe you manage to sort yours out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants