Skip to content

Conversation

@dnicolson
Copy link
Contributor

♻️ Current situation

Some unhandled errors result in unreadable exceptions in Homebridge when using homebridge-switchbot.

💡 Proposed solution

Handle errors more gracefully, it's likely that they could be prevented by changes in the async logic in this package.

3d4511a fixes the following error in Homebridge:

Bot: Light failed BLEpushChanges with BLE Connection & botMode: switch, Error Message: "Cannot read properties of undefined (reading 'turnOn')"
TypeError: Cannot read properties of undefined (reading 'turnOn')
    at fn (/usr/lib/node_modules/@switchbot/homebridge-switchbot/src/device/bot.ts:666:18)
    at Bot.retry (/usr/lib/node_modules/@switchbot/homebridge-switchbot/dist/device/bot.js:1115:16)
    at /usr/lib/node_modules/@switchbot/homebridge-switchbot/src/device/bot.ts:661:26
    at runNextTicks (node:internal/process/task_queues:60:5)
    at processTimers (node:internal/timers:504:9)

642e429 fixes the following error in Homebridge:

Curtain: Curtain failed BLEpushChanges with BLE Connection, Error Message: "Cannot read properties of null (reading 'write')"
TypeError: Cannot read properties of null (reading 'write')
TypeError: Cannot read properties of null (reading 'write')
    at /usr/lib/node_modules/@switchbot/homebridge-switchbot/node_modules/node-switchbot/lib/switchbot-device.js:449:42
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:533:9)
    at processTimers (node:internal/timers:507:7)

The latter error is easy to trigger from Homebridge by repeatedly switching a Bot off and on. This also causes all of Homebridge devices to become unresponsive for a short period of time.

@donavanbecker donavanbecker changed the base branch from latest to beta-1.7.3 December 28, 2022 22:23
@donavanbecker donavanbecker merged commit f9900b4 into OpenWonderLabs:beta-1.7.3 Dec 28, 2022
@donavanbecker
Copy link
Collaborator

Thanks @dnicolson!

donavanbecker added a commit that referenced this pull request Jan 5, 2023
## [Version 1.7.3](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.7.3) (2023-01-05)

## What's Changed

- Improve error handling, Thanks [@dnicolson](https://github.com/dnicolson/).  [#175](#175)
- Housekeeping and update dependencies

**Full Changelog**: v1.7.2...v1.7.3
@donavanbecker donavanbecker mentioned this pull request Jan 5, 2023
donavanbecker added a commit that referenced this pull request Jan 5, 2023
## [Version 1.7.3](https://github.com/OpenWonderLabs/node-switchbot/releases/tag/v1.7.3) (2023-01-05)

## What's Changed

- Improve error handling, Thanks [@dnicolson](https://github.com/dnicolson/).  [#175](#175)
- Housekeeping and update dependencies

**Full Changelog**: v1.7.2...v1.7.3
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