Johboh / hassalarm

Android app for integration with Hass.io as a sensor for the next scheduled alarm on the device
MIT License
62 stars 6 forks source link

Incorrect timestamp #21

Closed abelmatser closed 3 years ago

abelmatser commented 3 years ago

I believe there is a bug, but I'm unsure if it is due to Hassalarm or HA.

I have two sensors: input_datetime.next_alarm - through Hassalarm -, and sensor.abelphone_next_alarm - through the app. They both sync my alarm time with HA and the times match, see pic 1.

However, I believe there is an error when converting it to a timestamp (see pic 2), they lead to different values. The required value is 7:05 (UTC), which for me is 8:05 (CET, Paris). Hassalarm converted to timestamp and back reports: 1608277500 Is equivalent to: 12/18/2020 @ 7:45am (UTC) App alarm converted to timestamp and back reports: 1608275100 Is equivalent to: 12/18/2020 @ 7:05am (UTC)

My first guess would be that since Hassalarm does not add the timezone, that should lead to mistakes. However this does not match with an offset of 40 minutes. Would you have an idea how this is caused?

1 image 2 image (1)

Johboh commented 3 years ago

I'm looking into this. Instead of sending a formatted date, Hassalarm will send the unix timestamp (UTC) for the next alarm, e.g. not doing anything about timezones (as this is the only thing that the Android API provides). E.g. the timestamp as reported by the input_datetime. The 40 minutes is weird, however. What does Android OS show as next alarm? (in the notification area)

Johboh commented 3 years ago

@abelmatser Also, what does it say as "next scheduled alarm" when you open the Hassalarm?

abelmatser commented 3 years ago

The "next scheduled alarm" when opening Hassalarm does show the correct time: 08:05 and is published successfully. I can not easily find the next alarm of my device, but when checking my stock Clock app, it shows no alarm is enabled. The app I use (Amdroid) does show 08:05.

I believe sending the unix timestamp for the next alarm should do the trick. Let me know when there's an update I could test for you.

Johboh commented 3 years ago

I have pushed a new version 1.17, that does this. Can take a couple of hours to propagate.

abelmatser commented 3 years ago

I just installed update 1.17.

In Hassalarm, in the Connection test (successful), under request body, it says: {"entity_id":"input_datetime.next_alarm","timestamp":1608534300}

But this timestamp does not correspond with the reported timestamp in HomeAssistant (attached picture). This is weird to me. HA should not change the timestamp, even if I would be in a strange +40 minutes timezone. ha_next_alarm

Johboh commented 3 years ago

Yeah, it's weird that the published timestamp differs from the Hass one. What time zone do you have in home assistant?

abelmatser commented 3 years ago

The timezone is Europe/Amsterdam. I just checked the alarm that android thinks I have through AutoAlarm, and that is the correct 08:05.

If you can not recreate this bug, then maybe just leave it, as it could be some random hiccup in Home Assistant as well. For now I'll resort to the reported alarm time through the official HA app.

Johboh commented 3 years ago

Is this a new issue? Eg. did it start just now or was it always like this? I don't think the issue is in Hassalarm as the app reports the correct time (7.05 UTC). Also 40 minutes off is weird 😊. Will Google a bit.

abelmatser commented 3 years ago

Yeah it is weird.. Nope, it started this weeks Monday or Tuesday, before that it functioned perfectly.

On Fri, 18 Dec 2020, 16:12 Johboh, notifications@github.com wrote:

Is this a new issue? Eg. did it start just now or was it always like this? I don't think the issue is in Hassalarm as the app reports the correct time (7.05 UTC). Also 40 minutes off is weird 😊. Will Google a bit.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Johboh/hassalarm/issues/21#issuecomment-748142574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH7KP56FQHCCWWOZJWL7ZG3SVNWN7ANCNFSM4U7L5PIA .

abelmatser commented 3 years ago

That could coincide with me updating to HA 2020.12.0. I just updated to 2020.12.1, maybe that changes things, gimme a sec.

On Fri, 18 Dec 2020, 16:52 Abel Matser, abelmatser@gmail.com wrote:

Yeah it is weird.. Nope, it started this weeks Monday or Tuesday, before that it functioned perfectly.

On Fri, 18 Dec 2020, 16:12 Johboh, notifications@github.com wrote:

Is this a new issue? Eg. did it start just now or was it always like this? I don't think the issue is in Hassalarm as the app reports the correct time (7.05 UTC). Also 40 minutes off is weird 😊. Will Google a bit.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Johboh/hassalarm/issues/21#issuecomment-748142574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH7KP56FQHCCWWOZJWL7ZG3SVNWN7ANCNFSM4U7L5PIA .

Johboh commented 3 years ago

Did you upgrade home assistant by any chance? The weird part is that the time is still correctly shown for the input datetime, eg the converted timestamp correctly to 8.05, even when the timestamp is wrong.

abelmatser commented 3 years ago

Jackpot! Updating to 2020.12.1 fixed it for me. Looking at the changes, i noticed this issue. That must be the one. Thanks for trying to look at the problem with me.

Johboh commented 3 years ago

@abelmatser Great!