Set Android alarm clock from Home Assistant

Alarm state change is what you are after, just apply a label ot the alarm so its easy to toggle it

I was able to add a new alarm as per the code in you previous post. But I am not able to enable/disable an alarm in Sleep as Android.

I have tested this code (and some other alternatives) but it isnt working
I get message: Not able to send activityintent. Please check format of command. Or something like that, I get the message in swedish

service: notify.mobile_app_andreas_one_plus_8t
data: 
  message: command_activity
  data:
    channel: "com.urbandroid.sleep"
    group: "com.urbandroid.sleep.extra.alarm_label:test, com.urbandroid.extra.sleep.alarm_enabled:false"
    tag: "com.urbandroid.sleep.alarmclock.ALARM_STATE_CHANGE"

Make sure the labels match exactly what you see on the documentation, don’t add extra text before them.

alarm_label and alarm_enabled is copy/pasted, 100% sure it is correct. I have tried both with and without .extra.

remove this entire bit and only have alarm_label:label,alarm_enabled:true notice how there is no space after the comma as well?

You can also refer to the 3rd example: Notification Commands | Home Assistant Companion Docs

1 Like

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: