Set Android alarm clock from Home Assistant

Thank you for uber-quick help!

My code is now

service: notify.mobile_app_andreas_one_plus_8t
data: 
  message: "command_broadcast_intent"
  title: "com.urbandroid.sleep.alarmclock.ALARM_STATE_CHANGE"
  data:
    channel: "com.urbandroid.sleep"
    group: "alarm_label:test,alarm_enabled:false"
1 Like

Hi, I was happily using this solution to set my daily alarm, but I think Android 13 broke it… Now I just see the “command_activity” notification as if it was a normal notification.

I tried the map example in documentation and it still works, so I think there’s something specific with this intent. Has anyone else experienced this issue with Android 13?

It wasn’t android 13 that broke it. It was the update of the mobile app itself that broke it.

you need to use different service command structure.

Here is an example of mine with the update:

script:
  mobile_app_notification_command_set_alarm:
    alias: Mobile App Android Notification Command Set Alarm
    mode: restart
    sequence:
      - service: notify.mobile_app_my_mobile_app
        data:
          message: "command_activity"
          data:
            intent_action: android.intent.action.SET_ALARM
            intent_extras: >-
              {% set timelist = states('input_datetime.ma_alarm_set_time').split(':') %}
              {% set timehour = timelist[0] %}
              {% set timemin = timelist[1] %}
                android.intent.extra.alarm.HOUR:{{ timehour }},android.intent.extra.alarm.MINUTES:{{ timemin }},android.intent.extra.alarm.SKIP_UI:true
7 Likes

I have android 13 in my Pixel 4a. I have solved with this code. Thank you a lot :smiley:

1 Like

Thank you @finity, that worked!

How did you find out how to change the data to make it work?

It was partially the mobile app docs and there was a thread about beta changes a while back that i saw.

any body advise what i’m doing wrong i use the following code

service: notify.mobile_app_marks_s22
data:
  message: command_activity
  data:
    channel: "com.google.android.deskclock"
    group: "android.intent.extra.alarm.HOUR:8,android.intent.extra.alarm.MINUTES:30"
    tag: "android.intent.action.SET_ALARM"

but all i get is a pop up on the notifications saying “command_activity” and no alarms set

and i have installed the google clock

where as i was originally trying to use the samsung built in one

Group, chanel and tag is no longer correct syntax.
Look at the example just a few posts above.

1 Like

Cheers buddy. I’d looked quick and thought it said android 13 had broke it so ignored that but its the app.

Cheers for pointing it out

i’m really stupid at this but cant get the timer to work at all!!! i can get an alarm set with a time and a message but nothing on the timer, i can get it to open the timer but nothing will set.

the length line is obviously wrong but what should it be!!!

service: notify.mobile_app_marks_s22
data:
  message: command_activity
  data:
    intent_action: android.intent.action.SET_TIMER
    intent_extras: android.intent.extra.timer.LENGTH:12

Where did you pick up this intent extra?

Per the docs it should be android.intent.extra.alarm.LENGTH

https://developer.android.com/guide/components/intents-common#CreateTimer

id tried all sorts mate but couldn’t get it to work that was just the last thing that i had tried. i knew it was wrong thou.
that line works great but i’m struggling to work out why it’s alarm and not timer to be honest as it never calls the alarm part anywhere from what i can see in the above code.

Thats a better question for google LOL, don’t question it just go by what they document because thats what the code looks for. At the end of the day its just a string value so it can be anything they chose, literally.

:rofl: :rofl:

either way thanks bud, working a treat so i can set a timer automatically now for my daughters diabetes levels if she gets a high or low reading.

2 Likes

I am glad people are finding all kinds of uses for this feature :slight_smile:

Hi everyone!

Can’t get this to work. Never used, but saw that chances are made recently.

This is my yaml:

service: notify.mobile_app_poco_x3_gt
data:
  message: command_activity
  data:
    intent_package_name: com.urbandroid.sleep
    intent_action: android.intent.action.SET_ALARM
    intent_extras: >-
      android.intent.extra.alarm.HOUR:8,android.intent.extra.alarm.MINUTES:30,android.intent.extra.alarm.SKIP_UI:true 

Tried in Developer Tools and nothing, the HA app pop up an authorization to overlay apps but still nothing, tried without package name too… no alarm set anywhere…
Any ideas?
Thanks in advance

I have this in Node red:

{
    "message": "command_activity",
    "data":{
        "intent_action": "android.intent.action.SET_ALARM",
        "intent_extras":"android.intent.extra.alarm.HOUR:" & msg.hour & ",android.intent.extra.alarm.MINUTES:" & msg.minutes & ",android.intent.extra.alarm.MESSAGE:Wake UP!,android.intent.extra.alarm.SKIP_UI:true,android.intent.extra.alarm.VIBRATE:false",
        "ttl": 0,
        "priority": "high"
    }
}
3 Likes

Just tried this on another phone and worked!.. thanks for the reply… but…

In Poco X3 GT after several tests (and reinstall the app) I discovered that this only works if Home Assistant App is opened and with screen on… no idea how to fix that… =’(

did you make sure to grant the app Draw over other apps permission? You should’ve been directed there the first time you tried it when teh app was in teh background. If you denied it then you won’t get a prompt again, so might want to double check that.

Yeap, permission was given… reinstall again, and nothing… maybe something with Poco software? Normal notification (with just text information) works fine, sometimes with a delay but always arrive… the alarm set even waiting if in some point will be set… nothing… just work with app open… trying some changes here (like float notification function in the software) but don’t thing will work…

So sad… just discovered that function and was really excited with possibilities… and my main phone moke with me… =’(