homebridge / plugins

Information and resources for Homebridge plugins.
https://homebridge.io/w/Verified-Plugins
GNU General Public License v3.0
368 stars 17 forks source link

homebridge-spruce-irrigation #529

Closed waltmoorhouse closed 1 year ago

waltmoorhouse commented 1 year ago

Link To GitHub Repo

https://github.com/waltmoorhouse/homebridge-spruce-irrigation/

Link To NPM Package

https://www.npmjs.com/package/homebridge-spruce-irrigation

github-actions[bot] commented 1 year ago

:white_check_mark: Pre-checks completed successfully.

bwp91 commented 1 year ago

If I configure an auth token that is invalid, this crashes the plugin and sends homebridge into a restart loop:

Config:

        {
            "pollSeconds": 30,
            "runMinutes": 15,
            "lowBatteryLevel": 2.7,
            "authToken": "kjljhklhjkljl",
            "_bridge": {
                "username": "0E:7E:83:52:E6:60",
                "port": 40442
            },
            "platform": "HomeBridgeSpruceIrrigation"
        }

Result:

}
[10/04/2023, 16:28:47] [homebridge-spruce-irrigation] Discovery action completed

/usr/local/lib/node_modules/homebridge-spruce-irrigation/node_modules/axios/lib/core/settle.js:19
    reject(new AxiosError(
           ^
AxiosError: Request failed with status code 401
    at settle (/usr/local/lib/node_modules/homebridge-spruce-irrigation/node_modules/axios/lib/core/settle.js:19:12)
    at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/homebridge-spruce-irrigation/node_modules/axios/lib/adapters/http.js:556:11)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
[10/04/2023, 16:28:47] [homebridge-spruce-irrigation] Child bridge process ended
[10/04/2023, 16:28:47] [homebridge-spruce-irrigation] Process Ended. Code: 1, Signal: null
bwp91 commented 1 year ago

This is not part of the verification, but I would like to recommend a name property within the config schema, to let users change the 'name' of the plugin as shown in the homebridge log.

Something like:

  "schema": {
    "type": "object",
    "properties": {
      "name": {
      "title": "Plugin name as shown in Homebridge Log",
      "default": "SpruceIrrigation"
      },
...
waltmoorhouse commented 1 year ago

Once I add that to the config, where do I tell the logger to use it when logging? Do I do log.prefix = config.name?

bwp91 commented 1 year ago

You don’t need to do anything extra, it should use it automatically

waltmoorhouse commented 1 year ago

Ok, v1.1.1 just published should address both these items. Thanks

bwp91 commented 1 year ago

/check

github-actions[bot] commented 1 year ago

:white_check_mark: Pre-checks completed successfully.

bwp91 commented 1 year ago

Plugin is no longer crashing homebridge with an invalid token - so good!

I noticed that I still get these constant log entries when the token is invalid - so I assume some interval is running.

[11/04/2023, 18:13:39] [HBSpruce] Updating controller readings.

is this interval necessary when the token is invalid? Was just a thought of mine - is out of the scope for verification.

bwp91 commented 1 year ago

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 :heart: Donate button on it's tile in the Homebridge UI. See https://github.com/oznu/homebridge-config-ui-x/wiki/Developers:-Donation-Links for instructions.

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

waltmoorhouse commented 1 year ago

Plugin is no longer crashing homebridge with an invalid token - so good!

I noticed that I still get these constant log entries when the token is invalid - so I assume some interval is running.

[11/04/2023, 18:13:39] [HBSpruce] Updating controller readings.

is this interval necessary when the token is invalid? Was just a thought of mine - is out of the scope for verification.

If the token was ever valid, the interval will keep updating HomeKit with last known values. If it was never valid, then yeah it's a bit useless. I'll make a note to look into it for the next version.

Thanks for the help getting me verified.