Any chance you can get it working on something below Android 5.0?
As far as i know, the intent for Alarms is not common in Android. Some device manufacturers support it, some dont. Samsung does support it as far as i could try.
I have a similar implementation running for a year, however completely without HA involvement. It simply takes the time stamp and puts it into the hue hub directly. Im using an “automate” automation for it on Android.
However, im looking into changing the whole system to HA or at least combine it with HA.
I am looking to integrate my android phone eg. If I get a phone call, HA turns a light on.
The app is really good but it’s limited to alarm. It would be good if we could use it for more android functions. I know it’s possible with Tasker but I am not familiar with it.
First of all: update is published!
@kernald android.app.action.NEXT_ALARM_CLOCK_CHANGE
is indeed broadcasted when setting an alarm. But the time is not put in the extra fields of the intent, but maybe you can find another broadcast intent that works for you and has this information.
@AbraKabastard I’ll see how much work that is, but probably it’s easy… Which version are you running?
@bachoo786 It’s not limited to alarms, but to broadcast intents. You could e.g. add the intent for an incoming call: android.intent.action.PHONE_STATE
. The only problem is that the app needs special permissions for this particular action, and I have not implemented this.
4.4.2! Using an old Samsung S3.
At the moment I do something similair (I set the alarmtime upon change on my Android) using the
android.app.action.NEXT_ALARM_CLOCK_CHANGED
Creating a alarm clock - #211 by Bob_NL
But it fails to update my sensors from time to time somehow.
Will try this.
Where do I add the intent for an incoming call?
I am doing something similar and use an android alarm to automatically raise my blinds 10 minutes before the alarm goes off.
that basically works like this: there is a task in tasker that is triggered every day at 4:00 am. this task uses the AutoAlarm plugin to check how many minutes are left until the next alarm goes off. It then subtracts 10 from that number of minutes and delays for exactly that time. The delay finishes 10 minutes before the alarm is set to go off, the next task calls home-assistant rest api to raise the blinds
That’s a cool approach!
I wanted to achieve the same and went with the alarm app Sleep As Android. There I enabled a smart period of 5 minutes (which means the app wakes me up up to 5m early of the wished time).
Sleep as Android then sends an event 45m before the smart period starts which I catch with tasker, turn on WiFi and send it to HA where an automation will start fading in the lights some minutes later.
This works, but I have the feeling I like your solution more, maybe I will refactor it, thanks for sharing
Edit:
the next task calls home-assistant rest api to raise the blinds
I prefer doing logic in HA, so I created switches like “alarm_ringing” or “alarm_starts_in_50m” etc which are turned on by tasker via the rest api. This way my tasker setup has as less logic as possible and most of the stuff is done by HA. This makes switching phones or adding functionality easier in my opinion.
@corneyl, the app is pretty cool. One issue I see is that if you are a “regular” Android user you don’t know the data for the “Broadcast Action”.
Also, an option to change the full topic would be nice.
@fabaff I know, but it’s also more targeted at experienced users. Maybe I will implement a way to add presets in the future, so it’s more usable for less experienced users, or just less typework. Btw, for me I’t just a hobby project which I published on the play store.
Would you like to be able to change the full topic for each broadcast item, or for all at once in the settings?
@AbraKabastard I tried to support also Android 4.4, but it seems that the library I’m using for MQTT doesn’t support that. At least it didn’t work on a virtual device.
It would be awesome to be able to change the full topic if needed. For Home Assistant android/broadcast/device-id
works fine but it would make it easier to use it with other tools or beside other tools.
No obligations, asking is for free
Thanks for trying mate
Nice! Been looking for something like this
I’m trying to get it to work but when I try to connect it just spams my MQ and disconnects immediately.
here are my logs:
accepting MQTT connection <0.30085.11> (xx.xx.x.xxx:55342 -> xx.xx.x.xxx:1883)
MQTT disconnecting duplicate client id "BroadcastToMQTTAndroid" ("xx.xx.x.xxx:55340 -> xx.xx.x.xxx:1883")
MQTT disconnecting duplicate client id "BroadcastToMQTTAndroid" ("xx.xx.x.xxx:55341 -> xx.xx.x.xxx:1883")
MQTT protocol error "xx.xx.x.xxx:55342 -> xx.xx.x.xxx:1883" for connection qos2_not_supported
FYI - It doesn’t matter what I set the client-id to, it always uses the “BroadcastToMQTTAndroid”
Good point, that’s a bug, I’ll try to fix it as soon as possible.
i realize this is an old thread but thought id chuck my 10cents worth in…
You don’t actually need to use any MQTT app for this, or an automation in home assistant.
I use Tasker
Just create a profile with an event context of Alarm, and have it fire a http post task, and use the home assistant api to call the light.turn_on service.
I just published a new beta version which includes an option to change the client ID (@mconway) and the global MQTT topic. And it’s now also possible to set a topic per broadcast item.
Edit: and I know that you can use Tasker, but this is another approach which can be easier if you already set up a MQTT broker. Also it’s cheaper.
Which intent do you listen for with tasker? com.android.deskclock.ALARM_ALERT
doesn’t seem to be working for me. Is there an intent that gets fired when an alarm goes off?
No need to use an intent at all, there is a profile context for “Alarm”, its an event context.
The profile will fire as the alarm starts.