I wish to timestamp incoming mqtt state updates (using the MQTT integration). The timestamp may be in the past as my mqtt states may be updated some time after the sensor changed, but currently the timestamp given to the sensor update is the same as the time the MQTT message was recieved. In the incoming state update from my broker the time the state changed is in the incoming packet, I just need to “insert” it somehow.
How can I apply a timestamp so that the state is registered correctly in the database, and history plots show correctly?
There are several posts in this community that ask about timestamps but I cannot find anything that answers exactly this.
Hi again, I’d like to raise this again. Is there any way to explore whether state can be “backdated” in HA? An issue when using MQTT is that data values don’t necessarily arrive in the correct order. In my application (I am actually using HA to show smart ocean sensor values in an 8 year research project ) there could also be significant latency. It may be necessary for implementing data compression protocols, to send data much later (some minutes) than when it was measured.
For this reason it would be really a great enhancement of the MQTT integration if it were possible, in the future, maybe, to specify a “measurement time” that is honoured by HA and used to timestamp the data.
Right now I don’t have a huge problem, but that will change in the future. However we do see the odd situation when messages come in from the undersea sensors out of order, and are thus difficult to plot with the standard HA history graph etc.
I found another relevant post trying to achieve similar, but I think there are other similar queries