Alarm Clock from Android App is in UTC + Alarm rule based on it

Hi,

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?

Thanks.

Rule:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: HynekAlarmClock
    type: timer.DateTimeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: LivingRoomLightSwitch
      command: ON
    type: core.ItemCommandAction

Console time:

                           _   _     _     ____ 
   ___   ___   ___   ___  | | | |   / \   | __ )
  / _ \ / _ \ / _ \ / _ \ | |_| |  / _ \  |  _ \ 6
 | (_) | (_) |  __/| | | ||  _  | / ___ \ | |_) )
  \___/|  __/ \___/|_| |_||_| |_|/_/   \_\|____/
       |_|       3.3.0 - Release Build
admin@home:~ $ date
Use '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
To exit, use '<ctrl-d>' or 'logout'.
Wed 15 Feb 19:57:34 CET 2023

In what format is it?

Can you try this one which is the code I am using.

logInfo("alarm info", "android_events.rules: Android Alarm:")
if (newState != UNDEF && newState != null) {
  logInfo("alarm info", "android_events.rules: Android Alarm: Next Alarm: {}", (newState as DateTimeType).toLocaleZone)  
}

Hi. Thanks for feedback.
Here:

2023-02-17T04:00:00.000+0000

Hi. Thanks for feedback.

I have to modify it like this:

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.

Is this how you have it?

I am not sure whether it makes a difference but just to check it: how is your timezone setting at …/settings/services/org.openhab.i18n ?

Hi. This should be a file?

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).

me too :wink:

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.

Hi.

I want to have a local time 5:00.

  • In my phone is GMT+1. Alarm is set to 5:00.
  • Openhab item receive 4:00 GMT+0.
  • Openhab is GMT+1.(But rule will trigger at 4:00 GMT+1)

I found old issue in Android App repo:

They are fine with UTC time. So, I dont know if new request will solve something.

I think that Rule Trigger is not ok.
Because 5:00GMT+1 is equeal to 4:00GMT+0, no?
Now it will trigger when: Openhab 5:00GMT+1 and Item 5:00GMT+0.

It look like somewhere in rule trigger comparison timezone is lost. Normaly I would do it:

if(DateTimeA.ToUtc() == DateTimeB.ToUtc())
{
}

Thanks for help.

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.

Thanks. I will try.

After upgrade it work as it should. Thanks.
Also upgrade was really fast (docker image). I am supprised!

Hi everyone,
I’ve got a similar problem. I am on 3.4.2 and it is not fixed for me.
Any idea what the problem is?

Opehab got the correct timezone: GMT+1
My mobile phone got the correct timezone: GMT+1

Within the app I can see that the logged time for the last state post is the same as my mobile phone. This is ok.
But the alarmtime is one hour wrong.

Any idea how to fix this?

Thanks!

Hi. Do you really have 3.4.2? Mine look different, and I see everywhere local time. You can also try OpenHab beta android app.

Yes, version is 3.4.2 and the app version is 3.3.1

So everthing is up to date.

Still not working for me.

I need to bring this topic up again.
I am running openhab 4.0.2 (raspberry pi).

When I use the Main UI to trigger the rule based on time sent by openhab android app, everything works like a charm.

But using a dsl-rule

rule "Lichtwecker"
when
    Time is OnePlusAlarmClock   
then
    logInfo("Lichtwecker", "Starte Lichtwecker-Logik...")
    EG_Esszimmer_Light.sendCommand(ON)

end

Its not working. Alarm is set to 6:00 in the morning.

Anyone has an idea?

The same problem on 4.0.3, android app 3.7.0
My local time is UTC+3

In openHAB settings time zone also UTC+3, in debian os also UTC+3

Alrmclock on android phone at 06:00 am

Item receives 03:00 am and rule triggers at 03:00 am localtime but should trigger at 06:00 am localtime

Also have another problem:
my timezone UTC+3 all the whole year, i.e. summer time and winter time as the same

if I set new alrmclock to tomorow (27.10.2023) at 09:00 am and item receives 05:00 am
this is 4 hours less, not 3