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

homebridge-switchbot-sensor-ble #565

Closed
moritzmhmk opened this issue Sep 1, 2023 · 22 comments
Closed

homebridge-switchbot-sensor-ble #565

moritzmhmk opened this issue Sep 1, 2023 · 22 comments
Labels
verified use when a plugin meets the criteria - adds the verified badge text

Comments

@moritzmhmk
Copy link

Link To GitHub Repo

https://github.com/moritzmhmk/homebridge-switchbot-sensor-ble

Link To NPM Package

https://www.npmjs.com/package/homebridge-switchbot-sensor-ble

@moritzmhmk moritzmhmk added the pending the label given to a new verification/icon request label Sep 1, 2023
@github-actions
Copy link

github-actions bot commented Sep 1, 2023

The following pre-checks failed:

❌ Failed to import plugin: EAFNOSUPPORT, Address family not supported by protocol

Comment /check to run checks again.

@moritzmhmk
Copy link
Author

/check

@github-actions
Copy link

github-actions bot commented Sep 1, 2023

✅ Pre-checks completed successfully.

@bwp91
Copy link
Contributor

bwp91 commented Sep 1, 2023

Hi @moritzmhmk

How does your plugin handle cases where abandonware/noble has not been able to install - does the plugin properly catch the error in this case?

@moritzmhmk
Copy link
Author

Hi it will log an error message here and since the accessory never receives a value for temperature and humidity it will be marked as unreachable in the Home App.

@bwp91
Copy link
Contributor

bwp91 commented Sep 1, 2023

alrighty thank you for confirming.

also, does this plugin offer any more functionality than the already verified switchbot plugins?
Screenshot 2023-09-02 at 00 11 37

It might be worth a note in your readme about how your plugin is different.

Whilst there is no official plugin verification rule against multiple plugins with the same functionality, I think it would be helpful for users who are looking for their right plugin to see (e.g. in your readme) how yours is different from the others

@bwp91 bwp91 added awaiting-user-reply use after review has started - awaiting user to reply to a comment and removed pending the label given to a new verification/icon request labels Sep 1, 2023
@moritzmhmk
Copy link
Author

When trying to get the sensor to work on my Raspberry Pi 4 with Docker, I kept getting the error adapter is not ready: unknown, while other (non switchbot) BLE devices in the setup worked fine. Tracking down the error, I found that the node-switchbot library used by the other plugins was causing the error. Looking into creating a PR for node-switchbot, I found that it is easier to create a new plugin from scratch that only handles the device in question and does not rely on dependencies (besides noble).

So, unlike the other alternatives, my package is written according to the philosophy of doing only one thing but doing it well and having as few dependencies as reasonably possible. I tried to hint towards this in the README, if you have a suggestion on how to better communicate this to other users I will be happy to adjust the README accordingly.

@moritzmhmk
Copy link
Author

I updated the README.

@moritzmhmk
Copy link
Author

moritzmhmk commented Sep 2, 2023

After some communication with the creator of the other plugin, I looked at the problem again.

The node-switchbot package indeed has a BLE initialisation that is not compatible with my (and others Docker based) setup. Furthermore, and this is what made the troubleshooting so confusing, there is no support in node-switchbot at all for the sensor in question and additionally a wrong identifier used in the homebridge-switchbot plugin.

I have created corresponding PRs in both repos. Nevertheless, I will keep using my plugin due to its few dependencies and the concise code. For all those who also only use the hygrometers from Switchbot, it might be a lightweight alternative.

@bwp91
Copy link
Contributor

bwp91 commented Sep 3, 2023

One more small thing, after installing the plugin and configuring an accessory with the ble address of a thermometer sensor with a different brand (yes, I wasn't expecting to work!) but it does throw homebridge into a crash loop:

[03/09/2023, 14:16:17] [Hygrometer] Restarting Process...
[03/09/2023, 14:16:19] [Hygrometer] Launched child bridge with PID 11611
[03/09/2023, 14:16:19] Registering accessory 'homebridge-switchbot-sensor-ble.SwitchBotSensorBLE'
[03/09/2023, 14:16:19] [Hygrometer] Loaded homebridge-switchbot-sensor-ble v1.3.2 child bridge successfully
[03/09/2023, 14:16:19] Loaded 0 cached accessories from cachedAccessories.0E7C2D126D68.
[03/09/2023, 14:16:19] [Hygrometer] SwitchBotSensorBLE finished initializing!
[03/09/2023, 14:16:19] Homebridge v2.0.0-beta.1 (HAP v1.0.0-beta.8) (Hygrometer) is running on port 44449.
TypeError: Cannot read properties of undefined (reading '10')
    at SwitchBotSensorBLE.updateFromAdvertisement (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/src/accessory.ts:86:13)
    at Noble.<anonymous> (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/src/accessory.ts:72:12)
    at Noble.emit (node:events:514:28)
    at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/node_modules/@abandonware/noble/lib/noble.js:218:10)
    at NobleBindings.emit (node:events:514:28)
    at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:213:10)
    at Gap.emit (node:events:514:28)
    at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/node_modules/@abandonware/noble/lib/hci-socket/gap.js:175:10)
    at Hci.emit (node:events:514:28)
    at Hci.processLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/node_modules/@abandonware/noble/lib/hci-socket/hci.js:1148:12)
[03/09/2023, 14:16:22] [Hygrometer] Child bridge process ended
[03/09/2023, 14:16:22] [Hygrometer] Process Ended. Code: 1, Signal: null
[03/09/2023, 14:16:29] [Hygrometer] Restarting Process...
[03/09/2023, 14:16:30] [Hygrometer] Launched child bridge with PID 11626
[03/09/2023, 14:16:30] Registering accessory 'homebridge-switchbot-sensor-ble.SwitchBotSensorBLE'
[03/09/2023, 14:16:30] [Hygrometer] Loaded homebridge-switchbot-sensor-ble v1.3.2 child bridge successfully
[03/09/2023, 14:16:30] Loaded 0 cached accessories from cachedAccessories.0E7C2D126D68.
[03/09/2023, 14:16:31] [Hygrometer] SwitchBotSensorBLE finished initializing!
[03/09/2023, 14:16:31] Homebridge v2.0.0-beta.1 (HAP v1.0.0-beta.8) (Hygrometer) is running on port 44449.
TypeError: Cannot read properties of undefined (reading 'data')
    at SwitchBotSensorBLE.updateFromAdvertisement (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/src/accessory.ts:91:38)
    at Noble.<anonymous> (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/src/accessory.ts:72:12)
    at Noble.emit (node:events:514:28)
    at Noble.onDiscover (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/node_modules/@abandonware/noble/lib/noble.js:218:10)
    at NobleBindings.emit (node:events:514:28)
    at NobleBindings.onDiscover (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:213:10)
    at Gap.emit (node:events:514:28)
    at Gap.onHciLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/node_modules/@abandonware/noble/lib/hci-socket/gap.js:175:10)
    at Hci.emit (node:events:514:28)
    at Hci.processLeAdvertisingReport (/usr/local/lib/node_modules/homebridge-switchbot-sensor-ble/node_modules/@abandonware/noble/lib/hci-socket/hci.js:1148:12)
[03/09/2023, 14:16:31] [Hygrometer] Child bridge process ended
[03/09/2023, 14:16:31] [Hygrometer] Process Ended. Code: 1, Signal: null

@moritzmhmk
Copy link
Author

Thanks for the feedback, this is now fixed in v1.3.3.

@bwp91 bwp91 added pending the label given to a new verification/icon request and removed awaiting-user-reply use after review has started - awaiting user to reply to a comment labels Sep 4, 2023
@bwp91
Copy link
Contributor

bwp91 commented Sep 6, 2023

/check

@bwp91
Copy link
Contributor

bwp91 commented Sep 6, 2023

(trying against plugin v1.4.0)

@bwp91 bwp91 closed this as completed Sep 7, 2023
@bwp91 bwp91 reopened this Sep 13, 2023
@bwp91
Copy link
Contributor

bwp91 commented Sep 13, 2023

@moritzmhmk apologies i must have closed this accidentally

@moritzmhmk
Copy link
Author

I wondered if closing the issue meant that verification was about to happen 😅

Is there anything left that needs to be addressed code-wise?

@bwp91
Copy link
Contributor

bwp91 commented Sep 15, 2023

Yeah sorry about this i just happened to be going through closed issues and saw yours and remembered it hadn’t been verified.
Must have just closed by mistake so apologies.
Will have a look through the checklist a bit later 👍🏻

@bwp91
Copy link
Contributor

bwp91 commented Sep 21, 2023

/check

@github-actions
Copy link

✅ Pre-checks completed successfully.

@bwp91 bwp91 added reviewed and removed pending the label given to a new verification/icon request labels Sep 21, 2023
@github-actions
Copy link

  • - The plugin must successfully install.
  • - The plugin must implement the Homebridge Plugin Settings GUI.
  • - The plugin must not start unless it is configured.
  • - The plugin must be of type dynamic platform.
  • - The plugin must not offer the same nor less functionality than that of any existing verified plugin.
  • - The plugin must not execute post-install scripts that modify the user's system in any way.
  • - The plugin must not contain any analytics or calls that enable you to track the user.
  • - The plugin must not throw unhandled exceptions, the plugin must catch and log its own errors.
  • - The plugin must be published to npm and the source code available on GitHub.
  • - A GitHub release should be created for every new version of your plugin, with patch notes.
  • - The plugin must run on all Active LTS versions of Node.js, at the time of writing this is Node v18 and v20.
  • - The plugin must not require the user to run Homebridge in a TTY or with non-standard startup parameters, even for initial configuration.
  • - If the plugin needs to write files to disk (cache, keys, etc.), it must store them inside the Homebridge storage directory.

Everything Looks Good!

@bwp91 bwp91 added verified use when a plugin meets the criteria - adds the verified badge text and removed reviewed labels Sep 21, 2023
@github-actions
Copy link

Congratulations! Your plugin has been verified.

You can now add the Verified by Homebridge badge to your plugin's README:

verified-by-homebridge

[![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)

Your plugin is now also eligible to display a ❤️ Donate button on its tile in the Homebridge UI. See https://github.com/homebridge/homebridge/wiki/Donation-Links for instructions.

If for any reason in the future you can no longer maintain your plugin, please consider transferring it to our unmaintained plugins repo. We can take ownership until another willing developer comes along.

Don't forget to join the official Homebridge Discord server, where plugin developers can get tips and advice from other developers and the Homebridge project team in the #plugin-development channel!

Thank you for your contribution to the Homebridge Community.
https://homebridge.io

@bwp91
Copy link
Contributor

bwp91 commented Sep 21, 2023

sorry for the confusion in the interim re accidentally closing the issue

nice 👍

@bwp91 bwp91 closed this as completed Sep 21, 2023
@moritzmhmk
Copy link
Author

Thank you - I just added the badge in the Readme 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
verified use when a plugin meets the criteria - adds the verified badge text
Projects
None yet
Development

No branches or pull requests

2 participants