NorthernMan54 / homebridge-alexa

Expose your homebridge controlled devices to Amazon Alexa.
https://www.homebridge.ca
446 stars 77 forks source link

ERROR: HB Instance not found... #432

Closed techman55 closed 3 years ago

techman55 commented 3 years ago

I've been having an issue for a while now where the Home app would work with Homebridge accessories but the Alexa wouldn't. It happened again today so I decided to look in the logs and found this error. Any help would be appreciated, thanks!

[13/03/2021, 20:45:34] [Alexa] PowerController TurnOn 0E:76:E0:86:4E:F0 undefined Error: ERROR: HB Instance not found at /usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:131:18 at _populateCache (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:193:5) at _mdnsLookup (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:126:5) at HAPNodeJSClient.HAPcontrolByDeviceID (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:222:3) at alexaHome.alexaPowerController (/usr/local/lib/node_modules/homebridge-alexa/lib/alexaActions.js:334:14) at EventEmitter.emit (events.js:315:20) at MqttClient.<anonymous> (/usr/local/lib/node_modules/homebridge-alexa/lib/alexaLocal.js:71:26) at MqttClient.emit (events.js:315:20) at MqttClient._handlePublish (/usr/local/lib/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:1277:12) at MqttClient._handlePacket (/usr/local/lib/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:410:12) at work (/usr/local/lib/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:321:12) at Writable.writable._write (/usr/local/lib/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:335: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 Socket.ondata (internal/streams/readable.js:719:22) at Socket.emit (events.js:315:20) at addChunk (internal/streams/readable.js:309:12) at readableAddChunk (internal/streams/readable.js:284:9) at Socket.Readable.push (internal/streams/readable.js:223:10) at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

NorthernMan54 commented 3 years ago

Ask Alexa to discover devices again. And check for not responding devices in the Alexa app and remove them

RamiroOliveira commented 3 years ago

I'm facing a similar issue, but it's not happening all the time. I've rediscovered the devices in the Alexa app 1-2 times but the error remained.

[3/17/2021, 3:48:27 PM] [Alexa] PowerController TurnOff 0E:1D:B1:D3:9C:38 undefined null [3/17/2021, 3:49:00 PM] [Alexa] PowerController TurnOn 0E:1D:B1:D3:9C:38 undefined Error: ERROR: HB Instance not found at /homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:131:18 at _populateCache (/homebridge/node_modules/homebridge-alexa/node_modules/hap-node-lient/HAPNodeJSClient.js:193:5) at _mdnsLookup (/homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:126:5) at HAPNodeJSClient.HAPcontrolByDeviceID (/homebridge/node_modules/homebridge-alexa/node_modules/hap-node-lient/HAPNodeJSClient.js:222:3) at alexaHome.alexaPowerController (/homebridge/node_modules/homebridge-alexa/lib/alexaActions.js:334:14) at EventEmitter.emit (events.js:315:20) at MqttClient. (/homebridge/node_modules/homebridge-alexa/lib/alexaLocal.js:71:26) at MqttClient.emit (events.js:315:20) at MqttClient._handlePublish (/homebridge/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:1277:12) at MqttClient._handlePacket (/homebridge/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:410:12) [3/17/2021, 3:49:07 PM] [Alexa] PowerController TurnOn 0E:1D:B1:D3:9C:38 undefined null [3/17/2021, 3:49:09 PM] [Alexa] PowerController TurnOff 0E:1D:B1:D3:9C:38 undefined null

As you can see the plugin works most of the time, but at some random time it fails. In the Alexa app the devices are shown as not responding most of the time, but if I try to change their status it works most of the time also.

I'm running:

Any idea?

NorthernMan54 commented 3 years ago

That error is triggered by this line

https://github.com/NorthernMan54/Hap-Node-Client/blob/8868edcf15206bc28c1a5d586f267620be4a3223/HAPNodeJSClient.js#L131

And is indicating that the device id '0E:1D:B1:D3:9C:38' could not be found. Is your setup stable ?

AlexKusnezov commented 3 years ago

@NorthernMan54 same error here with v0.5.32 and v0.5.34 on homerbridge 1.3.3

[3/18/2021, 7:19:52 PM] [Alexa] PowerController TurnOn 0E:22:A1:8E:3A:6D undefined Error: ERROR: HB Instance not found
    at /homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:131:18
    at _populateCache (/homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:193:5)
    at _mdnsLookup (/homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:126:5)
    at HAPNodeJSClient.HAPcontrolByDeviceID (/homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:222:3)
    at alexaHome.alexaPowerController (/homebridge/node_modules/homebridge-alexa/lib/alexaActions.js:334:14)
    at EventEmitter.emit (events.js:315:20)
    at MqttClient.<anonymous> (/homebridge/node_modules/homebridge-alexa/lib/alexaLocal.js:71:26)
    at MqttClient.emit (events.js:315:20)
    at MqttClient._handlePublish (/homebridge/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:1277:12)
    at MqttClient._handlePacket (/homebridge/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:410:12)
[3/18/2021, 7:19:59 PM] [Alexa] PowerController TurnOn 0E:22:A1:8E:3A:6D undefined null
[3/18/2021, 7:20:03 PM] [Alexa] PowerController TurnOff 0E:22:A1:8E:3A:6D undefined null

removing and rediscovering doesn't solve it either:

[3/18/2021, 7:33:37 PM] [Alexa] PowerController TurnOn 0E:22:A1:8E:3A:6D undefined Error: ERROR: HB Instance not found
    at /homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:131:18
    at _populateCache (/homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:193:5)
    at _mdnsLookup (/homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:126:5)
    at HAPNodeJSClient.HAPcontrolByDeviceID (/homebridge/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:222:3)
    at alexaHome.alexaPowerController (/homebridge/node_modules/homebridge-alexa/lib/alexaActions.js:334:14)
    at EventEmitter.emit (events.js:315:20)
    at MqttClient.<anonymous> (/homebridge/node_modules/homebridge-alexa/lib/alexaLocal.js:71:26)
    at MqttClient.emit (events.js:315:20)
    at MqttClient._handlePublish (/homebridge/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:1277:12)
    at MqttClient._handlePacket (/homebridge/node_modules/homebridge-alexa/node_modules/mqtt/lib/client.js:410:12)
[3/18/2021, 7:33:43 PM] [Alexa] PowerController TurnOn 0E:22:A1:8E:3A:6D undefined null
[3/18/2021, 7:33:46 PM] [Alexa] PowerController TurnOff 0E:22:A1:8E:3A:6D undefined null
[3/18/2021, 7:33:48 PM] [Alexa] PowerController TurnOn 0E:22:A1:8E:3A:6D undefined null

homebridge 1.2.5 with v0.5.32 ist working fine

edit: homebridge 1.2.5 with v0.5.34 ist also working fine, so the problem must be with homebridge 1.3.2 and up

it was fixed for the google plugin

ronluna commented 3 years ago

Facing the same issue on versino HB v.13.4 I have deleted all the device and re-discovered them maybe 5 times already. but all devices are shown as :

"payload": { "type": "ENDPOINT_UNREACHABLE", "message": "ERROR: HB Instance not found" }

Any ideas?

NorthernMan54 commented 3 years ago

Looking back at the posts here, I'm wondering if this is being triggered by the zero in the device id ?

0E:22:A1:8E:3A:6D 0E:1D:B1:D3:9C:38

@ronluna Do you also have a zero ?

ronluna commented 3 years ago

Looking deeper into it... I doubt the problem are the zero in the deviceID. I have a couple devices with ceros that are working correctly and to be more specific I currently having problems with a couple thermostats. from AC Freedom and Coolmasternet plugins. although the NEST thermostat works fine with your Alexa plugin.

I also have a couple dimmers that would show the "Device is not responsive" message for about 15 seconds and then i would go away... It's weird... Not sure where to look....

Here is an example:

2021-03-28T02:47:06.566Z alexaLocal Emitting Alexa
2021-03-28T02:47:06.566Z alexaActions alexaMessage: {"directive":{"header":{"namespace":"Alexa","name":"ReportState","payloadVersion":"3","messageId":"9a52648b-7d29-4c9e-bdee-3c2e6bdbed82","correlationToken":"XXXXXXXXX"},"endpoint":{"endpointId":"MEA6MTA6ODM6ODE6QzY6QTUtaG9tZWJyaWRnZS1Db29sIEF1dG9tYXRpb24tTDIuMTM3IEFDLTAwMDAwMEJDLTAwMDAtMTAwMC04MDAwLTAwMjZCQjc2NTI5MQ==","cookie":{"TurnOn":"{\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":10,\"value\":1}","AdjustPowerLevel":"{\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":16}","upperSetpoint":"{\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":14}","ReportState":"[{\"interface\":\"Alexa.PowerController\",\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":10},{\"interface\":\"Alexa.TemperatureSensor\",\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":13},{\"interface\":\"Alexa.ThermostatControllerupperSetpoint\",\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":14},{\"interface\":\"Alexa.ThermostatControllertargetSetpoint\",\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":14},{\"interface\":\"Alexa.ThermostatControllerlowerSetpoint\",\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":15},{\"interface\":\"Alexa.PowerLevelController\",\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":16}]","targetSetpoint":"{\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":14}","lowerSetpoint":"{\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":15}","SetPowerLevel":"{\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":16}","TurnOff":"{\"deviceID\":\"0E:10:83:81:C6:A5\",\"aid\":312,\"iid\":10,\"value\":0}"}},"payload":{}}}
2021-03-28T02:47:06.566Z alexaActions _HAPstatusByDeviceID-1 {
  body: '?id=312.10,312.13,312.14,312.14,312.15,312.16',
  interface: 'Alexa.PowerController,Alexa.TemperatureSensor,Alexa.ThermostatControllerupperSetpoint,Alexa.ThermostatControllertargetSetpoint,Alexa.ThermostatControllerlowerSetpoint,Alexa.PowerLevelController',
  deviceID: '0E:10:83:81:C6:A5',
  spacer: ',',
  elements: [
    { interface: 'Alexa.PowerController', aid: 312, iid: 10 },
    { interface: 'Alexa.TemperatureSensor', aid: 312, iid: 13 },
    {
      interface: 'Alexa.ThermostatControllerupperSetpoint',
      aid: 312,
      iid: 14
    },
    {
      interface: 'Alexa.ThermostatControllertargetSetpoint',
      aid: 312,
      iid: 14
    },
    {
      interface: 'Alexa.ThermostatControllerlowerSetpoint',
      aid: 312,
      iid: 15
    },
    { interface: 'Alexa.PowerLevelController', aid: 312, iid: 16 }
  ]
}

2021-03-28T02:47:10.643Z alexaActions alexaMessage: Response {
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "ErrorResponse",
      "messageId": "9a52648b-7d29-4c9e-bdee-3c2e6bdbed82",
      "correlationToken": "XXXXXXXXX",
      "payloadVersion": "3"
    },
    "endpoint": {
      "endpointId": "MEA6MTA6ODM6ODE6QzY6QTUtaG9tZWJyaWRnZS1Db29sIEF1dG9tYXRpb24tTDIuMTM3IEFDLTAwMDAwMEJDLTAwMDAtMTAwMC04MDAwLTAwMjZCQjc2NTI5MQ=="
    },
    "payload": {
      "type": "ENDPOINT_UNREACHABLE",
      "message": "Homebridge status failed"
    }
  }
}
NorthernMan54 commented 3 years ago

Another thought is that this device id cache population is timing out too early in your setup

https://github.com/NorthernMan54/Hap-Node-Client/blob/919f288af0ffb7910c2a65168af0dc67e2f92ffd/HAPNodeJSClient.js#L126

The code is assuming that the bonjour / mdns responds within 4 seconds

You could try increasing the value

ronluna commented 3 years ago

Another thought is that this device id cache population is timing out too early in your setup

https://github.com/NorthernMan54/Hap-Node-Client/blob/919f288af0ffb7910c2a65168af0dc67e2f92ffd/HAPNodeJSClient.js#L126

The code is assuming that the bonjour / mdns responds within 4 seconds

You could try increasing the value

I've increased from 4 seconds to 10 seconds, restarted the engine but same result.

ronluna commented 3 years ago

The more I play with it the more devices that fails . I've had the plugin installed for a couple of months now but it is now that I truly started to play with it, although in my setup the alexa plugin is unreliable as it frequently show the following message on the logs for any type of device:

"payload": {
  "type": "ENDPOINT_UNREACHABLE",
  "message": "ERROR: HB Instance not found"
}

any other ideas. I could try?

NorthernMan54 commented 3 years ago

If you start homebridge with this DEBUG option

DEBUG=hap* homebridge

It will log from this line here during the error

https://github.com/NorthernMan54/Hap-Node-Client/blob/919f288af0ffb7910c2a65168af0dc67e2f92ffd/HAPNodeJSClient.js#L654

Which might give more of a clue

RyTsYdUp commented 3 years ago

I was consistently seeing this error until I rolled back to homebridge-alexa@0.4.74. Now my Z-Wave devices work great but the Zigbee devices still fail with the error

"payload": { "type": "ENDPOINT_UNREACHABLE", "message": "ERROR: HB Instance not found" }

I think the issue is the way the Alexa Homebridge plugin is sending responses back to Amazon. The responses for Z-Wave appear to be different from Zigbee's.

RamiroOliveira commented 3 years ago

I've enabled debug and I can confirm that in version v0.5.34 it fails with error:

"payload": { "type": "ENDPOINT_UNREACHABLE", "message": "ERROR: HB Instance not found" }

NorthernMan54 commented 3 years ago

This has been resolved as part of #446

RamiroOliveira commented 3 years ago

On my side it's solved.

AlexKusnezov commented 3 years ago

@NorthernMan54 Thank you so much, It works with the newest docker image (v1.3.4)! Now, I can finally update all the other plugins :)

NorthernMan54 commented 3 years ago

Tks for confirming