Open pponce opened 3 years ago
Same here... hoping the dev is still maintaining this, else will have to pin to an older version of Homebridge until someone can fix it
[homebridge-rachio-platform] This plugin generated a warning from the characteristic 'Active': Unhandled error thrown inside read handler for characteristic: Error: characteristic value expected number and received object at Characteristic.validateUserInput (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1929:17) at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1490:24 at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:9:18 at Characteristic.<anonymous> (/homebridge/node_modules/homebridge-rachio-platform/index.js:300:13) at Characteristic.emit (events.js:315:20) at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1466:14 at new Promise (<anonymous>) at Characteristic.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1464:12) at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27) at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57) at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75 at new Promise (<anonymous>) at Object.__awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16) at Characteristic.handleGetRequest (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:632:24) at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1507:27) at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27) at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57) at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75 at new Promise (<anonymous>) at Object.__awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16) at Bridge.Accessory.handleCharacteristicRead (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js:1273:24) at _loop_1 (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1449:12) See https://git.io/JtMGR for more info.
Same issue here.
It seems to be working again with the update to Homebridge 1.3.1, likely due to this change:
- Automatically correct bad characteristic values provided by plugins in more cases, this should fix the vast majority of problems users were facing after upgrading to v1.3.0.
However, there are still messages in the log telling that the Rachio plugin is generating warnings around the InUse and Active characteristics "expected a number and received object". So, it would still be nice if @kcharwood could update the code to be fully compliant.
I may have spoke too soon... in less than an hour I used up my 1700 API calls on the Rachio service, so I'm guessing these warnings are causing the plugin to make more requests than normal/necessary. Can anyone else confirm similar behavior?
I put it this in a disabled block In my config.json for now. Hope someone with more skills than i can take on fixing this one for homebridge 1.3.0 and up.
Library could use a bit of cleanup/modernization, but this patch should resolve the immediate problem. ☝️
@leehendricks this is great... is there a branch we can use in the interim until @kcharwood can approve the PR? Any tips on how to do that in homebridge would be helpful
Yes, I forked the original:
https://github.com/leehendricks/homebridge-rachio-platform
My master branch has the above fixes.
@leehendricks i just installed your fork. I am able to control the sprinklers but I do have an issue. All my zones show running after a little while even though they are not. I can manually stop and start them and then stop them. But then after a bit they all show as “running”.
@pponce Good catch. Needed to wait on promises to resolve to determine if zones are running. Give it another shot.
The plugin is making a lot of unnecessary Rachio API calls. Feels like a solid refactor would cache the active zone for a given device rather than querying every time.
@leehendricks yes I often hit my limit of 1700/day from Rachio's API
Forgive me, but what is the process to configure Homebridge to use your branch? I am running HB on a Pi using the HB_Pi distro.
@stevehoek Not familiar with running homebridge on a Pi, but you may need to do a little surgery to replace the original index.js
with the version from my fork.
On my mac, it's here:
/usr/local/lib/node_modules/homebridge-rachio-platform/index.js
If the original author doesn't respond to the PR, I'll figure out how to register a new homebridge plugin.
Maybe there's an easy way to tell homebridge to pull from
https://github.com/leehendricks/homebridge-rachio-platform
vs.
https://github.com/kcharwood/homebridge-rachio-platform/
?
@leehendricks thanks for the help... It worked for me to do this from my node_modules folder
npm install https://github.com/leehendricks/homebridge-rachio-platform.git#fixCharacteristicValues
@stevehoek Ah, nice! Wasn't sure how homebridge would handle the conflict with multiple plugins with the same name. Did you have to remove the original?
@leehendricks nope!
if you have any time to put even a quick and dirty cache in to reduce API calls, I think that would let us get alot more mileage out of this plugin if the original author is no longer involved...
Already working on a refactor branch. Shhh...don't tell my Day Job Boss, LOL.
testing now and will report back on the "running" issue. FYI: to install i just run npm install -g leehendricks/homebridge-rachio-platform
@leehendricks so i re-installed but had the same "running" issue. was there a specific branch I needed to install to test the change?
scratch that. trying this now. npm install -g leehendricks/homebridge-rachio-platform#fixCharacteristicValues
works well. thanks for working on this for the community!
@stevehoek Quick and dirty cache:
npm install -g leehendricks/homebridge-rachio-platform#cacheActiveZones
Sorry, I must be a total dolt. Do I need to remove the old plugin when trying to install this branch? I'm getting the following error:
pi@RaspberryPi:~ $ sudo npm install -g leehendricks/homebridge-rachio-platform#cacheActiveZones npm ERR! code 128 npm ERR! command failed npm ERR! command git ls-remote ssh://git@github.com/leehendricks/homebridge-rachio-platform.git npm ERR! /bin/bash: /root/.bashrc: Permission denied npm ERR! Warning: Permanently added the RSA host key for IP address '140.82.112.4' to the list of known hosts. npm ERR! git@github.com: Permission denied (publickey). npm ERR! fatal: Could not read from remote repository. npm ERR! npm ERR! Please make sure you have the correct access rights npm ERR! and the repository exists.
npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2021-03-17T14_28_38_102Z-debug.log
@swamplynx You could try it fully qualified like @stevehoek did:
@leehendricks thanks for the help... It worked for me to do this from my node_modules folder
npm install https://github.com/leehendricks/homebridge-rachio-platform.git#cacheActiveZones
@stevehoek Quick and dirty cache:
npm install -g leehendricks/homebridge-rachio-platform#cacheActiveZones
@leehendricks that is great, thank you for taking time for this away from the day gig :) I have installed it and will see what comes tomorrow. I have already hit my 1700 API call limit somehow. I'm in Michigan and I'm not even watering right now! Maybe because I keep a tab open with Homebridge all the time?
I notice you say it caches "active" zones... does that mean ones that are enabled in HomeKit, or active meaning actively watering? Because if it is the latter it probably won't help me...
"Active zones" is a bit of misnomer. Really only applies if you have more than one Rachio tied to your API key. For 99% of folks, there will be one zone active.
Previously the plugin was making API calls to Rachio every time homekit wanted to know the state of all zones. (2 calls for each zone.) Now I determine the active zone upon initialization, cache it, and update the cache whenever the active zone changes.
I bet homekit periodically asks for the state of your devices if you have a tab (or the Home app) open all the time. Let's say you have 10 enabled zones. That would be 20 API calls. Total calls for the day dependent on how often homekit asks for state.
@stevehoek how do you check on how many api calls you have used?
@pponce I received an error message in the Homebridge console stating that I had surpassed my daily API limit of 1700, but I know of no other way to check how man API calls my token was used for in any given period of time. Most web service providers would have a way to do this, but I'm doubtful Rachio offers such insight.
[17/03/2021, 13:49:23] [Rachio Controller] Failed to refresh devices. Error: 1700 daily calls rate limit exceeded. [429] GET https://api.rach.io/1/public/person/info at Request._callback (/usr/local/lib/node_modules/homebridge-rachio-platform/node_modules/rachio/lib/datastore/DataStore.js:25:21)
@leehendricks your branch for caching Active Zones seems to work well for my API call problem. Been running for 36 hours with no issue. Thanks again!
I do see these messages. I've seen them in the past, so I think they are unrelated to your changes. Do any of you guys see this kind of message from time to time?
[18/03/2021, 22:40:57] [Rachio Controller] Webhook Recieved from an unknown external id Homebridge-3ea94f2f-f005-4cc7-91e0-7be28150fe6d
[18/03/2021, 22:40:57] [Rachio Controller] Unhandled event type DEVICE_STATUS
@stevehoek Glad to hear it. Looking at my logs with debug turned on, the state of each zone (watering or not) is queried many times per hour. Cache is way to go here for something that rarely changes.
Didn't touch the webhook logic, but it could probably use another look.
Rachio retains all the webhooks you've ever registered for a given device (i.e., Rachio controller), unless you explicitly delete them. So if you've made any changes to your config (specifically, the name
in your Rachio platform section), you can end up with unused, unnecessary webhooks. (I had around 10.) And these lead to those unhandled event warnings. The plugin only needs one webhook per device.
Feels like the solution would be to delete any previous webhooks, but what if you're using them for some other non-Homekit purpose? Maybe that could be a flag in the options (clearPreviousWebhooks
), false by default.
@leehendricks that is good info. I'm not sure I ever renamed my Rachio platform, but for sure it has some orphaned hooks by the behavior I'm seeing. An option like that would be useful for sure.
Does it re-use a previous hook from one session to another just by the name being the same?
@stevehoek Yes, it was attempting to reuse webhooks with the same name, so I'm not sure why the cruft was building up.
New clear_previous_webhooks
option plus a major refactor:
npm install https://github.com/leehendricks/homebridge-rachio-platform.git#cleanupWebhooks
@leehendricks thank you so much for picking this up and getting it working again!
@stevehoek Yes, it was attempting to reuse webhooks with the same name, so I'm not sure why the cruft was building up.
New
clear_previous_webhooks
option plus a major refactor:npm install https://github.com/leehendricks/homebridge-rachio-platform.git#cleanupWebhooks
I installed it this morning and set the new flag... will monitor and report back if I notice anything irregular.
Thanks again @leehendricks !
Haven't managed to install this fix on my pi homebridge installation. SSH from Mac. Any tips for the less savvy? Best would be to update via homebridge UI for us dummies. Thanks for the great plugin btw, much appreciated.
@GeezusChrotch Solid GitHub handle. 💯
Registered my forked version of the plugin with npm, so now you should be able to install/update via the normal home bridge channels (Homebridge Config UI X, etc.)
@leehendricks thanks again for the work you did on this. I've been running your fork for awhile now with no issues. I do see this message occasionally in the log... not sure if it is something new or in the original code: Unhandled event type DEVICE_STATUS It does not seem to cause any issues.
Thank you for all the work you put into this. I was able to configure this - however I am seeing a duplicate of the controller and zones (for a total of 16 zones and 2 controllers). I tried clearing the homebridge cached devices in case it was a remnant of the previous attempt at installing the older plug in but the zones reappear. Not sure what I may have done incorrectly :/
Nevermind
Thank you for all the work you put into this. I was able to configure this - however I am seeing a duplicate of the controller and zones (for a total of 16 zones and 2 controllers). I tried clearing the homebridge cached devices in case it was a remnant of the previous attempt at installing the older plug in but the zones reappear. Not sure what I may have done incorrectly :/
Well nevermind - I realized it's not a duplicate...but it's a second unit I have on my account that I plan on installing at my parents' house. Is there a way to ignore it? Eventually I plan on turning it over to them account-wise. But I was hoping to maintain shared access...unless it messes with my Homebridge!
All zones showing "no response" after install of homebridge 1.3.0