Automation that creates an alarm on my android phone

Im pretty new with home assistant and i would like to know if it is possible to set an alarm with home assistant.
So basically my time schedule can change everyday and i also have setup a sensor for that. Now the sensor triggeres a automation based on what time i have to be at work and uses a specified time to run the automation. For example if the sensor detects that my work starts at 7:55 then the automation will automatically trigger at 6:30. Or if my work starts at 9:30 my automation will automatically be triggered at 8:00. This works completly fine.
Now i want to be able to create a Alarm on my Android Phone which will just be like 2 minutes ahead of time.
So when my automation triggeres at 6:30 then as the action ha will create an alarm on my phone that goes of 2 minutes after. So It should run at round about 6:32 then.

Is it possible to create an alarm on my android phone within a automation?

Yes but you will need the Home Assistant Companion App installed on your phone where you want the alarm set.

What do i need to change specifically for my use case?
I get an error message if i try to use the code you linked.

image

Have you looked at Pushover?

remove the last 2 lines

If i trigger it it sends a notification to my phone but wont do anything. If i look in my Clock ab, there is no alarm created.

sorry , looks like you are following a forum post that used old parameters. I have updated my post now to reflect the current state.

also in the future make sure to reference the docs to ensure the post is up to date: Notification Commands | Home Assistant Companion Docs

But what exactly do i have to do?
I dont really know how it works

Update the code to the latest changes in the post you copied and try again

I looked into it but i just cant understand what needs to be changed :cry:

your entire service call needs to change. Your screenshot from your comment up above

do you see the differences?

no longer matches the post you referenced, you need to update it.

For reference let me paste the new updated post again.

service: notify.mobile_app_pixel_5
data:
  message: command_activity
  data:
    intent_package_name: "com.google.android.deskclock"
    intent_extras: "android.intent.extra.alarm.HOUR:8,android.intent.extra.alarm.MINUTES:30"
    intent_action: "android.intent.action.SET_ALARM"

yes i see it now.
But now i get an error message on my android phone (s10) saying
" aktivitäten format kann nicht gesendet werden, bitte befehlsformat überprüfen".
As im german i translated it:
“activity format cannot be sent, please check command format”

I already gave Home assistant every possible entitlement. And by reading the error message it looks like somethings still wrong with the code:

service: notify.mobile_app_s10_brandon
data:
  message: command_activity
  data:
    intent_package_name: "com.google.android.deskclock"
    intent_extras: "android.intent.extra.alarm.HOUR:8,android.intent.extra.alarm.MINUTES:30"
    intent_action: "android.intent.action.SET_ALARM"

do you have the Google clock app installed becaues teh example use that package name :wink:

1 Like

Oh yeah i didnt know that now it works!
But how do i make it that the alarm will be set like only 1 minute away so that wenn my automation triggers the alarm will basically go off directly.
Right now it only sets the time on 8:30

Could you find a solution?

This is how i did that.

First i set a variable for the hour and minute that i want to set the alarm named “hour1” and “min1”
as i want to set the alarm for one minute from now,
hour1= current hour ,“now().hour”
min1= current min +1 “now().minute+1”
then these are added to the extras as variables instead of a single number.

Obviously, this will fail if the script is triggered at, for example “08:59” because it will set the alarm for 08:60 which is not a real time.

Otherwise, this works great

alias: "Set next alarm "
sequence:
  - variables:
      hour1: "{{now().hour|int}}"
      min1: "{{now().minute+1|int}}"
    alias: Set time
  - service: notify. Mobile_PHONE_NAME
    data:
      message: command_activity
      data:
        intent_package_name: com.google.android.deskclock
        intent_action: android.intent.action.SET_ALARM
        intent_extras: >-
          android.intent.extra.alarm.HOUR:{{hour1|int}},android.intent.extra.alarm.MINUTES:{{min1|int}},android.intent.extra.alarm.MESSAGE:Home
          Assistant Alarm,android.intent.extra.alarm.SKIP_UI:true
mode: single
1 Like