I have some items which define the time for stuff like alarm clocks. Only the time is relevant, I don’t care about the date. But as there are only DateTime items I use those.
Depending on how I set the time, the date of those items is either 1970-01-01 or the date when the time was last set.
Now the trouble starts, as depending on the date the time zone is MET or MEST. When I now use the item to trigger a rule (with only the time) openhab seems to match the UTC time and depending on the timezone of the item and the current time zone the alarm goes to 1 hour too late or too early.
Is this the expected behavior? How can I use items as triggers which are not updated daily?
The time-only usages of DateTimeType can be a bit tricky and in some cases error-prone when the epoch offset becomes negative because of the difference between the system or openHAB time zone and UTC.
Which time zone have you configured in openHAB regional settings?
Which time zone is configured for your system/OS?
Do you have a time zone configured in JAVA_EXTRA_OPTS (if so, which one)?
How do you set the item state? You write “depending on how I set the time”. Perhaps you can walk us through a concrete example where you set it in some specific way and get a specific (unexpected) result.
rlk_datetime_standalone (from marketplace) uses the current date / timezone but the value also seems to be stored as UTC. So if I set the value now to 7:00 it is stored as 5:00 UTC which is 7:00 MEST but 6:00 MET
My rule trigger looks like this (created in the gui):
What is unclear to me: How are time-only items supposed to work? If the DateTime is stored in UTC they need to be updated at each daylight saving time change.
Thanks for your help!
Let’s try to isolate the problem. I know nothing about widgets/UI components, so I’d like to keep that out of the equation for now. I did the following
openHAB time zone: Pacific/Midway (GMT-11)
JVM time zone: Europe/Copenhagen
Item: DateTimeTest
Created these DSL rules:
rule "DateTimeTest set"
when
Item DateTimeTest changed
then
logInfo("TZ", "jvm.zone = {}", ZoneId.systemDefault)
end
rule "DateTimeTest triggered"
when
Time is DateTimeTest timeOnly
then
logInfo("Triggered", "DateTimeTest triggered")
end
Then did this in a karaf console (time was one minute later):
I believe only the JVM time zone is relevant here, not the time zone configured in openHAB. The “Time is” creates a cron expression using the JVM time zone:
I guess this is because the JVM time zone is used in the other end when evaluating cron expressions.
In any case, it seems to work fine for me. I suspect that you may lack to set up the JVM time zone for your Docker container.
Can you try to run these same tests and post the results?