openhab / openhab-android

openHAB client for Android
https://play.google.com/store/apps/details?id=org.openhab.habdroid
Eclipse Public License 2.0
596 stars 318 forks source link

Add configurable Offset to all DateTime items #3430

Open dilyanpalauzov opened 1 year ago

dilyanpalauzov commented 1 year ago

An openHAB-instance runs in one time zone and all DateTime items show the data local to that timezone. To be precise in my case I use as item definition DateTime rd_last_change "Last change in [%1$tH:%1$tM:%1$tS h]".

OpenHAB-Android is executed physically in another time zone. I have to perform the calculations between the timezone of where the openHAB-instance is and where openHAB-Android run, in my head.

Please add an option in openHAB-Android to convert the DateTime items’ values from the timezone, where openHAB runs, to the timezone where openHAB-Android is executed.

lolodomo commented 1 year ago

Probably something to be thought more globally and not only with a solution on each UI app.

mueller-ma commented 1 year ago

Maybe a new parameter called timezone which accepts timezones (e.g. UTC+2) and the keywords client (timezone of the client) and server (timezone of the server). The current behavior should be the default behavior.

UTC+2 works for Germany in summer, but in winter it's UTC+1. Maybe accept only the two keywords client/server at all?

maniac103 commented 1 year ago

Would you really want this to be mixed in one sitemap? I'd imagine a single option (use device time zone/use server time zone) should normally be sufficient.

rkoshak commented 1 year ago

I agree with @maniac103. It would be odd to have more than one DT on a sitemap with different TZs.

But, if you guys do go with @mueller-ma's approach, be sure to consider how users will encounter timezones in the rest of OH. In particular, with working with ZonedDateTimes in rules they get the time zone name instead of the UTC offset. Where feasible it's helpful to be consistent. It may not be feasible or even relevant here but I just wanted to bring this up as a consideration.

dilyanpalauzov commented 1 year ago

The sitemaps shall not be changed. The server knows its timezone. The client also knows its timezone, or can be set by an option. What is missing is to convert from the timezone of the server to the timezone of the client for DateTime items.

mueller-ma commented 1 year ago

What I'd like about the Sitemap expansion is that the setting is "hidden" from a regular app user. But adding a setting in the app seems fine to me as well.

dilyanpalauzov commented 1 year ago

I do not understand how is the mentioned Sitemap expansion supposed to work.