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

Check for "undefi" property values on update #261

Merged
merged 2 commits into from
Aug 18, 2024

Conversation

jakespracher
Copy link
Contributor

@jakespracher jakespracher commented 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. The invalid string itself appears to originate from the WyzeAPI library.

See issues: #251 #232 #228

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
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message that will be displayed on users' first pull request

@jfarmer08 jfarmer08 merged commit ecc4c95 into jfarmer08:main Aug 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants