openhab / openhab-android

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

AlarmTimer receives wrong DateTime #2285

Closed vKnmnn closed 3 years ago

vKnmnn commented 3 years ago

Hi everyone, similar to #2080 i'm experiencing problems with the android-app sending the next alarm time from mi Xiaomi Mi phone (miui 12). when using the default app, recurring alarms to not trigger the sending of an item at all, non-recurring alarms work fine. using another app (sleep as android in my case) seems to be sending now+1minute to openhab

Actual behaviour

when using the default app, recurring alarms to not trigger the sending of an item at all, non-recurring alarms work fine. using another app (sleep as android in my case) seems to be sending now+1minute to openhab

Expected behaviour

well the actual alarm should be set

Steps to reproduce

  1. create an alarm on a MIUI 11 or 12 phone
  2. create AlarmTimer DAteTime object
  3. launch openhab app
  4. watch the logs

Environment data

Client

Server

openHAB Cloud

Logs

App log

Click to expand ``` 11-02 23:25:37.639 26022 26022 D BackgroundTasksManager: onReceive() with intent android.app.action.NEXT_ALARM_CLOCK_CHANGED 11-02 23:25:37.639 26022 26022 D BackgroundTasksManager: Alarm clock changed 11-02 23:25:37.641 26022 26022 D BackgroundTasksManager: Alarm sent by com.urbandroid.sleep 11-02 23:25:37.642 26022 26022 D BackgroundTasksManager: Scheduling work for tag alarmClock 11-02 23:25:37.667 26022 26022 D BackgroundTasksManager: onReceive() with intent android.app.action.NEXT_ALARM_CLOCK_CHANGED 11-02 23:25:37.667 26022 26022 D BackgroundTasksManager: Alarm clock changed 11-02 23:25:37.668 26022 26022 D BackgroundTasksManager: Alarm sent by com.urbandroid.sleep 11-02 23:25:37.669 26022 26022 D BackgroundTasksManager: Scheduling work for tag alarmClock 11-02 23:25:37.758 26022 26073 E WM-WorkerWrapper: Didn't find WorkSpec for id 1fb4e3d5-db84-467f-bcaf-4bccea3dbe8d 11-02 23:25:37.791 26022 26704 D ItemUpdateWorker: Trying to get connection 11-02 23:25:38.295 26022 26704 D ItemUpdateWorker: Trying to update Item 'AlarmClock' to value 2020-11-02T22:26:37+0000, was 1604355997505 11-02 23:25:38.700 26022 26704 D ItemUpdateWorker: Item 'AlarmClock' successfully updated to value 2020-11-02T22:26:37+0000 11-02 23:25:38.705 26022 26050 I WM-WorkerWrapper: Worker result SUCCESS for Work [ id=e776bd62-d676-4874-b499-1282f9fe7eee, tags={ alarmClock, itemUploads, org.openhab.habdroid.background.ItemUpdateWorker } ] ```

openHAB Server log

Click to expand ``` ==> /var/log/openhab2/openhab.log <== 2020-11-02 23:25:37.004 [INFO ] [eclipse.smarthome.model.script.alarm] - Alarm expired ==> /var/log/openhab2/events.log <== 2020-11-02 23:25:38.347 [ome.event.ItemCommandEvent] - Item 'AlarmClock' received command 2020-11-02T22:26:37.000+0000 2020-11-02 23:25:38.388 [vent.ItemStateChangedEvent] - AlarmClock changed from 2020-11-02T22:25:37.000+0000 to 2020-11-02T22:26:37.000+0000 ==> /var/log/openhab2/openhab.log <== 2020-11-02 23:25:38.404 [INFO ] [eclipse.smarthome.model.script.alarm] - Scheduling alarm for2020-11-02T23:26:37.000+0100 (1604355997000) 2020-11-02 23:25:38.418 [INFO ] [eclipse.smarthome.model.script.alarm] - New alarm ```
mueller-ma commented 3 years ago

As already stated in the linked issue:

I don't think we can do much here, because we just get the next alarm time from alarm service of Android.

I know this isn't the answer you want to hear, but the used api doesn't give us more information.

FYI there are a few apps that aren't allowed to set the alarm time on openHAB: https://github.com/openhab/openhab-android/blob/master/mobile/src/main/java/org/openhab/habdroid/background/BackgroundTasksManager.kt#L267-L271