Wake-up light based on Android alarm clock

did you also try com.android.alarmclock.ALARM_ALERT and com.android.deskclock.ALARM_ALERT?

Permissions are not needed for alarm clock intents as far as I know. Only for special intents, like when someone calls e.g.

ok got a bit closer. I have a huwai phone with EMUI. ANd I installed the stock clock app of android.
If I’m using the Emui alarm clock:

com.android.deskclock.ALARM_ALERT

Seems to work.
But still wondering why the stock app is not throwing the intent.

How to set up with Tasker + MQTT:

  • install tasker
  • give it app permissions for everything (maybe storage and telefon is enough, but it didnt work without doing it)
  • install mqtt addon for tasker: mqqt publisher https://play.google.com/store/apps/details?id=net.nosybore.mqttpublishplugin
  • open tasker
    — in profile tab click the +Icon -> event -> date/time -> alarm clock
    — add new task for this profile (this will probably open automatically, tasker GUI is quite messy…)
    — give task a name -> task edit opens automatically -> click on the +Icon -> plugin -> mqtt publisher
    — edit the “configuration”:
    ---- add IP of your mqtt broker, add Port (1883 for non SSL mqtt is default), add client id (something that is not used yet, for example “myalarmphone”, doesnt really matter), add username + passwort if your mqtt broker needs that, add a topic (call it what ever you want, like “light/wakeup” or simply “wakeup”), QoS 1, accept
    — you can test this now, by listening to your mqqt broker. For example on a raspberry pi with mosquitto to listen to all incoming publishes:
    mosquitto_sub -h HOSTIP -t "#" -v -u USER -P PASSWORD
    — and in Tasker click on the Task you just created and press the play button. your topic should be shown (e.g. “light/wakeup”)
    –open Home Asssistant automation.yaml and add this (screenshots because formatting got messed up by this forums markup):
    grafik

replace “obi1” by “sonoffs” or “sonoff”. For service you may add the name you gave to your switch. I am not familiar with automation.conf yet. Got it to work by copy&paste and try&error.

you can use this instead if you use a tasmota sonoff switch:
grafik

This is my first post on the HA forums, so thank you to everyone.

I have been using this android app for a few weeks now and everything has been working great. The lights in my bathroom turn on to a dim setting when our alarms go off in the morning.

@corneyl I have a feature request if this is still being actively developed. It would be nice to have the daily alarm count instead of a running tally of the overall number of events since inception. The JSON payload on my current version includes a “count” variable which is the overall count since inception and an “android.intent.extra.ALARM_COUNT” variable which seems to stay at 1 regardless of how many times the alarm is triggered.

The use case for this would be triggering an action in the house to forcefully help to wake someone up after, perhaps, 3 alarms are triggered within a set amount of time.

Thank you again for the great app. It is simple to setup and very intuitive to use.

It’s not actively developed, but so now and then I spend some time on it.

For clarity: would you like to have a count of the past 24 hours, or one that resets at midnight?

A reset at midnight would work for my use case. Perhaps resetting the count after no alarm activity for a set period of time, say 1 hour, would also work. This would allow you to keep track of snooze events in a given alarm ‘session’ if there were multiple alarms used in one day.

Either way having a count of snoozes would be useful.

Thank you again. Cheers.

@corneyl, this is awesome.

The intent “android.intent.action.ACTION_PHONE_STATE_CHANGED” needs some privileges declared in the app manisfest file. I need this intent for automations related with phone calls.

Would you be available to add the ability for listening broadcasts about calls and telephony, please?

Thanks.

Cool option , but isn’t this all easier with the new routines function in the Google clock? Then you don’t need an extra app and mqtt? It’s a built-in feature now… ?

I was looking for a native android way to do this so i could use my voice to activate my alarm.
Unfortunately i discovered that my previous way was way more flexible and offered more features, you might find it interesting.

I use an app called ‘sleep as android’ that is hooked into ifttt by using webhooks. Besides all the default triggers, this has some smart triggers build in giving much more posiblities to automate things.

For example, it has a webhook tigger called ‘smart_period’ that fires 45m before my set alarm goes off. This allows for my thermostat to be set to a temperature and thus making sure it’s nice and cosy when the alarm rings without having to set a thermostat schedule. This also initiates a wake up light and turns on the coffee maker 30 minutes after the trigger went off.

It also fires an event at the moment you should go to bed to meet your sleep targets which you might find interesting.

The setup is quite simple and well documented for IFTTT and hooking IFTTT into hass.

Some examples:

  • sleep_tracking_started
  • sleep_tracking_stopped
  • sleep_tracking_paused
  • sleep_tracking_resumed
  • alarm_snooze_clicked
  • time_to_bed_alarm_alert
    • fires when you get a bedtime notification
  • alarm_alert_start
  • alarm_alert_dismiss
    • fires when you dismiss alarm (after you solve CAPTCHA, if it’s set)
  • rem
    • fires when we estimate the start of REM phase
  • antisnoring
    • fires when we detect snoring
  • smart_period
    • fires 45 minutes before the smart wakeup period starts

Just FYI.

1 Like

Sorry, I don’t have time at the moment to work on this.

But I’ve put the code on github so if you want to add something yourself you’re welcome to create a PR :smiley:.

See: https://github.com/pixento/broadcast-to-mqtt

Those who already have Tasker or an automation app compatible with Tasker (e.g. Automate) or would rather use something else than IFTTT might like to know that they can use a Tasker task (or, e.g., an Automate flow) to act on Sleep as Android events. I have a setup in which Tasker triggers HA scripts when I start sleep monitoring (to turn of my night stand lamp) and when I stop sleep monitoring (to turn on my coffee machine and turn on some lights if it is dark outside).

I understand, but for those who do not specifically look for a tasker way, IFTTT is an alternative that works great for me to do tasks like these.

If u do not mind using IFTTT, this works wonders. Unfortunately, you will be bound to the internet. Then again, on the very rare occasion that this would happen to me, I guess I would survive to not having a wake-up light and flipping the switch on the coffeemaker myself.

Edit: Excuse me, I now see that I misinterpreted your reply. The text above might still be valuable.

Anyone managed to use it with Google Clock? It works ok with Samsung clock but I can’t figure out which intent should be used for Google Clock.

It might now be easier to just install the Home Assistant app and use the next alarm sensor it provides.

1 Like

I gave up on tasker and alike. Switched over to Google Assistant Routines which are available in Google Clock. It seems to work when I test it with either switches or scripts during the day, but when set up for morning wake up alarm it does not work. The phone shows notification that the routine is running but actually is not doing anything. Has anybody faced similar issue?
image

Did you see what Corneyl suggested?

Yes I did. Haven’t tried that yet. How would the automation look like? Can I schedule an action for the time when coming from this state? What would be the best way to do that?

OK, I have found a topic on that with a few alternatives:

So after a few days of trying here is my experience, trying to automate wake up routine in line with my Samsung Galaxy S8 alarm clock (stock Google Clock app):

  • IFTTT - does not work, also other notifications are not captured
  • Tasker - works when tested but after night the tasks are not executed (probably app is killed)
  • Google Assistant Routines added to the Alarm actions - works when tested most of the time but does not work in the morning.
  • And finally Home Assistant Companion app and next_alarm sensor: works like a charm. The only thing you have to keep in mind is that if you have not used the App for a while and you change the next alarm the sensor might not get updated. So the best is to open the HA app after setting new alarm clock time. So I stick to it for the moment, let’s see after a few weeks how reliable it is.

I have noticed this too.
It would have been great if you could force update the sensors every now and then.
Just like you can force the location.