I’d like to create an automation in Home Assistant with which I can start an Alarm/Timer on my Android smartphone. There weren’t a lot of posts on how to do this other than using the Home Assistant Companion app’s notifications, which don’t fit my requirements as I always have my notifications silent with vibrations. Mossaddeque Mahmood however created this post detailing his method for using Android Intents to create an Android timer set to 1 second.
I followed his guide and ended up with the following automation:
When I run this automation the alarm volume on my phone is updated, but no 1 seconds timer is set/started. I however get a brief Unable to send activity intent, please check command format error popup.
What would I need to change in the automation to get to the correct command format / are there alternative methods to achieve this?
@Schmetis@achapa45 is there a way to do this with the installed Samsung clock app.? I’ve just been trying to VIEW it before I try to set the timer but I can’t even get it to VIEW.
I have followed what’s posted in this thread, on two different phones, with great success in the last months. My two cell phones stopped reacting to this script correctly recently, not both at the same time, but eventually both stopped working correctly.
Now, ringer is very faint, not the same type and the phone shows this notification:
I just edited the previous post and removed the package name, that way it calls the default app for the phone. Also make sure that HA has permissions for alarms and appearing on top of other apps.
There is one little bug in the alarm code from @carlos.vroque above. If you set the alarm in the last minute of hour (say at 7:59 for an alarm to go off at 8:00) then it sets the alarm for the previous hour (7:00 in my example) and would go off the next day instead of the next minute. It’s a simple fix where you need to add the 1 minute to the hour as well as the minute calculation:
Also I will note that anybody using this code will want to update the service target (notify.mobile_app in this example) to your actual device target (ex: notify.mobile_app_coderanger_s_phone). You can find this value in Developer Tools / Services by searching for “notify.mobile_app”. Your device will be listed with the correct notify.mobile_app_xxx service name underneath it.
Edit: It’s safer to set the alarm 2 minutes instead of 1 minute in the future as well. While testing I ran into a issue where by the time the phone got the alarm setting it has passed and was set for the next day. This happens because the next minute could be only 1 second away (between 1 and 60 seconds away). Setting it to 2 minutes in the future guarantees at least a minute (between 61-120 seconds away).
I also had problem to make it working. It worked only when I have unlocked the phone and home assistant opened and visible at front. To make it working in general I had to add two additional permissions to Home Assistant application, mainly: ‘Show on Lock screen’ and ‘Open new windows while running in the background’. These permissions are under ‘Other Permissions’ in my phone.
At this moment I am able to set alarm automatically even though my phone is locked. I use android 13 with MIUI 14.0.5 (Xiaomi).