Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wyze crash loop after changing colors via homekit #251

Open
funesgg opened this issue Jun 6, 2024 · 4 comments
Open

Wyze crash loop after changing colors via homekit #251

funesgg opened this issue Jun 6, 2024 · 4 comments
Labels
bug Something isn't working question Further information is requested

Comments

@funesgg
Copy link

funesgg commented Jun 6, 2024

Describe The Bug:
Whenever i use the homekit to change the colors of the wyze bulbs the lights will instead turn green and the plugin will crash causing homebridge to loop. Changing the color manually in the wyze app causes the loop to end and the lights turn on and off as expected but the color changes crash the plugin.

To Reproduce:
Ask siri or use home app to change the color of the wyze bulbs.

Expected behavior:
The colors should change to correct color without causing the homebridge service to go into a loop

Logs:

[06/06/2024, 19:00:05] TypeError: Cannot read properties of null (reading 'r')
    at Object.colorsys.hex2Hsv (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31)
    at WyzeMeshLight.updateColor (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:104:31)
    at WyzeMeshLight.updateCharacteristics (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:69:46)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[06/06/2024, 19:00:06] TypeError: Cannot read properties of null (reading 'r')
    at Object.colorsys.hex2Hsv (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31)
    at WyzeMeshLight.updateColor (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:104:31)
    at WyzeMeshLight.updateCharacteristics (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:69:46)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[06/06/2024, 19:00:06] TypeError: Cannot read properties of null (reading 'r')
    at Object.colorsys.hex2Hsv (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31)
    at WyzeMeshLight.updateColor (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:104:31)
    at WyzeMeshLight.updateCharacteristics (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:69:46)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[06/06/2024, 19:00:05] Got SIGTERM, shutting down Homebridge...
[06/06/2024, 19:00:10] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[06/06/2024, 19:00:15] [HB Supervisor] Restarting Homebridge...
[06/06/2024, 19:00:15] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules --strict-plugin-resolution
[06/06/2024, 19:00:15] [HB Supervisor] Started Homebridge v1.8.2 with PID: 4205
[06/06/2024, 19:00:26] Loaded config.json with 0 accessories and 4 platforms.
[06/06/2024, 19:00:27] Loaded 7 cached accessories from cachedAccessories.
[06/06/2024, 19:00:27] ---
[06/06/2024, 19:00:28] Loaded plugin: homebridge-lifx-plugin@0.3.0
[06/06/2024, 19:00:28] Registering platform 'homebridge-lifx-plugin.LifxPlugin'
[06/06/2024, 19:00:28] ---
[06/06/2024, 19:00:29] Loaded plugin: homebridge-wiz-lan@3.2.8
[06/06/2024, 19:00:29] Registering platform 'homebridge-wiz-lan.WizSmarthome'
[06/06/2024, 19:00:29] ---
[06/06/2024, 19:00:29] Loaded plugin: homebridge-wyze-smart-home@0.5.46
[06/06/2024, 19:00:31] Registering platform 'homebridge-wyze-smart-home.WyzeSmartHome'
[06/06/2024, 19:00:31] ---
[06/06/2024, 19:00:31] Loading 4 platforms...
[06/06/2024, 19:00:31] [Wyze] Initializing WyzeSmartHome platform...
[06/06/2024, 19:00:31] [Lifx Plugin] Initializing LifxPlugin platform...
[06/06/2024, 19:00:31] [WizSmarthome] Initializing WizSmarthome platform...
[06/06/2024, 19:00:31] [WizSmarthome] [Refresh] Pings are off
[06/06/2024, 19:00:31] [WizSmarthome] Loading accessory from cache: Wiz RGB Bulb 444f8e808948
[06/06/2024, 19:00:31] [WizSmarthome] Loading accessory from cache: Wiz RGB Bulb 444f8e8142a2
[06/06/2024, 19:00:31] [WizSmarthome] [Socket] Setting up socket on        
[06/06/2024, 19:00:32] [WizSmarthome] [Discovery] Sending discovery UDP broadcast to 
[06/06/2024, 19:00:32] [WizSmarthome] Updating accessory: Wiz RGB Bulb 444f8e808948
[06/06/2024, 19:00:33] Homebridge v1.8.2 (HAP v0.12.1) (Homebridge 441D) is running on port 51377.
[06/06/2024, 19:00:35] [WizSmarthome] Updating accessory: Wiz RGB Bulb 444f8e8142a2
[06/06/2024, 19:01:20] [Homebridge UI] [funesg] Accessory layout changes saved.
[06/06/2024, 19:03:03] [Homebridge UI] [funesg] Accessory layout changes saved.
[06/06/2024, 19:03:42] TypeError: Cannot read properties of null (reading 'r')
    at Object.colorsys.hex2Hsv (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31)
    at WyzeMeshLight.updateColor (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:104:31)
    at WyzeMeshLight.updateCharacteristics (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:69:46)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[06/06/2024, 19:03:42] Got SIGTERM, shutting down Homebridge...
[06/06/2024, 19:03:42] TypeError: Cannot read properties of null (reading 'r')
    at Object.colorsys.hex2Hsv (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31)
    at WyzeMeshLight.updateColor (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:104:31)
    at WyzeMeshLight.updateCharacteristics (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:69:46)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[06/06/2024, 19:03:42] TypeError: Cannot read properties of null (reading 'r')
    at Object.colorsys.hex2Hsv (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31)
    at WyzeMeshLight.updateColor (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:104:31)
    at WyzeMeshLight.updateCharacteristics (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:69:46)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
[06/06/2024, 19:03:47] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[06/06/2024, 19:03:52] [HB Supervisor] Restarting Homebridge...
[06/06/2024, 19:03:52] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules --strict-plugin-resolution

Plugin Config:

"bridge": {
"name": "Homebridge 441D",
"username": "",
"port": ,
"pin": ",
"advertiser": "avahi"
},
"accessories": [],
"platforms": [
{
"name": "Config",
"port": 8581,
"platform": "config"
},
{
"name": "Wyze",
"username":
"password":
"keyId":
"apiKey":
"refreshInterval": 60000,
"hms": false,
"showAdvancedOptions": false,
"apiLogEnabled": false,
"pluginLoggingEnabled": false,
"lowBatteryPercentage": 30,
"excludeMacAddress": false,
"excludedeviceType": false,
"platform": "WyzeSmartHome"
},
{
"name": "Lifx Plugin",
"duration": 0,
"brightnessDuration": 300,
"colorDuration": 300,
"default": "0.0.0.0",
"broadcast":
"lightOfflineTolerance": 3,
"messageHandlerTimeout": 45000,
"resendPacketDelay": 150,
"resendMaxTimes": 3,
"updates": true,
"debug": false,
"autoDiscover": true,
"platform": "LifxPlugin"
},
{
"name": "WizSmarthome",
"enableScenes": false,
"lastStatus": false,
"broadcast": "",
"refreshInterval": 0,
"platform": "WizSmarthome"
}
]
}

Environment:

Plugin Version v0.5.46

  • Homebridge Version: 4.56.2
  • Node.js Version: 20.12.2
  • NPM Version:
  • Operating System: Raspbian GNU/Linux Bookworm (12)
@funesgg funesgg added bug Something isn't working question Further information is requested labels Jun 6, 2024
Copy link

github-actions bot commented Jun 6, 2024

Message that will be displayed on users' first issue

@zshtx
Copy link

zshtx commented Aug 12, 2024

I'm having the same issue, I haven't been able to get the plugin working since. Have you been able to find a workaround?

@jakespracher
Copy link
Contributor

jakespracher commented Aug 14, 2024

I've stopped the crashloop by adding this code to the updateColor function in WyzeMeshLight.js

/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:108

    if (value === "undefi") {
        console.error('Value is invalid ("undefined" or truncated to "undefi"), cannot convert to HSV');
        return;
    }

Logging I added indicates the string undefi is being passed as the value and the colorsys lib is not handling this gracefully. This change alone has all my lights working with color changing seemingly functional. Will spend a few to see if I can work up the stack and ID why this is happening.

jakespracher added a commit to jakespracher/homebridge-wyze-smart-home that referenced this issue Aug 14, 2024
There was a bug where we try to pass the string "undefi" into the colorsys hex2Hsv method. The library does not handle this gracefully and it results in the error

```
TypeError: Cannot read properties of null (reading 'r')
    at Object.colorsys.hex2Hsv (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31)
    at WyzeMeshLight.updateColor (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:104:31)
    at WyzeMeshLight.updateCharacteristics (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:69:46)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
```

Here we add a check to the updateCharacteristics method (alongside two others that already existed) to ignore this invalid value rather than trying to act on it.

In my local testing the ability to set colors was not impacted as logging seems to indicate a valid color is later provided for the same device.

See: jfarmer08#251
jakespracher added a commit to jakespracher/homebridge-wyze-smart-home that referenced this issue Aug 14, 2024
There was a bug where we try to pass the string "undefi" into the colorsys hex2Hsv method. The library does not handle this gracefully and it results in the error

```
TypeError: Cannot read properties of null (reading 'r')
    at Object.colorsys.hex2Hsv (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/node_modules/colorsys/colorsys.js:197:31)
    at WyzeMeshLight.updateColor (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:104:31)
    at WyzeMeshLight.updateCharacteristics (/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:69:46)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
```

Here we add a check to the updateCharacteristics method (alongside two others that already existed) to ignore this invalid value rather than trying to act on it.

In my local testing the ability to set colors was not impacted as logging seems to indicate a valid color is later provided for the same device.

See: jfarmer08#251
@Geologic9222
Copy link

I've stopped the crashloop by adding this code to the updateColor function in WyzeMeshLight.js

/var/lib/homebridge/node_modules/homebridge-wyze-smart-home/src/accessories/WyzeMeshLight.js:108

    if (value === "undefi") {
        console.error('Value is invalid ("undefined" or truncated to "undefi"), cannot convert to HSV');
        return;
    }

This fixed the crashing for me. I can set the color in the Home app with no problem, but when I ask Siri to set the color it "acts" as if it did, but nothing happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants