I have Openhab 3.3 Release running in docker container. I have a OpenHab Android App in my phone, and I want to create a rule based on Alarm time.
I can see that Alarm time is transfered to OpenHab Item. It is in UTC time.
In documentation is written, that trigger shoud be: “Time is AlarmClock”
I dont use file based rules, so I tried it using UI (see bellow). It is working, but trigger is fired in wrong time. It looks like it is comparing OpenHab Local time with Items time in UTC.
I checked my timezone in OpenHab console (inside a docker) and it is correct (CET).
Does anybody have some idea what I am doing wrong?
logInfo("alarm info", "android_events.rules: Android Alarm:")
if (HynekAlarmClock != UNDEF && HynekAlarmClock != null) {
logInfo("alarm info", "android_events.rules: Android Alarm: Next Alarm: {}", (HynekAlarmClock.state as DateTimeType).toLocaleZone)
}
This will convert HynekAlarmClock Item to local time, but it will not solve the problem, that rule is triggered at UTC time. Only what I can imagine is that I will create another Item HynekAlarmClockLocalTime . And I will have two scripts. First ony to convert UTC to Local (HynekAlarmClock → HynekAlarmClockLocalTime). Second which will trigger at HynekAlarmClockLocalTime time a do the job.
In regional settings I have (MainUI->Settings->Regional settings):
Timezone set to GMT+1
Region/Country not set
In folder conf/services/ I dont have file like you mentioned(?). In runtime.cfg are all lines comnented (no configuration there).
I am trying to avoid file based configuration if possible.
Sorry, not that was part of the URL of the UI under Settings → System Services → Regional Settings but you still found it (documented at Settings | openHAB … sorry that these have not been documented in particular as I hadn’t had the time yet).
Not sure if the Region has an impact (I doubt it) and the timezone looks good to me (same like mine).
OK, and I assume in this case the time you actually want is 04:00 in your timezone.
You’ll have to file an issue with the android app if that’s the case. It’s explicitly setting the timezone meaning that instant in time is exactly 04:00 GMT. If it sends the timezone at all, it should send it using the timezone for which the alarm is set, not just assume GMT. Or it should send it as a local datetime without the timezone at all in which case your system’s timezone will be assumed.
It might be the case that there is a bug in the Time is Item rule trigger that is causing it to lose the timezone or something like that.
Based on what you are describing, this is not really what’s happening. The Android app is reporting 04:00 GMT. That is the same instant in time as 05:00 GMT+1. So it’s not triggering at UTC time, it’s ignoring the timezone returned by the Android app and triggering at 04:00 GMT+1.
The root problem here is OH is ignoring the timezone for the trigger.
However, you are running a really old version of OH at this point and there has been a lot of work and changes that are related to this feature in OH. So I’d say the first thing to do is upgrade to OH 3.4 and see if the problem persists. If so, file an issue on openhab-core describing the mishandling of the tiemzone.
I vaguely remember there being an issue on this though so I’m pretty confident that this was a bug that has already been fixed.