Hi!
I’m developing a custom component and have run into an issue with batch loading. The API I use returns data in batches, each with a timestamp and a value. I can’t poll too frequently, and the list of events is too long to store in extra state attributes (it exceeds the 255-character limit for state).
Is there a way to set the state of a sensor to a value from the batch, but also set the sensor’s state timestamp to match the timestamp when that value actually occurred (not when the batch was received)? Or is there another recommended pattern for handling this kind of time series data in Home Assistant sensors?
Example of data:
[{'timestamp': '2025-06-03T22:04:12+00:00', 'weight_bowl_1': -3.0, 'weight_bowl_2': 0.0}, {'timestamp': '2025-06-03T23:29:08+00:00', 'weight_bowl_1': -6.0, 'weight_bowl_2': 0.0}, {'timestamp': '2025-06-04T01:26:47+00:00', 'weight_bowl_1': -2.0, 'weight_bowl_2': 0.0}, {'timestamp': '2025-06-04T02:44:01+00:00', 'weight_bowl_1': -1.0, 'weight_bowl_2': 0.0}, {'timestamp': '2025-06-04T04:06:41+00:00', 'weight_bowl_1': -2.0, 'weight_bowl_2': 0.0}, {'timestamp': '2025-06-04T08:16:55+00:00', 'weight_bowl_1': -3.0, 'weight_bowl_2': 0.0}, {'timestamp': '2025-06-04T17:30:35+00:00', 'weight_bowl_1': -2.0, 'weight_bowl_2': 0.0}, {'timestamp': '2025-06-04T19:10:55+00:00', 'weight_bowl_1': -2.0, 'weight_bowl_2': 0.0}, {'timestamp': '2025-06-04T19:48:33+00:00', 'weight_bowl_1': -3.0, 'weight_bowl_2': 0.0}, {'timestamp': '2025-06-04T20:51:19+00:00', 'weight_bowl_1': -1.0, 'weight_bowl_2': 0.0}]