Hi, thanks for the fork!
I'm experiencing a crash upon removing bridges from Home, here's the stacktrace:
31 Jul 19:40:15 - TypeError: Cannot read property 'updateAdvertisement' of undefined
at Bridge.Accessory._handleUnpair (/Users/nkasyanov/Desktop/node-red/node_modules/hap-nodejs/lib/Accessory.js:699:20)
at HAPServer.emit (events.js:182:13)
at HAPServer._handlePairings (/Users/nkasyanov/Desktop/node-red/node_modules/hap-nodejs/lib/HAPServer.js:823:10)
at HAPServer.<anonymous> (/Users/nkasyanov/Desktop/node-red/node_modules/hap-nodejs/lib/HAPServer.js:209:39)
at IncomingMessage.emit (events.js:182:13)
at endReadableNT (_stream_readable.js:1081:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Here are some observations:
Just for your information: Got the same problem after removing a bridge.
Restarting node-red "used" as a work around.
same here, when i remove bridge from home node-red crashes
20 Jan 19:44:06 - TypeError: Cannot read property 'updateAdvertisement' of undefined
at Bridge.Accessory._handleUnpair (/Users/kolar/.node-red/node_modules/@plasma2450/hap-nodejs/lib/Accessory.js:699:19)
at emitTwo (events.js:125:13)
at HAPServer.emit (events.js:213:7)
at HAPServer._handlePairings (/Users/kolar/.node-red/node_modules/@plasma2450/hap-nodejs/lib/HAPServer.js:823:10)
at HAPServer.<anonymous> (/Users/kolar/.node-red/node_modules/@plasma2450/hap-nodejs/lib/HAPServer.js:209:39)
at emitNone (events.js:105:13)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1045:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
I'm experincing the same problem:
Feb 03 11:14:00 openhabian Node-RED[2227]: 3 Feb 11:14:00 - TypeError: Cannot read property 'updateAdvertisement' of undefined
Feb 03 11:14:00 openhabian Node-RED[2227]: at Bridge.Accessory._handleUnpair (/home/nodered/.node-red/node_modules/hap-nodejs/lib/Accessory.js:701:20)
Feb 03 11:14:00 openhabian Node-RED[2227]: at emitTwo (events.js:126:13)
Feb 03 11:14:00 openhabian Node-RED[2227]: at HAPServer.emit (events.js:214:7)
Feb 03 11:14:00 openhabian Node-RED[2227]: at HAPServer._handlePairings (/home/nodered/.node-red/node_modules/hap-nodejs/lib/HAPServer.js:823:10)
Feb 03 11:14:00 openhabian Node-RED[2227]: at HAPServer.<anonymous> (/home/nodered/.node-red/node_modules/hap-nodejs/lib/HAPServer.js:209:39)
Feb 03 11:14:00 openhabian Node-RED[2227]: at emitNone (events.js:106:13)
Feb 03 11:14:00 openhabian Node-RED[2227]: at IncomingMessage.emit (events.js:208:7)
Feb 03 11:14:00 openhabian Node-RED[2227]: at endReadableNT (_stream_readable.js:1064:12)
Feb 03 11:14:00 openhabian Node-RED[2227]: at _combinedTickCallback (internal/process/next_tick.js:138:11)
Feb 03 11:14:00 openhabian Node-RED[2227]: at process._tickCallback (internal/process/next_tick.js:180:9)
Somehow this creates some inconsistent state, as I'm unable to add that bridge (after modifications) again to the Home App. The only thing that worked so far, is deleteing the Bridge-Node in NR and creating it new again. Unfortunately, that involves adjusting all Service-Nodes...
If someone knows about a better workaround, please let me know.
im using homekit2mqtt and integrating it with node-red via mqtt, this node red plugin looks broken :/
@martincollar in your stack trace I can see you are using fork by @plasma2450.
Please remove @plasma2450/node-red-contrib-homekit-bridged and @plasma2450/hap-nodes.
Then download our latest version (released today):
npm i node-red-contrib-homekit-bridged
@1stone Could you update to 0.5.0 and try to reproduce error?
Can you write complete list of steps to reproduce it?
I can say the problem does exists ;)
I am going to look at this next week.
There will be a try to fix this today. Could be related to #12
@nikolaykasyanov @ttww @martincollar @1stone
I think I fixed it on my last commit to dev branch.
What was the problem?
When we remove Service nodes from flow then we usually still have unused Bridge node.
Bridge node is not published since it doesn't have active Service nodes. And since it's not published it crash on advertiser update because advertiser is not started!
What I did?
I overrided unpair event handler for Bridge server and added check for advertiser if it's null.
It works for me! :)
I made a PR in HAP-nodejs. If they accept it then I will remove override from our code.
Retest:
[ ] node-red should crash with error 'TypeError: Cannot read property 'updateAdvertisement' of undefined'
Checking fix
Please retest using above.
I summon my best associates @radokristof @crxporter @flic @radionoise @emilingerslev aka @NRCHKB/test
The last thing I want to do is to release something tested by me only. But if I have to...
Please update to new version 0.6.1 using node-red.
Then please retest this bug if it's still occurs.
So as my fix is merged to newest HAP-nodejs then we need to remove fix from our code.
Opening so I will not forget.
Most helpful comment
I can say the problem does exists ;)
I am going to look at this next week.