jfarmer08 / homebridge-wyze-smart-home

Wyze Smart Home plugin for Homebridge.
MIT License
104 stars 17 forks source link

TypeError issue causing service to restart #51

Closed mustangjac closed 1 year ago

mustangjac commented 1 year ago

Starting about a week or so ago, this error started showing up: "[Wyze] Error getting devices: TypeError: Cannot read properties of null (reading 'r')"

I have Homebridge installed on an Unraid box in docker running version v1.6.0 of Homebridge. I also have a sandbox homebridge container running on a separate device that's running v1.5.0 that's also receiving this error.

Running the current version of the wyze plugin, v0.5.24, I removed the container and the config folder, reinstalled and reconfigured.....same results. Installed beta version of Wyze Smart Home, v0.5.2-5 Beta 3....same results.

However, if I install the older version, 0.5.22, the error still occurs, but it doesn't force the service to restart.....just fills up my logs with "[Wyze] Error getting devices: TypeError: Cannot read properties of null (reading 'r')". Though the app stays functional, and the service remains stable and usable.

github-actions[bot] commented 1 year ago

Message that will be displayed on users' first issue

jfarmer08 commented 1 year ago

Can you turn on debug. We need the logs to better understand the issue.

mustangjac commented 1 year ago

/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197 return colorsys.rgb2Hsv(rgb.r, rgb.g, rgb.b) ^ TypeError: Cannot read properties of null (reading 'r') at Object.colorsys.hex2Hsv (/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31) at WyzeMeshLight.updateColor (/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:73:31) at WyzeMeshLight.updateCharacteristics (/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:54:18) at processTicksAndRejections (node:internal/process/task_queues:95:5) at WyzeMeshLight.update (/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeAccessory.js:51:7) [12/20/2022, 12:52:07 PM] [Wyze] Child bridge process ended [12/20/2022, 12:52:07 PM] [Wyze] Process Ended. Code: 1, Signal: null [12/20/2022, 12:52:14 PM] [Wyze] Restarting Process... [12/20/2022, 12:52:14 PM] [Wyze] Launched child bridge with PID 16219 [12/20/2022, 12:52:14 PM] Registering platform 'homebridge-wyze-smart-home.WyzeSmartHome' [12/20/2022, 12:52:14 PM] [Wyze] Loaded homebridge-wyze-smart-home v0.5.24 child bridge successfully [12/20/2022, 12:52:14 PM] Loaded 46 cached accessories from cachedAccessories.0E42B25401EB. [12/20/2022, 12:52:14 PM] Homebridge v1.6.0 (HAP v0.11.0) (Wyze) is running on port 49434.

mustangjac commented 1 year ago

That's the part that keeps repeating. I'll try enabling debug.

jfarmer08 commented 1 year ago

That helps a lot. I will see what I can find.

mustangjac commented 1 year ago

FYI, that's from the container running the newest official release of HB and the wyze plugin. That's the one that restarts itself over and over. I'll see if I can get logs from the one running the older version of the plugin that's just thowing the error without restarting the service.

mustangjac commented 1 year ago

OK, even with debug on, this is all that is showing...repeating every minute and a couple seconds.

[12/20/2022, 1:05:46 PM] [Wyze] Error getting devices: TypeError: Cannot read properties of null (reading 'r') [12/20/2022, 1:06:50 PM] [Wyze] Error getting devices: TypeError: Cannot read properties of null (reading 'r')

This is the one running the older plugin. V0.5.23

jfarmer08 commented 1 year ago

So the issue is with converting hex color from wyze into HSL for HomeKit. I am not seeing the same error so that says your getting a different value on the update. Are you using color bulbs or the light strip? Also what color do you have set in the wyze app? One thing you can do after checking the color in the app then change it and see if the error is still there.

// Convert a Hex color from Wyze into the HSL values recognized by HomeKit. const hslValue = colorsys.hex2Hsv(value)

jfarmer08 commented 1 year ago

So say for red, it looks like wyze hex color is not translated correctly to rgb and therefor it cannot be converted to hsv.

image

mustangjac commented 1 year ago

Yeah. Most of my bulbs are color. I’ll give it a try tonight and get back to you. Thanks for the suggestion.

jfarmer08 commented 1 year ago

Just let me know. If it changes anything.

jfarmer08 commented 1 year ago

Any other details for this?

mustangjac commented 1 year ago

Yep. I’ve tried just about every color from plain white, red, blue, green and just randoms. Same results. I’m going to setup a new Wyze account t tomorrow and add a few bulbs to it and see if there’s any difference.

-Jac


From: jfarmer08 @.> Sent: Sunday, December 25, 2022 11:05:03 AM To: jfarmer08/homebridge-wyze-smart-home @.> Cc: mustangjac @.>; Author @.> Subject: Re: [jfarmer08/homebridge-wyze-smart-home] TypeError issue causing service to restart (Issue #51)

Any other details for this?

— Reply to this email directly, view it on GitHubhttps://github.com/jfarmer08/homebridge-wyze-smart-home/issues/51#issuecomment-1364703153, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ATU4WGB5CW3EMVOK44YS2XDWPBWC7ANCNFSM6AAAAAATEUTKCU. You are receiving this because you authored the thread.Message ID: @.***>

mustangjac commented 1 year ago

New Account and new bulb.....The original error is gone. When I first added the new bulb, it gave a warning below....but didn't affect the functionality....when I changed the color from the original, it went away completely.

I have about a dozen bulbs on the main account....I suppose I can try removing them one by one to see which is causing it....then reload it (or all) and see if that resolves my issue.

mustangjac commented 1 year ago

Warning mentioned from above.

[12/30/2022, 11:53:48 AM] [homebridge-wyze-smart-home] This plugin generated a warning from the characteristic 'Color Temperature': characteristic value expected valid finite number and received "Infinity" (number). See https://homebridge.io/w/JtMGR for more info. [12/30/2022, 11:54:48 AM] [Wyze] Loading accessory from cache Color Bulb 1 (MAC:) [12/30/2022, 11:54:50 AM] [homebridge-wyze-smart-home] This plugin generated a warning from the characteristic 'Color Temperature': characteristic value expected valid finite number and received "Infinity" (number). See https://homebridge.io/w/JtMGR for more info. [12/30/2022, 11:55:11 AM] [Homebridge UI] [jac] Accessory layout changes saved. [12/30/2022, 11:55:39 AM] [Homebridge UI] [jac] Accessory layout changes saved. [12/30/2022, 11:55:50 AM] [Wyze] Loading accessory from cache Color Bulb 1 (MAC:) [12/30/2022, 11:55:51 AM] [homebridge-wyze-smart-home] This plugin generated a warning from the characteristic 'Color Temperature': characteristic value expected valid finite number and received "Infinity" (number). See https://homebridge.io/w/JtMGR for more info. [12/30/2022, 11:56:53 AM] [Wyze] Loading accessory from cache Color Bulb 1 (MAC:) [12/30/2022, 11:56:54 AM] [homebridge-wyze-smart-home] This plugin generated a warning from the characteristic 'Color Temperature': characteristic value expected valid finite number and received "Infinity" (number). See https://homebridge.io/w/JtMGR for more info. [12/30/2022, 11:57:55 AM] [Wyze] Loading accessory from cache Color Bulb 1 (MAC:) [12/30/2022, 11:57:56 AM] [homebridge-wyze-smart-home] This plugin generated a warning from the characteristic 'Color Temperature': characteristic value expected valid finite number and received "Infinity" (number). See https://homebridge.io/w/JtMGR for more info. [12/30/2022, 11:58:58 AM] [Wyze] Loading accessory from cache Color Bulb 1 (MAC:) [12/30/2022, 12:00:00 PM] [Wyze] Loading accessory from cache Color Bulb 1 (MAC:)

mustangjac commented 1 year ago

I removed each color bulb....then re-added it. Then moved on to the next. It was the last bulb that cleared the issue. I wonder if it was that bulb's config....or the act of removing them all that cleared it.

mustangjac commented 1 year ago

One thing to note now however.....is that the plugin seems to reload all the accessories each minute....which isn't happening on the other device. Doesn't seem to be causing any trouble though.

jfarmer08 commented 1 year ago

Any help provided would be great. Also having debug logs would also help.

carTloyal123 commented 1 year ago

@mustangjac is this still causing an issue or has it resolved itself?

mustangjac commented 1 year ago

Sorry for the silence. Busy after the holidays....

The plugin is working well, which has pushed this out of mind...but it does still continue to reload the wyze cached devices every minute....which doesn't seem to affect functionality...but it does make the logs pretty cluttered. I'll turn debug on and let it run for a bit and I'll post those shortly.

mustangjac commented 1 year ago

Here's my logs. I disabled all other plug-ins so hopefully it's less cluttered.

homebridge.log(2).txt

evbart commented 1 year ago

I'm having the same issue, my wyze plugin repeatedly crashes and restarts and it seems to be color related.

I'm fairly new to all this, so let me know if this is the part of the logs that you want to see, i just grabbed from restart to restart:

[Wyze] Restarting Process... [1/9/2023, 9:32:43 PM] [Wyze] Launched child bridge with PID 28333 [1/9/2023, 9:32:44 PM] Registering platform 'homebridge-wyze-smart-home.WyzeSmartHome' [1/9/2023, 9:32:44 PM] [Wyze] Loaded homebridge-wyze-smart-home v0.5.24 child bridge successfully [1/9/2023, 9:32:44 PM] Loaded 5 cached accessories from cachedAccessories.0EC244888A29. [1/9/2023, 9:32:44 PM] Homebridge v1.6.0 (HAP v0.11.0) (Wyze) is running on port 39269. [1/9/2023, 9:32:45 PM] [Wyze] Loading accessory from cache Side Table (MAC: XXXXXXXXXXXXX) [1/9/2023, 9:32:45 PM] [Wyze] Loading accessory from cache Desk Lamp (MAC: XXXXXXXXXXXXX) [1/9/2023, 9:32:45 PM] [Wyze] Loading accessory from cache Bar Light (MAC: XXXXXXXXXXXXX) [1/9/2023, 9:32:45 PM] [Wyze] Loading accessory from cache Ceiling bulb 2 (MAC: XXXXXXXXXXXXX) [1/9/2023, 9:32:45 PM] [Wyze] Loading accessory from cache Ceiling bulb 1 (MAC: XXXXXXXXXXXXX)

/usr/local/lib/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197 return colorsys.rgb2Hsv(rgb.r, rgb.g, rgb.b) ^ TypeError: Cannot read properties of null (reading 'r') at Object.colorsys.hex2Hsv (/usr/local/lib/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31) at WyzeMeshLight.updateColor (/usr/local/lib/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:73:31) at WyzeMeshLight.updateCharacteristics (/usr/local/lib/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:54:18) at processTicksAndRejections (node:internal/process/task_queues:96:5) at WyzeMeshLight.update (/usr/local/lib/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeAccessory.js:51:7) [1/9/2023, 9:32:45 PM] [Wyze] Child bridge process ended [1/9/2023, 9:32:45 PM] [Wyze] Process Ended. Code: 1, Signal: null [1/9/2023, 9:32:52 PM] [Wyze] Restarting Process...

evbart commented 1 year ago

For additional context, firmware on my wyze bulbs is 1.2.0.508, Homebridge v1.6.0 , Node v16.16.0, running it on an old mac mini mid 2010. I had the plugin working for a minute before the issue came up, can't isolate what changed.

jfarmer08 commented 1 year ago

Can you confirm what version your running of the addon. Also can you try and exclude MeshLight. Let's see if there are any other issues.

@evbart

evbart commented 1 year ago

So strange… but now it’s working. I’m using version v0.5.24.

I uninstalled and reinstalled the plug-in ( which I had done before ) but otherwise don’t know what would have fixed it

jfarmer08 commented 1 year ago

So I believe we are getting invalid data from the api. We need debug log when this happens.