I have an Item that gets populated with a DateTime in UTC, and I have it displayed in OH UI in local time - all is fine.
I however wish to send the displayed value, in local time via MQTT, but when i try this, the value that is sent is the raw DateTime value, ie. UTC, and not local time. Since I live in a country with daylight savings time, i cannot simply add a certain amount of hours.
I have tried 2 solutions but failed:
-
Perfom some transformation on the outgoing value - I cannot find any way to edit the timezone used in the state formatter - if this is a possibility it would probably be the best/easiest
-
The alternate method I tried was to make a proxy item that is updated along with the original item, but I have been unable to find a way to apply the correct time corrections to the proxy item - here is the rule i have tried:
val localtime = (cheapestPriceTime.state as DateTimeType).toLocalDateTime()
cheapestPriceTime_ProxyItem.sendCommand(localtime)
but this only adds the time zone difference, but does not change the time itself to reflect the local time. Due to DST I cannot just put a fixed value.