homebridge / verified

Plugins Verified by Homebridge
https://homebridge.io/w/Verified-Plugins
GNU General Public License v3.0
366 stars 17 forks source link

Verification Request: homebridge-sleepme #757

Open LukeWinikates opened 2 weeks ago

LukeWinikates commented 2 weeks ago

Plugin Name

homebridge-sleepme

Link To GitHub Repo

https://github.com/LukeWinikates/homebridge-sleepme

Plugin Icon (Optional)

No response

The plugin does not offer the same nor less functionality than that of any existing verified plugin.

🟢 Yes

The plugin successfully installs and does not start unless it is configured.

🟢 Yes

The plugin does not require the user to run Homebridge in a TTY or with non-standard startup parameters, even for initial configuration.

🟢 Yes

The plugin does not contain any analytics or calls that enable you to track the user.

🟢 Yes

If the plugin needs to write files to disk (cache, keys, etc.), it stores them inside the Homebridge storage directory.

🟢 Yes

The plugin does not throw unhandled exceptions, the plugin must catch and log its own errors.

🟢 Yes

More Information

This is my first Homebridge plugin, and is quite simple. I'd love to receive the feedback that comes with the verification process and improve the plugin accordingly. It's for a niche family of devices, and I don't expect the utilization to ever be very high.

I answered the "The plugin successfully installs and does not start unless it is configured" question as "yes", but I'm not sure I understand what "start" means in this case. I'd be happy to add logic to short-circuit startup if no API keys are configured. As is, if unconfigured, the plugin would find no API keys at startup and wouldn't find anything to start up and loop over.

The device this plugin supports has a water tank, which gets used up over time and needs to be refilled. I wanted to expose this information in the plugin, but the only accessory/characteristic that mapped at all to this was a "battery". I'd love any suggestions for a better way of handling that, if possible.

github-actions[bot] commented 1 day ago
bwp91 commented 1 day ago

Hi @LukeWinikates

I have installed the plugin and set up as a child bridge. I have the following (minimal) config:

        {
            "platform": "SleepmeHomebridgePlugin",
            "_bridge": {
                "username": "0E:43:1A:1A:1E:EE",
                "port": 37163
            }
        }

This is leading to a crash loop with the following message:

[22/09/2024, 09:41:18] [homebridge-sleepme] Executed didFinishLaunching callback
TypeError: Cannot read properties of undefined (reading 'forEach')
    at SleepmePlatform.discoverDevices (file:///usr/local/lib/node_modules/homebridge-sleepme/src/platform.ts:61:26)
    at HomebridgeAPI.<anonymous> (file:///usr/local/lib/node_modules/homebridge-sleepme/src/platform.ts:40:12)
    at HomebridgeAPI.emit (node:events:519:28)
    at HomebridgeAPI.signalFinished (file:///usr/local/lib/node_modules/homebridge/src/api.ts:244:10)
    at ChildBridgeFork.startBridge (file:///usr/local/lib/node_modules/homebridge/src/childBridgeFork.ts:193:14)
[22/09/2024, 09:41:18] [homebridge-sleepme] Child bridge ended (code 1, signal null). The child bridge ended unexpectedly, which is normally due to the plugin not catching its errors properly. Please report this to the plugin developer by clicking on the 'Report An Issue' option in the plugin menu dropdown from the Homebridge UI. If there are related logs shown above, please include them in your report.

Here you need to check that config.api_keys exists, and is an array!

https://github.com/LukeWinikates/homebridge-sleepme/blob/8aa271badfea4d07d20c6fe63dd6c8b24189f725/src/platform.ts#L61

LukeWinikates commented 1 day ago

Thanks @bwp91 - I'll get this fixed soon.