Pyhiveapi
Pyhiveapi copied to clipboard
[FEATURE] Add thermostat temperature history
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
I would like to access my thermostat's temperature history. This is available from the following Hive beekeeper API endpoint :https://beekeeper-uk.hivehome.com/1.0/history/heating/<thermostat_id>
with the following parameters.
-
start
: Timestamp as milliseconds since unix epoch -
end
: Timestamp as milliseconds since unix epoch -
timeUnit
:YEARS
,DAYS
,HOURS
,MINUTES
orSECONDS
. -
rate
: Integer value -
operation
: I can only find one valid valueAVG
, which is the default if this parameter is omitted
I'm happy to make this change and submit a PR. @KJonline Do you have any thoughts about where this best fits in the pyhiveapi
API structure?
Additional context
- I have not seen any records closer than ~5~ 2 minutes apart and its not unusual for adjacent records to be more like 30 minutes apart. No interpolation occurs when the requested granularity is finer than the data supports. In this case the raw records are returned.
- Data seems to be go back to 00:00:00 GMT on 01 Jan 2019. I was able to query back this far around 5-6am on 30 Dec 2021 and queries with start dates a little before this returned with 00:00:00 on 01 Jan 2019 as the earliest entry. [Edit: this changed to 23:00:00 on 31 Dec 2018 after a few minutes and has stayed there for about 30 minutes]
- I want to say that if you query outside this range you get a
404 - Not found
error, but I think it may be more nuanced than that. I was able to query with some start dates prior to the earliest returned date and setting the end date in the future did not give an error. I also had some dates intermittently give me the 404 error (25, 26, 27 Dec 2020). I can't be sure I was querying with single day resolution when I got those intermittent 404 errors, however I think the 404 error may occur if the query has had to look at more than about a year's worth of data. Perhaps there is some kind of internal timeout that gets translated as "no results" rather than a server error?
I'm also happy to extend the Hive Home Assistant Integration to expose this new functionality, though I'll need some time to get my head into the codebase.
@martintoreilly as a starter for 10 I would build the api and then we can see how to can be utilised elsewhere. The key with this library is to make sure it’s compatible with 4 use cases
- through home assistant
- using a pyhiveapi as home assistant does but without home assistant
- async raw api
- sync raw api
with regards to unasync this only works on the main code not the api code so you do have to code twice as unasync doesn’t work well with sync and async http libraries