I’d like to create a rest sensor for json values such as {“timestamp”:1676502393000,“power”:153}.
The device is documented to only update the value every 5 minutes so when HA will query the value
it will likely correspond to a datetime in the past 5min (at most).
thank you for your help but it looks like I wasn’t clear enough.
I don’t want to create another sensor for timestamp.
What I want is the last updated datetime of the sensor “Device Power” be set to the associated timestamp.
let’s say timestamp in the json refers to 14:39 and power is 153W.
if HA queries at 14:43, it will get { “timestamp”:<timestamp_for_14:39>, “power”:153 } but will report in the sensor history 14:43 for value 153VA instead of 14:39.
That’s not possible through normal means. You’d need to store the timestamp as an attribute, then run a script to update the timestamps in the database via SQL commands. Likely fragile and error-prone.
I just stumbled through this post searching to solve this same problem.
I have a feed that provides multiple pairs of type: [[timestamp],[value] ] and want the sensor to store the timestamps as they are read (every 15 minutes) from the feed source.
Has this changed in any way since this issue was first posted in 2016?
P.S:
Maybe this functionality can be achieved the other way around?
Instead of reading values from an external feed, posting the same 15 tuples (each one corresponding to one minute) to my instance of HA every 15 minutes.
Is it at all possible associate a sensor value to a timestamp before it gets written to the database? Is there any HA functionality available or is HA really only associating sensor values to the moment it receives the message?