Android alarms as a sensor

Could you have the app read the alarms on your phone and add them as a sensor so you can have a scene trigger on/before your alarm?

You can do this with tasker or there’s an app called hassalarm that does it as well.

I’ve seen both of those solutions, but if I’ve already installed one app to integrate with HA, I’d prefer not to have to install others to accomplish what this one could fairly trivially.

I understand, I use Tasker for a lot of other things as well, so for me it’s not an additional app to install.

There’s already an open issue for this on github.

I can recommend tasker for this too.
Besides the alarm clock I use it for sms or call notification, so for me it isn’t an additional app either.

Didn’t see the other thread, so this one can be closed, but I don’t intend for any of HA to be exposed to the internet, so having to install another app on my phone and open HA to the internet is a hell of a lot extra vs having the app I’ve already installed do this.

I actually submitted a PR for this today :slight_smile: just need to wait for it to be reviewed and merged. If you really want to test this feature now you can grab the debug APK from the github actions.

4 Likes

Seems to work like a charm. Now I’ve gotta figure out how to integrate it haha

3 Likes

Yes indeed - it works great and I can see the sensor value in HA - but I can’t figure how to utilise that sensor value as a trigger for an automation

Broadcast to MQTT was able to do it. Unfortunatly, it’s no longer actively maintained.

But the sensor is included in the official app now, so Broadcast2MQTT isn’t needed anymore right?

Does anyone knows how to integrate the next alarm sensor in an automation? I tried this but it doesn’t trigger.

- id: "Sync-Smartphone-Alarm"
  alias: Sync-Smartphone-Alarm
  trigger:
    - platform: state
      entity_id: sensor.col_l29_next_alarm
  condition:
    - condition: template
      value_template: '{{ now().strftime("%Y-%m-%d %H:%M") == as_timestamp(states("sensor.col_l29_next_alarm")) | timestamp_custom("%Y-%m-%d %H:%M") }}'
  action:
    - service: light.turn_on
      data:
        entity_id: light.bett_right_led
        brightness: 100
        transition: 3600
        rgb_color: [255, 0, 0] 

Your condition should be the trigger.

Thanks, i tried it but same result :confused:

trigger:
 - platform: template
   value_template: '{{ as_timestamp(states("sensor.col_l29_next_alarm")) | timestamp_custom("%Y-%m-%d %H:%M") }}'
# both don't work
 - platform: template
   value_template: '{{ now().strftime("%Y-%m-%d %H:%M") == as_timestamp(states("sensor.col_l29_next_alarm")) | timestamp_custom("%Y-%m-%d %H:%M") }}'

You need a time sensor for Home Assistant. Your current attempts do not work,because there is no entity that changes the state (your alarm clock sensor only changes when you set a new alarm), so the automation is never triggered. The time sensor updates every minute, so the template will then be evaulated every minute. Another approach is to trigger with a time patter (e.g. every 5 seconds) and check in the condition if the alarm clock time is equal to now.