DateTime Item and Timezone in openhabian

Hi,

I have a strange problem to get the correct DateTime displayed… I’m on the latest snapshot #1597 and dont know if its related to this or something else…

Maybe someone can help me with that.

I grab some data via the HTTP binding:

DateTime SPPet_2_PositionSince "[%1$tA, %1$td.%1$tm.%1$tY %1$tH:%1$tM]" {http="<[surehub:600000:JSONPATH($.data[1].position.since)]"}
String SPPet_2_PositionSinceString "[%s]" {http="<[surehub:600000:JSONPATH($.data[1].position.since)]"}

and this gives me:

2019-05-23 11:27:56.678 [vent.ItemStateChangedEvent] - SPPet_2_PositionSince changed from NULL to 2019-05-23T08:27:54.000+0200
2019-05-23 11:27:56.745 [vent.ItemStateChangedEvent] - SPPet_2_PositionSinceString changed from NULL to 2019-05-23T08:27:54+00:00

but in the Sitemap it shows me the formated Date with 2 hours behind…
2019-05-23%2011_53_02-Window

The correct time should be 10:27
Date and Timezone in PaperUI and openhabian config are both set and correct.

anyone have a hint for me how to display the correct time?

Thanks
/Holger

IMHO this time is coming that way from the http request (see the log entry), I’d start looking there.

yeah true…the String item is correct… but the DateTime item shows also the +2 TimeZone… but its not displayed correctly in OH…

Thats whats confusing me…

My GUESS is the http request returns a string, can you configure those seturns at the origin?

No, i cant change the output…

I found another interessting thing…

If i user the String item in HABPanel like:

{{itemValue('SPPet_2_PositionSinceString') | date:"EEE HH:mm"}}

i’ll get the correct datetime with correct TZ (10:27) as it should be…


So the question still is, why cant i transform the http JSONPATH response from the string into a DateTime Item Type… hmmm.

Your stringitem shows the source sending +00:00, which seems to be wrong, assuming your timezone is not UTC.

Yeah thats true and correct…

Maybe i dont understand it right how OH handles the dates…
I try to explain again:

The source is saving the time in UTC +00.00 (i cant change that)
In the official App you have to set the correct Timezone (mine is UTC+2) and now you have in the App the correct time and date…

Now i want to have the same in openhab… In OH i have set the +0200 TZ and also OH and Raspberry is showing me the correct DateTime in the correct Timezone…

I thought i can use the http Json response (2019-05-23T08:27:54+00:00) from the API and convert it with a DateTime Item easily to the correct timezone… but somehow OH does interpret this “false”?!

Thats why i used for testing the clean json string and the datetime item…

In the Log i see that the DateTime Item SPPet_2_PositionSince uses at the end the +0200 (assuming its the Timezone) so 08:27 + 2 = 10:27 but in the sitemap i only get 08:27 for this item…

And my question is, do is something wrong, or how can i get the original UTC +0 time to my current timezone.

Thanks for all you help. :slight_smile:

1 Like

thanks @Syn

this works! but what i dont like… i need to add rules for this… what i dont like in this case…

I was hoping to avoid that… but it seems that there is no other solution… :frowning:

anyway, thank all for yur help :slight_smile:

Maybe you should have a look at state profiles https://www.openhab.org/docs/developer/transformations/#state-profiles
I haven‘t worked with them yet, but it looks like, that’s the tool your looking for.

1 Like

Thanks for the link… but i dont understand this and how to use… thx anyway :slight_smile:

i opened a issue on github… because i think this might be a issue…