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 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:
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
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