Insert state at specific timestamp

I am looking develop an integration with an API, but it provides data in a somewhat bulk format. Data points are every 30 minutes, but it’s only updated once per day. For example, at a specific time each morning, the whole data set for the previous day is uploaded and there are 48 new data points available.

Similar questions have been asked a few times throughout the forum:

The response always seems to be that a combination of sensors/attributes need to be used. That’s not ideal though. What would need to be developed to do this properly? You can see by the questions that the use cases are quite varied (battery powered data logging, weird online APIs etc).

Maybe a new Sensor platform that accepts a timestamp with a state update? So when it writes the state to the database, it can specify the time, rather than it using the insert time.

9 Likes

Any thoughts on this?

I’m looking to integrate a platform into the Energy dashboard. The platform only delivers data once per day but it’s time stamped every 15-30 minutes. There must be a way to insert data at a specific time?

Same use case here. I can fetch my meter readings from the utility company API, but the readings are delayed by several hours. They come with timestamps, but when I push messages to the MQTT sensor they use “now”, which is invalid. I don’t know how to get accurate energy readings with this limitation. I need to use the timestamps that come from the API meter readings.

it’s not so simple if you want true time stamps I have been importing steps from apple health and the data arrives for the current day even if its hours later when it hits HA its good enough.

What we actuaally want is something like this Exporting Apple Health Data to Home Assistant - SixtyMeters - Smart Home

1 Like

Yes, I also use InfluxDB alongside Home Assistant. It’s very handy to be able to store masses of time stamped data. Influx doesn’t require the timestamp to be the time of insertion either, I wonder whether the whole backend of Home Assistant could be ported to something more flexible.

It’ll be database specific, but just execute the insert statements and supply the timestamps

E,g,

insert into states …

Integrations can inject timestamped historical data, no custom sql required either. There’s an API in core for this integrations can use. And there are two integrations in core making use of this API you can use as a reference. See my post here for more info:

5 Likes