Sending data to HA via REST API, how can I set last_updated time?

I have a python script that collects data and sends it HA via REST API using the states POST command. What I don’t understand is if I can set the time that the state is valid? In my case the actual value isn’t updated often, and would like to just send the state value, and its time it was updated. And allow HA to just ignore it if it is a duplicate. Is this possible with the REST API?


HA does that on its own. If you post multiple time the same state, it will ignore everything but an actual state change.

just to be clear, if I send a state with same number i.e. 32080 gallons, it will ignore if I send that exact same number again?

Don’t take my word. Just try it …

In the State machine if the whole state (including attributes) are the same as previously it doesn’t see it as something changed and thereby is what you would refer to “ignoring” it.

Some solve this by setting a last_updated attribute on the sensor which is then updated with whatever you want and thereby it’s a State change as attributes are part of State