Timestamp difference between log and MainUI

He guys,
Running OH3 for a while (LXC container, debian) and all working well.
Just added a DIY waterflow sensor which, besides waterflow rate etc., also send me an epoch time formatted timestamp via MQTT (example: 1616340606).
I created the respective channels and items, whereas it seems that, while the log shows the correct timestamp in my time zone (GMT+7 Asia/Bangkok), the MainUI shows a different time zone.


There is a difference of 7h, which is the GMT+7 somehow.
OH3 is set in Settings to Asia/Bangkok time zone and I added (after finding some similar threads) also JAVA_ARGS=-Duser.timezone=Asia/Bangkok to /etc/default/openhab.

Any pointer what I am missing here?

As far as I understand the value of your sensor in the logging is formatted wrong. It does not show the correct timezone value ( +0000 ). +0000 stand for UTC / GMT.
This is why moving UTC time to your timezone ( GMT+7 ) ends up at 22:30 your time.

1 Like

Thanks, that helps.
My ESP8266 code gets the timestamp via unsigned long epochTime = timeClient.getEpochTime(); whereas it also includes a time zone adjustment of const long utcOffsetInSeconds = 25200; to account for it (which then shows the right time). Assume though that the full thing is not send to MQTT then?
Have to see how I can add a time zone identifier I guess, even though the epochTime already is in the correct one.

That’s the mistake really. You correct UTC to local zone, but send over MQTT with no zone indicated. openHAB parses that thinking it is UTC - because no zone.
If you just send raw UTC it should all work out.

Note that your Item doesn’t really represent “last seen” so far as openHAB is concerned, it’s just some data that was sent.

1 Like

Thanks, was thinking the same and removing the correction from my esp code. Will try once I get a chance tomorrow. Last hurdle to deploy the sensor.
I only call it last_seen as I want a record of when it last was able to get a mqtt msg through as my esp code goes into deep sleep and I am still testing how long batteries will last.

Just to update, I changed the epoch offset and it works as intended.
Only drawback is though that the log now obviously shows a different time (sense time zone), whereas that is ok for now (not that important to have accurate log reading on this sensor as long as the item is updated).
Let’s see how long the batteries will last :slight_smile:.