Integrate non-realtime data with HA?

I see I can use the API to POST data to ‘create’ a sensor that is then visible in HA. That’s great, but that seems limited to data being recorded at the time it is posted.
I understand this is an IoT solution so we’re recording data in real time, but I am getting data from an API (from my water service) that is hourly, but only updated twice a day, so in short, at 12:00AM and 12:00PM, I get 12 hours of data. I would love to be able to integrate this as a ‘sensor’. Even with at most 12h delay, it is still useful to set triggers to detect leaks or daily over-use.

So the question is: Is there a way to post non-real time data to HA and retain the timestamp?
Thanks

Only HA way is the spook integration.

Or this:

1 Like

Hi!, I’m the auhor of “Historical sensors”.

Feel free to ask any questions about how to integrate it into your project.

Currently I’m using it in one integration (ideenergy) so documentation and API may be incomplete or too much influenced by ideenergy but the goal it’s to make it flexible enough for general usage.

1 Like

Thanks @ldotlopez
I got so far as getting some data into HA, but I’m not sure if it updates, or if I need to add the DataCoordinator part.

I note that v2.0.0a0 is not on Pypi even though it is referenced in the ideenergy. I’m using 1.0.1 and it’s fine. Not sure what improvements v2 brings.

The example in the historical-sensors repo didn’t work for me on its own. it never showed as a sensor until I added the setup_platform function.
The ideenergy integration is a better example, although it is more complex and overkill for my use case.

Question I have:
Ultimately I’d like to setup alerts based on computations on the data (i.e. leak detection), however I’m not sure it is possible as is since it seems like alerts are based on the ‘real-time’ sensors changing state or reaching some threshold, but since this sensor is always ‘unavailable’, I guess that would not work, and it seems like I’m going to need to integrate the alerting within the data ‘update’ functionality. Is that a fair assessment?

Hi @Streamnsight
Sorry about not answering, somehow I missed the reply notification…

I note that v2.0.0a0 is not on Pypi even though it is referenced in the ideenergy. I’m using 1.0.1 and it’s fine. Not sure what improvements v2 brings

I’m dealing with some complicated issue in the 2.0.0+, no significant improvements yet. Major version bump comes from an infortunataedly typo in some API

The example in the historical-sensors repo didn’t work for me on its own. it never showed as a sensor until I added the setup_platform function.

Did you add the “delorian” integration? May be I missed something from the last HomeAssistant API, can you make a PR?

Question I have:

Yes, historical sensors are always unavailable by design, any other valid state will mess up history and statistics.

My guess:

  • Implement the historical methods to store historical consumption water
  • Use the update/async_update to query recorder, check for leaks and reflect in state