cflurin / homebridge-mqtt

Homebridge-mqtt is a Plugin for Homebridge.
Apache License 2.0
229 stars 39 forks source link

error on adding new accessories #109

Open alexchornyi opened 3 years ago

alexchornyi commented 3 years ago

I will try to add new accessories

homebridge/to/add { "name": "Smart AC", "service_name": "smart_ac", "service": "HeaterCooler", "CoolingThresholdTemperature": {"maxValue":30, "minValue": 17, "minStep": 1}, "HeatingThresholdTemperature": {"maxValue":30, "minValue": 17, "minStep": 1} }

on home bridge I get list of errors and Homebridge totally rebooted

TypeError: Cannot read property 'on' of undefined at Accessory.allocate (/usr/local/lib/node_modules/homebridge-mqtt/lib/accessory.js:199:6) at Accessory.configureCharacteristics (/usr/local/lib/node_modules/homebridge-mqtt/lib/accessory.js:154:12) at Accessory.configureAccessory (/usr/local/lib/node_modules/homebridge-mqtt/lib/accessory.js:95:10) at Controller.addAccessory (/usr/local/lib/node_modules/homebridge-mqtt/lib/controller.js:107:17) at Model. (/usr/local/lib/node_modules/homebridge-mqtt/lib/model.js:153:22) at MqttClient.emit (events.js:375:28) at MqttClient._handlePublish (/usr/local/lib/node_modules/homebridge-mqtt/node_modules/mqtt/lib/client.js:1277:12) at MqttClient._handlePacket (/usr/local/lib/node_modules/homebridge-mqtt/node_modules/mqtt/lib/client.js:410:12) at work (/usr/local/lib/node_modules/homebridge-mqtt/node_modules/mqtt/lib/client.js:321:12) at Writable.writable._write (/usr/local/lib/node_modules/homebridge-mqtt/node_modules/mqtt/lib/client.js:335:5) at doWrite (/usr/local/lib/node_modules/homebridge-mqtt/node_modules/readable-stream/lib/_stream_writable.js:409:139) at writeOrBuffer (/usr/local/lib/node_modules/homebridge-mqtt/node_modules/readable-stream/lib/_stream_writable.js:398:5) at Writable.write (/usr/local/lib/node_modules/homebridge-mqtt/node_modules/readable-stream/lib/_stream_writable.js:307:11) at Socket.ondata (internal/streams/readable.js:726:22) at Socket.emit (events.js:375:28) at addChunk (internal/streams/readable.js:290:12) [20/06/2021, 11:20:15] Got SIGTERM, shutting down Homebridge...

alexchornyi commented 3 years ago

Why you closed without any solution?

cflurin commented 3 years ago

Hi,

I've uploaded a fix in accessory.js. Please download accessory.js from GitHub and try again.

alexchornyi commented 3 years ago

thnx

jjknudsen commented 3 years ago

I updated accessory.js with the latest version you committed a few days ago and am getting the same issues. Right after adding the accessory I see this:

6/24/2021, 9:02:41 AMMqtt BridgemqttWARNINGon.offline <to analyze>
6/24/2021, 9:02:41 AMMqtt BridgemqttWARNINGon.close <to analyze>
6/24/2021, 9:02:42 AMMqtt BridgemqttWARNINGon.reconnect <to analyze>
6/24/2021, 9:02:42 AMMqtt Bridgemqttconnected (url = mqtt://127.0.0.1)
6/24/2021, 9:02:47 AMMqtt BridgemqttaddAccessory true, accessory 'office_occupancy', service_name 'Office Occupancy' is added. [0]
cflurin commented 3 years ago

I updated accessory.js with the latest version you committed a few days ago and am getting the same issues.

This isn't the same issue! Please read the doc and correctly configure your mqtt-broker.

cflurin commented 3 years ago

@alexchornyi

Does the new accessory.js work for you?

jjknudsen commented 3 years ago

I am using node-red-contrib-aedes for my broker. It's a fairly straightforward configuration. Everything seems to work just fine on another Raspberry Pi with the only difference between the two being that one is running Homebride 1.3.3 and the other is running 1.3.4.

cflurin commented 3 years ago

I'm using mosquitto for years without any issues.

jjknudsen commented 3 years ago

I updated the plugin to 1.0.1 which includes your updates to accessory.js. I've switched to Mosquitto for my broker. Not sure what else i should look into but still getting the exact same message as the original poster.

7/1/2021, 10:17:01 AMMqtt BridgeWARNINGunhandled rejection: TypeError: Cannot read property 'on' of undefined
cflurin commented 3 years ago

Please post more infos:

topic: homebridge/to/add

payload: ?

Post the full error log: from start to the error.

jjknudsen commented 3 years ago

OK. I'm sorry for all the fuss. I'm not sure if the original poster is using Hoobs as well, but I'm running the Hoobs 4 beta where I'm having these issues.

I installed a new instance of homebridge on another machine, and using this plugin with the same MQTT broker and had no issues whatsoever. So I'm going to have to put the Hoobs 4 beta at fault I think. I'll open an issue there and see what happens. I'll also continue to debug and will post here if I find anything useful for you.

Thanks for your help and responsiveness on this.

jjknudsen commented 2 years ago

Any tips on how I might go about debugging this? I'm not sure if it's a Hoobs4 issue or something else but I'm really wanting to make it work. Trying to get a stack trace or something so that I can begin debugging.