Hello, I would like to define an automation based on my android next alarm.
I was able to successfully create the sensor for next alarm, and I have set the automation on time trigger based on the sensor without using any templates.
platform: time
at: sensor.mobile_phone_next_alarm
Now, the automation is never triggered, and I noticed a strange thing in the logbook: the sensor becomes unavailable some seconds before the alarm should go off
Does this happen to any of you too? May this mean that the mobile phone and the hassio have some time discrepancy, and the alarm goes off before hassio can reach the time and trigger the automation?
Thanks for everything
Home Assistant 2023.10.5
Supervisor 2023.10.0
Operating System 11.0
Companion app 2023.10.2-full
try to check your server time and device time to make sure they are up to date. The state of unavailable means there are no alarms, you can try checking companion app logs when the issue occurs too.
I’m having the same issue. The alarm goes to unavailable when it sounds and stays unavailable until I either stop or snooze it. In my automation, I compare the Next Alarm sensor’s milliseconds attribute (which I truncate to allow for a wider comparison period) to the current date time (also as milliseconds) value as my trigger. It was working well for almost a year, then stopped working maybe a couple months back (I don’t have exact update when it changed).
I suspect it’s not triggering because it immediately changes to unavailable when the alarm sounds.
This is from dev tools > template:
{{ states("sensor.my_pixel_next_alarm") }}
{{ state_attr("sensor.my_pixel_next_alarm", "Time in Milliseconds") }}
Results in:
2023-10-24T17:25:00+00:00
1698168300000
While the alarm is sounding, that same template returns:
unavailable
None
…until I stop or snooze alarm and then it changes to the next days alarm.
Interestingly, I checked my wife’s phone and her next alarm sensor immediately switches to the next day’s alarm when the current alarm is sounding. Her alarm-based automations are working fine as a result.
We are both on pixel phones, mine is a more current model. We both use the stock android clock, only mine (assuming because it’s more current and running a more current version of android) is running clock version 7.6, while hers is running 7.5. So it could be the clock app. Also I checked both Next Alarm sensor configurations in the companion app settings and they are both configured the same, with the “Package” defined as com.google.android.deskclock.
Home Assistant 2023.10.3
Supervisor 2023.10.0
Operating System 10.5
Frontend 20231005.0 - latest
make sure to check the companion app logs when the issue occurs to find out why the alarm is changing faster. Also double check the time on server and phone matches that can also be a cause of the issue. The companion app logs will print exactly why the state changes.
I didn’t really get your intention but i use “Turbo Alarm” on Android, together with its Tasker implementation. I’ve set tasker to run a task that presses a helper button when I snooze and another when i Dismiss. I plan to use this to for example send a notification with the question to start warming the car.