FINALLY!.. I sincerely don’t have total sure of exactly what I do… =P
Just install Tasker and follow this (but instead of Tasker I did this steps with HA App): Tasker for Android
And this: Xiaomi | Don’t kill my app! (dontkillmyapp.com)
Tried to fire the notification some times between the steps and after complete this 3 options:
On Xiaomi devices enable “Auto Start” for the apps and “Display on Lock Screen” under “Other Permissions”
On Xiaomi devices disable automatic backup of apps because that process kills all running apps, including Tasker.
everything worked…
Now I can rest in peace… =P
Thank you very much for the support… I love Home Assistant and the community is amazing! <3
Hope that help someone else with the same problem with Xiaomis…
Thanks! It works!
The only thing is that each time I set an alarm, a new alarm appears in my phone, even if an alarm with the same time already exists.
My idea is that when I set an alarm in my echo with alexa, home assistant automatically sets the same alarm in my phone (just in case).
But if I use this, everyday, I would end up with tens of alarms in my phone.
Do you know how could I set an alarm if it does not exist or just activate if it already exists? Or any idea?
Thanks in advance for any help
thanks, but it is different. the alarm exists but is not set/active.
I want that, if an alarm already exists but is not active, then activate the existing alarm, and only set a new alarm if there is not any alarm at that hour.
other option would be to delete an alarm.
this depends on the application and how it implements the API intents. You will need to test to see if your alarm app does this.
this only happens for non-recurring alarms, there is no command to delete an alarm. This also depends on what the alarm app supports.
Sleep as Android does allow you to enable and disable an alarm based on the label you give, other apps might not work. Best way to tell is to test it yourself.
random question again about timers. i have it working a treat after help from dshokouhi but is there a way of cancelling the timer at all. so for example it sets the timer when i say for 15 mins to check my daughters levels. but then if i scan in the mean time and her levels are normal i want to cancel the timer on my phone. looking at al the info i can only see about starting timers etc
i have noticed thou that the phone does nothing when i run the code. if i put say PAUSE_TIMER i get the error etc so its looking like the command is right i just need to figure out how it works!!
have you tried looking at the companion app logs to see if there is another error there?
also the intent_extra is not needed
The timer to dismiss should be specified using the Intent's data URI, which represents a deeplink to the timer.
If no data URI is provided, dismiss all expired timers.
I am not 100% certain about how to construct the deep link here so may need to research that bit.
I tried it on its own which should I would have thought cancelled all timers without the extra bits but to no avail. I’ll have a look in the logs see if there is anything in them.
I scrounged your code to set an alarm on my Samsung (Android 12) whenever I have an early shift the next day. Script works, however, I can’t import any variables from the call. I.e., when I hardcode the alarm time in the script, I get the result I want. Any time I try to use ‘time’ as a variable, I get a failure info ‘time not defined’. I have tried other variable names, but no joy. Any hints?
Appreciate,
Frankie
Are you sure you are calling it like this:
service: script.set_android_alarm
data: {“device”: “mobile_app_devicename”, “time”:“7:15”, “message”:“time to wake up!”}
I’ve just tested it and it works over here.
Please try the following code and let me know what the message is that you receive on your device
alias: set android alarm
sequence:
- service: notify.{{device}}
data:
message: "alarm set to {{time}} with description {{message}}"
- service: notify.{{device}}
data:
message: command_activity
data:
intent_action: android.intent.action.SET_ALARM
intent_extras: >-
{% set timelist = time.split(':') %} {% set timehour = timelist[0]
%} {% set timemin = timelist[1] %}
android.intent.extra.alarm.MESSAGE:{{message}},android.intent.extra.alarm.HOUR:{{ timehour }},android.intent.extra.alarm.MINUTES:{{ timemin }},android.intent.extra.alarm.SKIP_UI:true
mode: single
icon: mdi:alarm
thanx for the speedy response!
I found my error - my syntax within ‘android.intent…’ was skewed, I left a few empty spaces, etc. After a lengthy trial&error process the variables are passed, and the script works fine. Plus, I learned a lot.
Thanx again, Frankie
I’m using Sleep for Android as well. I found out there’s a way more simple way to see the status of the next alarm.
If you got the Home assistant app on your phone you can find the sensor.(your-phone-name)_next_alarm
The only thing you have to add in the sensor.yaml is a date script.
# Time and date
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_utc'
- 'date_time_iso'
- 'time_date'
- 'time_utc'
- 'beat'