kuestess / homebridge-platform-insteonlocal

Homebridge platform plugin for local Insteon control
Other
76 stars 26 forks source link

Regular Homebridge crash upon reading properties #260

Closed JimCSaratoga closed 1 year ago

JimCSaratoga commented 2 years ago

@kuestess I'm seeing regular crashes in an idle state when the plugin is (assumedly) getting status for the same device (it's a 2477S grouped switch). I've turned on debug and have DM'ed you the config and full log file. You'll see that it happens only with the query of the status of this single device and that it pushes out a TypeError each time.

of particular interest in this scenario since the Insteon servers have come back up I've factory reset all devices, re-created the entire Insteon Hub configuration including Scenes and have created a brand new Homebridge / InsteonLocal configuration. All that said it's crashing on the same device in the new config also.

Any and all thoughts are appreciated.

Thanks !!!

[6/22/2022, 4:25:46 PM] [InsteonLocal] Group device is a name...
[6/22/2022, 4:25:46 PM] [InsteonLocal] Found matching device with id  2A6978
[6/22/2022, 4:25:46 PM] TypeError: Cannot read properties of undefined (reading 'name')
    at /usr/local/lib/node_modules/homebridge-platform-insteonlocal/index.js:2478:58
    at Array.forEach (<anonymous>)
    at InsteonLocalAccessory.getGroupMemberStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/index.js:2469:20)
    at Insteon.<anonymous> (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/index.js:739:40)
    at Insteon.emit (node:events:527:28)
    at Insteon.handler (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:725:12)
    at Insteon._checkStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:667:33)
    at Insteon.checkStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:603:21)
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:615:16)
    at listOnTimeout (node:internal/timers:559:17)
[6/22/2022, 4:25:46 PM] Got SIGTERM, shutting down Homebridge...
JimCSaratoga commented 2 years ago

@kuestess I tried an experiment and removed that device from the config and am still seeing this same error in the log sporadically now targeting another device:

[6/23/2022, 7:16:53 AM] [InsteonLocal] Getting status of scene device Garage Lanterns 1
[6/23/2022, 7:16:53 AM] [InsteonLocal] Group device type switch
[6/23/2022, 7:16:53 AM] [InsteonLocal] Group device is a name...
[6/23/2022, 7:16:53 AM] [InsteonLocal] Found matching device with id  585413
[6/23/2022, 7:16:53 AM] TypeError: Cannot read properties of undefined (reading 'name')
    at /usr/local/lib/node_modules/homebridge-platform-insteonlocal/index.js:2478:58
    at Array.forEach (<anonymous>)
    at InsteonLocalAccessory.getGroupMemberStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/index.js:2469:20)
    at Insteon.<anonymous> (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/index.js:739:40)
    at Insteon.emit (node:events:527:28)
    at Insteon.handler (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:725:12)
    at Insteon._checkStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:667:33)
    at Insteon.checkStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:603:21)
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:615:16)
    at listOnTimeout (node:internal/timers:559:17)
[6/23/2022, 7:16:53 AM] Got SIGTERM, shutting down Homebridge...

Uploaded the full log export to DB

64Spaces commented 2 years ago

@JimCSaratoga, do you have any of the old powerline only devices (pre-Dual Band) in your setup? I had issues with my older devices. They would have difficulty linking and sometimes they would not respond. Overtime, they would eventually totally fail. I recently upgraded everything to dual band and since then, I have not had any real issues. My understanding is that, just like the hub and PLM’s, the older switches had capacitor issues. All my switches are now versions of Rev. 7.x and 8.x.

JimCSaratoga commented 2 years ago

@64Spaces thanks for that advice. I'll have to check there are over 100 of them in the house but they were all purchased after 2014 so I'm assuming that they are all dual band. Interesting to hear about the response issues. Good news is that I was able to get a new 2020 hub on eBay in the great "sell-off" of Insteon gear. Opportunity for all of us to purchase back up gear in the event Ken and team are only able to get one product line (the former Nokia line) back into production.

kuestess commented 2 years ago

@JimCSaratoga I think this may be some logic that I need to fix. For your scene devices, try replacing the device id in the groupMembers key with the name of the group device instead of the device id and see if that fixes the crash.

PS - you probably want to define the 'Garage Lanterns' in your config as a scene rather than a keypad.

JimCSaratoga commented 2 years ago

@kuestess thanks for the guidance. And thank you for catching my slip on scene vs. keypad !

Just to make sure I'm understanding you correctly I've modified the config as follows:

                {
                    "name": "Driveway Lanterns 1",
                    "deviceID": "2ZZZZZ",
                    "deviceType": "switch",
                    "dimmable": "no",
                    "groupMembers": "Driveway Lanterns 2"
                },
                {
                    "name": "Driveway Lanterns 2",
                    "deviceID": "2YYYYY",
                    "deviceType": "switch",
                    "dimmable": "no",
                    "groupMembers": "Driveway Lanterns 1"
                },
                {
                    "name": "Driveway Lanterns",
                    "deviceID": "2AXXXX",
                    "deviceType": "scene",
                    "keypadbtn": "D",
                    "six_btn": "true",
                    "groupID": "51"
                }

The syntax doesn't halt anything - interesting to see that the "name" is ok there in groupMembers. Question what if you had multiple group members? ie. Driveway Lanterns 1, Driveway Lanterns 2, Driveway Lanterns 3 - I tried enclosing them in an array [ ] but that didn't pass the syntax check.

FYI so far no crashes !!!

kuestess commented 2 years ago

@JimCSaratoga You should just be able to put multiple device names in a comma separated list inside the quotes. The code will try to figure out whether it is a series of names or device ids.

JimCSaratoga commented 2 years ago

Update after 48 hours no crashes! (caveat: with the config that doesn't have the multiple groupMembers stated below) - @kuestess I'm assuming it's just a parsing issue with the construction of the string and the spaces in my device names? FYI I tried renaming the Driveway Lanterns 1 & 2 with underscores instead of spaces ie. Driveway_Lanterns_1 but it still had the TypeError on the groupMembers key value.

JimCSaratoga commented 2 years ago

Tried the CSL and got a crash:

[6/28/2022, 10:49:40 AM] [InsteonLocal] Got event for Garage Entry Keypad (2C0238)
[6/28/2022, 10:49:40 AM] [InsteonLocal] Got event for Driveway Lanterns (2C0238)
[6/28/2022, 10:49:40 AM] [InsteonLocal] Group device is a name...
[6/28/2022, 10:49:40 AM] [InsteonLocal] Found matching device with id Driveway Lanterns 1
[6/28/2022, 10:49:40 AM] [InsteonLocal] Getting status of scene device Driveway Lanterns 1
[6/28/2022, 10:49:40 AM] [InsteonLocal] Group device is a name...
[6/28/2022, 10:49:40 AM] [InsteonLocal] Found matching device with id  Driveway Lanterns 2
[6/28/2022, 10:49:40 AM] TypeError: Cannot read properties of undefined (reading 'name')
    at /usr/local/lib/node_modules/homebridge-platform-insteonlocal/index.js:2478:58
    at Array.forEach (<anonymous>)
    at InsteonLocalAccessory.getGroupMemberStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/index.js:2469:20)
    at Insteon.<anonymous> (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/index.js:739:40)
    at Insteon.emit (node:events:527:28)
    at Insteon.handler (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:725:12)
    at Insteon._checkStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:667:33)
    at Insteon.checkStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:603:21)
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:615:16)
    at listOnTimeout (node:internal/timers:559:17)
[6/28/2022, 10:49:40 AM] Got SIGTERM, shutting down Homebridge...

with this config:

               {
                    "name": "Driveway Lanterns 1",
                    "deviceID": "2A6080",
                    "deviceType": "switch",
                    "dimmable": "no",
                    "groupMembers": "Driveway Lanterns 2"
                },
                {
                    "name": "Driveway Lanterns 2",
                    "deviceID": "2A6978",
                    "deviceType": "switch",
                    "dimmable": "no",
                    "groupMembers": "Driveway Lanterns 1"
                },
                {
                    "name": "Driveway Lanterns",
                    "deviceID": "2C0238",
                    "deviceType": "scene",
                    "keypadbtn": "D",
                    "six_btn": "true",
                    "groupID": "58",
                    "groupMembers": "Driveway Lanterns 1, Driveway Lanterns 2"
                },
kuestess commented 1 year ago

@JimCSaratoga This should now be fixed in the 0.5.0 release I published last night.

JimCSaratoga commented 1 year ago

@kuestess awesome I'll upgrade right now and change back the names thank you !!

JimCSaratoga commented 1 year ago

@kuestess working for me - not crashing. I'm not seeing the update on the second device (status update) in Apple's Home app but that's ok because I'll probably group them anyhow in the Home app. thank you !

JimCSaratoga commented 1 year ago

@kuestess sorry seeing crashes again. Config hasn't changed since my last update above. What information can I provide? The crash documented in the log is the same as above.

kuestess commented 1 year ago

@JimCSaratoga Can you post the recent crash log?

ucdscott commented 1 year ago

I'm experiencing this same issue. All I have are leak sensors.

Running latest version of Homebridge and your plugin.

[9/1/2022, 8:19:35 AM] TypeError: Cannot read property 'id' of undefined at /usr/local/lib/node_modules/homebridge-platform-insteonlocal/src/InsteonLocalPlatform.ts:120:27 at /usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/q/q.js:2055:17 at runSingle (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/q/q.js:137:13) at flush (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/q/q.js:125:13) at processTicksAndRejections (internal/process/task_queues.js:75:11) [9/1/2022, 8:19:35 AM] Got SIGTERM, shutting down Homebridge... [9/1/2022, 8:19:35 AM] Got SIGTERM, shutting down child bridge process... [9/1/2022, 8:19:40 AM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null [9/1/2022, 8:19:45 AM] [HB Supervisor] Restarting Homebridge...

JimCSaratoga commented 1 year ago

sorry for the delay:

[9/1/2022, 2:57:27 PM] [InsteonLocal] Got event for Garage Entry Keypad (2C0238)
[9/1/2022, 2:57:27 PM] [InsteonLocal] Got event for Driveway Lanterns (2C0238)
[9/1/2022, 2:57:27 PM] [InsteonLocal] Group device is a name...
[9/1/2022, 2:57:27 PM] [InsteonLocal] Found matching device with id Driveway Lanterns 1
[9/1/2022, 2:57:27 PM] [InsteonLocal] Getting status of scene device Driveway Lanterns 1
[9/1/2022, 2:57:27 PM] [InsteonLocal] Group device is a name...
[9/1/2022, 2:57:27 PM] [InsteonLocal] Found matching device with id  Driveway Lanterns 2
[9/1/2022, 2:57:27 PM] TypeError: Cannot read properties of undefined (reading 'name')
    at /usr/local/lib/node_modules/homebridge-platform-insteonlocal/src/InsteonLocalAccessory.ts:1421:66
    at Array.forEach (<anonymous>)
    at InsteonLocalAccessory.getGroupMemberStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/src/InsteonLocalAccessory.ts:1396:23)
    at Insteon.<anonymous> (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/src/InsteonLocalPlatform.ts:487:50)
    at Insteon.emit (node:events:527:28)
    at Insteon.handler (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:725:12)
    at Insteon._checkStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:667:33)
    at Insteon.checkStatus (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:603:21)
    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-platform-insteonlocal/node_modules/home-controller/lib/Insteon/index.js:615:16)
    at listOnTimeout (node:internal/timers:559:17)
[9/1/2022, 2:57:27 PM] Got SIGTERM, shutting down Homebridge...
[9/1/2022, 2:57:28 PM] [InsteonLocal] Received command for 2879C0
[9/1/2022, 2:57:29 PM] [InsteonLocal] Received command for 2A69ED
[9/1/2022, 2:57:29 PM] [InsteonLocal] Found 1 accessories matching 2A69ED
[9/1/2022, 2:57:29 PM] [InsteonLocal] Hub command: {"standard":{"type":"50","id":"2A69ED","gatewayId":"571302","extended":false,"messageType":1,"hopsLeft":0,"maxHops":0,"command1":"00","command2":"00","raw":"02502A69ED571302200000"}}
[9/1/2022, 2:57:29 PM] [InsteonLocal] Got event for Garage Floods 2 (2A69ED)
[9/1/2022, 2:57:29 PM] [InsteonLocal] Getting status for Driveway Lanterns 1
[9/1/2022, 2:57:29 PM] [InsteonLocal] Driveway Lanterns 1 is off at 0%
[9/1/2022, 2:57:30 PM] [InsteonLocal] Received command for 585413
[9/1/2022, 2:57:30 PM] [InsteonLocal] Found 1 accessories matching 585413
[9/1/2022, 2:57:30 PM] [InsteonLocal] Hub command: {"standard":{"type":"50","id":"585413","gatewayId":"571302","extended":false,"messageType":1,"hopsLeft":0,"maxHops":0,"command1":"00","command2":"00","raw":"0250585413571302200000"}}
[9/1/2022, 2:57:30 PM] [InsteonLocal] Got event for Garage Lanterns 2 (585413)
[9/1/2022, 2:57:31 PM] [InsteonLocal] Received command for 423292
[9/1/2022, 2:57:32 PM] [InsteonLocal] Received command for 2A608E
[9/1/2022, 2:57:32 PM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[9/1/2022, 2:57:37 PM] [HB Supervisor] Restarting Homebridge...
[9/1/2022, 2:57:37 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -D
[9/1/2022, 2:57:37 PM] [HB Supervisor] Started Homebridge v1.5.0 with PID: 41600
[9/1/2022, 2:57:37 PM] Loaded config.json with 0 accessories and 2 platforms.
[9/1/2022, 2:57:37 PM] Loaded 26 cached accessories from cachedAccessories.
[9/1/2022, 2:57:37 PM] ---
[9/1/2022, 2:57:37 PM] Loaded plugin: homebridge-config-ui-x@4.50.1
[9/1/2022, 2:57:37 PM] Registering platform 'homebridge-config-ui-x.config'
[9/1/2022, 2:57:37 PM] ---
[9/1/2022, 2:57:37 PM] Loaded plugin: homebridge-platform-insteonlocal@0.5.3
[9/1/2022, 2:57:37 PM] Registering platform 'homebridge-platform-insteonlocal.InsteonLocal'
[9/1/2022, 2:57:37 PM] ---
[9/1/2022, 2:57:37 PM] Loading 2 platforms...
[9/1/2022, 2:57:37 PM] [InsteonLocal] Initializing InsteonLocal platform...
[9/1/2022, 2:57:37 PM] [InsteonLocal] Connecting to Insteon Model 2245 Hub...
[9/1/2022, 2:57:37 PM] [InsteonUI] Initializing Insteon UI 
[9/1/2022, 2:57:37 PM] [InsteonUI] Reading config from /Users/homebridge/.homebridge/config.json
[9/1/2022, 2:57:37 PM] [InsteonUI] Found 2 platform(s) in config
[9/1/2022, 2:57:37 PM] [InsteonUI] Reading devices from insteon.json
[9/1/2022, 2:57:37 PM] [InsteonUI] Done with InsteonUI init
[9/1/2022, 2:57:37 PM] [InsteonLocal] Finished initializing platform: InsteonLocal
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: First Floor Bathroom Leak Sensor
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Henri Bathroom Leak Sensor
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Guest Bathroom Leak Sensor
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Basement Water Main
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Basement First Floor Furnace
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Basement Second Floor Furnace
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Basement Water Heater
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Laundry Room Sink Leak Sensor
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Laundry Room Washer Leak Sensor
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Basement Sump Pump Leak Sensor
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Master Bathroom Toilet Leak Sensor
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Family Room Outlets
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Front Entrance Lanterns
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Garage Entry Keypad
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Driveway Lanterns 1
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Driveway Lanterns 2
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Driveway Lanterns
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Garage Lanterns 1
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Garage Lanterns 2
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Garage Lanterns
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Landscape Lights Switch
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Landscape Lights Module
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Garage Floods 1
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Garage Floods 2
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Garage Floods
[9/1/2022, 2:57:37 PM] [InsteonLocal] Loading accessory from cache: Right Side Floods
[9/1/2022, 2:57:37 PM] [InsteonLocal] Executed didFinishLaunching callback
[9/1/2022, 2:57:37 
kuestess commented 1 year ago

@JimCSaratoga I've done some troubleshooting and I think I have a fix. In your config, can you remove the space after the comma in your comma-separated list of group members, ie:

"groupMembers": "Driveway Lanterns 1,Driveway Lanterns 2"

I tested a few things on my config and I think this is the issue - just want to make sure it works with your config.

JimCSaratoga commented 1 year ago

@kuestess thanks for your persistence on my problem! I have updated the config and so far haven't seen the home bridge crashes.... I'll continue to monitor. Your efforts, as always, are Greatly Appreciated!

kuestess commented 1 year ago

@JimCSaratoga Thanks - published a fix that should sanitize the inputs so you no longer need to worry about spaces. Let me know if you have any issues.

JimCSaratoga commented 1 year ago

@kuestess operating over 18 hours and no issues at all

kuestess commented 1 year ago

@JimCSaratoga Good stuff - closing this one out, let me know if anything pops up!