Wake-up light based on Android alarm clock

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.

I haven’t tried this or studied this solution in detail, but would it be possible to use the same solution to trigger light f.ex 30 minutes before the alarm? I would love a solution where I had basically an “if alarm with name good morning set, run wakeup-profile”.

Hmm…I’m trying to use that right now and the profile doesn’t seem to be firing when my alarm goes off. I’m using Event > Date/Time > Alarm Clock for my profile.

I’ve tried leaving the alarm label blank and I’ve tried labeling my alarm and adding a label to the profile…not sure why it won’t fire…other profiles work for this same task. I’ll probably try an alarm clock Tasker plugin. Anyway, thanks for the help!

Thanks @corneyl. Any specific reason your app requires QOS2 for connections to the MQTT broker? that’s what’s preventing me from using the app. My broker only supports QOS0 and 1

Good point, and no particular reason, I actually thought that the app was using QOS0 messages. But looking at the code I indeed use QOS2 messages. I’ll release a new beta today where QOS is an option which defaults to 0.

Will there be a iPhone app? If no, do you know if there is a iPhone app that does the same job?

Creative and great app

You mean the Broadcast to MQTT app right, not Tasker? For me this is just a hobby project, I do not own any Apple stuff and don’t even know whether they use a broadcast system internally. So no, not from my side at least.

Thank you!!!
I was looking for something similar to automate the shutters of the house at the sound of my alarm clock!

Hi @corneyl,

Your app is great, thanks for sharing.

Do you think it could be possible to send custom payloads with the event?
For instance, according to this link https://stackoverflow.com/questions/2600378/android-get-time-of-the-next-alarm we could get the time of the next alarm with the variable Settings.System.NEXT_ALARM_FORMATTED.

It would be awesome to be able to put such variables as payloads.

Thanks!

A quick search showed that this variable is deprecated: https://stackoverflow.com/questions/27333972/next-alarm-formatted-is-deprecated

But it would be nice indeed to be able to know the next alarm on forehand. I might look into this later, thanks for the pointer!

Hi @corneyl,
I would like to thank you for great app!

I was thinking about if it is possible to add functionality to turn wifi on when event is fired? Because at night I have fly mod turned on, so it cannot send data to MQTT. Or is there another workaround?

The Timely app will create a notification 10-15 minutes prior to the alarm, and the notification lists the time of the next alarm. Would there be a way to grab the next alarm time from the notification and send to home assistant?

I don’t see an intent being broadcasted with the notification, but I might be missing a step.

@KavajNaruj I don’t know a workaround other than enabling wifi on forehand. Maybe this functionality is possible with e.g. Tasker?

@ericstewart22 All ‘extra’ fields of the broadcast intent are also send via MQTT. So if you can find the broadcast and it contains an extra field with the next alarm time, then you can grab it from the json message sent via MQTT.

Hi!
Your app is fantastic but suddenly the app don’t notice when my alarm goes off. I have a oneplus 5 and searching for the correct broadcast action.

Where can i find it?

hello,

I like youre app.
I like to use it but i got some error’s
i want to set the allarm on my phone en send a mqtt message to turn on lights in my room

This is my config :

  • trigger:
    • platform: mqtt
      topic: 'android/broadcast/gsmruben
    • condition: state
      value_template: ‘{{ trigger.payload_json.action == “com.samsung.sec.android.clockpackage.alarm.ALARM_ALERT” }}’
      action:
      • service: switch.turn_on
        entity_id: switch.lamp

Error in home assistant:
Testing configuration at /config ERROR:homeassistant.util.yaml:while parsing a block mapping in “/config/automations.yaml”, line 12, column 7 expected , but found ‘{’ in “/config/automations.yaml”, line 15, column 22 Failed config General Errors: - while parsing a block mapping in “/config/automations.yaml”, line 12, column 7 expected , but found ‘{’ in “/config/automations.yaml”, line 15, column 22

Sorry i am new to mqtt

Gr Ruben