Skip to content

Conversation

@srescio
Copy link

@srescio srescio commented Sep 22, 2024

related to andrewleech/uhoo-homeassistant#5

uhoo API has probably some kind of cache related to the userSettings object that may get cleared after some time,
reason why some people have been experiencing the issue and some not,

in my case the object was there but empty, after going into my uhoo mobile app and changing the temperature unit in settings the next calls contained again the temp property, same for all the other units

while this action makes the integration work again, we don't know when/why the property may be cleared again,
the temp unit is not reported anywhere else, but among other things added there is a "treshold" property, which contains the following:

      "threshold": {
        "co": { "aMax": 100, "aMin": 0, "max": 70, "min": 35 },
       ...
        "temp": { "aMax": 104, "aMin": 32, "max": 78.8, "min": 69.8 },
      },

while min and max change based on the safety treshold chosen in the app for a given value, aMax and aMin are fixed and represent the overall range, values change only based on the unit,
for celsius it returns the following:

      "threshold": {
        "temp": { "aMax": 40, "aMin": 0, "max": 26, "min": 21 },
      },

therefore the threshold.temp.aMax can be used to reasonably infer the selected unit for temperature as fallback when the explicit value is missing in userSettings

@andrewleech
Copy link
Owner

Great finding and thanks for putting together this fix! While it's annoying their api is inconsistent, this seems a very pragmatic workaround. I'll test it out myself and merge it asap.

Thanks for the other cleanups too - I originally assumed this fork would be just for submitting pr's upstream but that seems a long way in the past now...

@srescio
Copy link
Author

srescio commented Sep 23, 2024

⚠️ there is a dependency conflict with yarl version when attemptint to install everything together in the HA component ⚠️
trying to figure out how to have them play together...

@srescio srescio marked this pull request as draft September 23, 2024 21:08
@andrewleech
Copy link
Owner

andrewleech commented Sep 24, 2024

Hi @srescio yeah I'm changing my ha plugin to use git subrepo to manage essentially a snapshot of the library here in the plug-in codebase, I've run into dependency issues like this on other ha projects that can be very hard to resolve otherwise.

@srescio srescio marked this pull request as ready for review September 29, 2024 09:30
@srescio
Copy link
Author

srescio commented Sep 29, 2024

@andrewleech finally had it work in running core fetching data,
you can check with this branch/PR on the component andrewleech/uhoo-homeassistant#6

@andrewleech
Copy link
Owner

Hi @srescio thanks again for this and sorry it's taken me a while to get to it. I finally got my local install set up to test this and it does indeed fix the data fetching error (my uhoo had stopped receiving data a few weeks ago too).

I'm thinking I might rename this package to just pyuhoo2 so that I can publish it to pypi and reference it easily from my updated ha plugin, that's probably easier to maintain than my plan to keep a copy of this in the ha plugin with git subrepo.

@andrewleech andrewleech merged commit 1e39712 into andrewleech:client_id Oct 13, 2024
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