Automations based on next scheduled alarm (on Android device)

Ahhh, sorry, didn’t see that thread. Sorry for double your things. You have made an awesome project and I like it very much. I will definitely use this onwards. Thanks!

Hello, i am unable to reach to the HA assistant with the hassalarm app.
Getting this info in the app log:

Using long lived token
Entity ID is of type input_datetime
Request: POST http://xxxxxxx.duckdns.org:443/api/services/input_datetime/set_datetime

Request headers: Authorization: Bearer long_lived_token_here_abcdefgh

Request body: {“datetime”:“2020-02-04 06:12:01”,“entity_id”:“input_datetime.next_alarm”}

Failure: unexpected end of stream on Connection{xxxxxxx.duckdns.org:443, proxy=DIRECT hostAddress=xxxxxxx.duckdns.org/IP:443 cipherSuite=none protocol=http/1.1}

Hi!
What if you try https://xxxxxxx.duckdns.org as your host instead? E.g. https instead of http as well as removing the port number.

//Johan

hi johboh thanks for your fast reply.

Following your suggestion, I tried also https://xxxxxxx.duckdns.org (no port)

Result is:

Using long lived token
Entity ID is of type input_datetime
Request: POST https://xxxxxxx.duckdns.org/api/services/input_datetime/set_datetime
Request headers: Authorization: Bearer long_lived_token_here_abcdefgh
Request body: {“datetime”:“2020-02-04 06:12:01”,“entity_id”:“input_datetime.next_alarm”}
Failure: 400:Bad Request

In case i specify the port 443, i get it reflected in the url
Request: POST https://xxxxxxx.duckdns.org:443/api/services/input_datetime/set_datetime
but same result
Failure: 400:Bad Request

Thanks,
alex

hi johboh
I removed from the configuration.yaml the legacy api password entry. I was keeping it there for historical reasons (silly), although i was not using it anymore.
I restarted HA and now connection is successful using:
https://xxxxxxx.duckdns.org/ (no port)

thanks a lot!

Would it be possible to add a feature where it looks at the label on Android to determine the “next alarm”. For instance, if I have 2 alarms set throughout the day, but only 1 is to get up…I would want my morning automation to only run for the first alarm and not the second. Is this do-able?

I don’t think so. The API only expose the next alarm timestamp, and nothing about the label/name of the alarm. The API I’m using is a public Android OS API which reports the next scheduled alarm, as set by the alarm clocks apps, I’m not interfacing with the alarm app itself (as they don’t expose any API).

However I do understand the need for it. Maybe I can add some kind of silent/cutoff-period setting so one can specify to not report any next alarm to hass between these times. Or a setting to only report the first alarm in the day.

1 Like

Thank you very much for sharing this app! Works great!

1 Like

Hi there, i had some struggle to make it work properly at the first time - after installation it stated that the next alarm is set to next day at 00:00 - but it wasnt :wink: I tried to install Google clock and set alarms there, still no change. I restarted my phone and while there were no alarms it showed that next alarm is set next day at 10:00 - it wasnt :wink: But it updated after i set a new alarm. Now the only struggle is that the alarm is set at 7:50 but the app shows it is set for 6:50 :confused: Timezone in Hass is set properly, app shows alarm an hour before it should fire :confused:

Hi! Thanks for the work on this app an integration!
I can get it working with my internal connection at home ising http://[ip]:8123
However, I don have wifi on all the time, so I would like to connect to the external url I use. It uses reverse proxy on IIS, on url https://home.[domain].com

When I use the external domain, I get an error [Connection failed - Trust anchor not found]
Is there a way to get it working using my external URL?

Hey!
I think this is due to an issue with your certificate. How is the certificate issued? There is a similar issue here: https://github.com/Johboh/hassalarm/issues/17

Hi, thanks for the reply.
I’m using a letsencryp certificate on that domain

Never mind, I see your respons a few posts up. Sorry.

Is there any possibility to get the name/description of the alarm from the phone?
Let’s say that on weekdays I want to wake up and just go to work, but on weekends I want coffee made.
So if I trigger on this alarm I need to know if it’s weekend or weekday alarm (simplified).

Obviously you could have a day off in the middle of the week and still have coffee and that is why it would be better to base it on the alarm name than weekday name.

Can you verify that the certification is working properly? I.e. when you navigate to your hass instance over https there is no certificate issues by your browser.

Hey!
No its not currently possible, you can see my answer in this post above: Automations based on next scheduled alarm (on Android device)
Basically the Android API does not expose that.

I have noticed that the app has started to report my calendar notifications as alarm events to Hass. Is there any way to fix this?

Hey!
This sounds very similar to the issue mentioned at the end of this issue: https://github.com/Johboh/hassalarm/issues/7
That your calendar app is reporting events as alarms (using the AlarmManager), which it shouldn’t. What device and calendar app are you using?

Thanks for the answer. I have an samsung galaxy s10 and I use google calendar and the built in calendar app. From the issues site it looks like it could be google calendar spooking I’ll try to disable it then.

Yes try disabling the built in app (and use the google calendar one). I use the google calendar one and that one does not interfere. It might also be that there are some settings you can change for the internal one to not publish alarms.

oh okay, thanks:-)