How to use next alarm sensor

Hello.
How do we overpass this issue?
I have a Samsung Galaxy phone and I tried to use next alarm either with the embedded alarm app or with the Google clock and I can’t get it to work. So I guess it’s the reason you mention.
Thank you!

try removing any app from the allow list, then check the package attribute to find the offending package and remove any alarms from it. Give you have a samsung device, check the samsung calendar as well. Remember any app can se the alarm, so you have to investigate which app it is.

Had the same issue, had to reboot my phone before it worked

My issue is somewhat similar.
In my case i have a recurrent alarm set up. However, it seems like when the mobile app is unable to connect to the Server, the sensor is set for now +10 minutes.
So when i don’t use my phone in a while it would start fluctuating between now +10 minutes, and the real alarm, and again back to now+10min. Only when there’s an active connection (plugged charging, or using the phone) will it remain a stable sensor.

image

If you would think this is better in a different thread let me know. Thanks!

What alarm app are you using? Sounds like either Samsung or Xiaomi default clock app? Unfortunately some apps are known to do weird things like that.

Thanks.
I actually got that fixed. It’s a Oneplus. What I did was to edit the android companion app, edit the next alarm sensor where we can define which app is able to ‘update’ the next alarm value and i’ve set it to oneplus clock app only. So i guess there was some other apk which was pushing some ‘alarm’ stuff to the sensor poluting it.

What i’m not sure is, for automations, how reliable is it to compare now() against alarm. I ask this becasue as soon as the alarm is reached, then the sensor will update the value to the next occurence in that same isntant. So potentially alarm will never be equial to now()? I haven’t tried it yet, but that’s what I suspect might happen? Or is it working fine for you?

Thanks!

It’s working for me.
But I have seen people who has had issues with it.

You could just trigger the automation 10 seconds earlier than the time and it should work.

1 Like

honestly you don’t need to do that at all if you want it to fire when the alarm fires just use the time trigger like below

https://www.home-assistant.io/docs/automation/trigger/#sensors-of-datetime-device-class

2 Likes

Spot on, thanks!
And the example from the docs in particular shows precisely the ‘next_alarm’ scenario so it that’s how is meant to be used.

I had the same problem.
I wanted the heating in the bathroom to be set to 25 degrees 30 minutes before my (Android) alarm clock rang.
That way, the bathroom is always nice and warm in the morning when I get up.
I found the solution in another thread and find it extremely simple.
As trigger use:

{{ as_timestamp(states(''sensor.pixel_5_next_alarm'')) - 1800 < as_timestamp(now()) }}
3 Likes

Added a WTH topic, maybe if more people are interested there can be an easier solution.
WTH - Phone Alarm as Automation Trigger

What about the solution 3 posts above yours?

2 Likes

Yaml vs. Gui more or less I guess

Hello,
Until now, I used an input time to activate my alarm clock.
My alarm clock is divided into several parts.
The first at wake-up time which triggers an automation. That’s done and working. :white_check_mark:

The second at a time before the alarm clock which activates my phone charger.:x:

So far I used this code to control loader automation.

template:
  - sensor:
      - name: "Wake Time 1 Pre"
        unique_id: sensor.wake_time_1_pre
        device_class: timestamp 
        state: >
          {% set alarm = today_at(states('input_datetime.wake_time_1')) %}
          {% set offset = 23 if now() >= alarm else -1 %}
          {{ alarm + timedelta(hours=offset) }}

Today I wanted to replaceinput_datetime.wake_time_1 through sensor.oneplus_6t_justin_next_alarm

Which give :

template:
- sensor:
      - name: "Wake Time 1 Pre"
        unique_id: sensor.wake_time_1_pre
        device_class: timestamp 
        state: >
          {% set alarm = today_at(states('sensor.oneplus_6t_justin_next_alarm')) %}
          {% set offset = 23 if now() >= alarm else -1 %}
          {{ alarm + timedelta(hours=offset) }}

Except that this is not working, mysensor.wake_time_1_pre is marked as unavailable.

I don’t quite know what to do right now.

I would also like to add an input to control the time to be removed fromsensor.oneplus_6t_justin_next_alarm, which should allow me in the future to do something adaptive depending on the battery level.

So if you have any ideas to help me.

Thanks

I wish the next alarm sensor had a companion sensor that would tell me when I’ve snoozed an alarm. Right now I have to add heuristics like “is the next alarm in roughly 10 minutes?” to distinguish between snooze and actual next alarm, and this is killing me.

Sleep as Android let’s you distinguish that

That’s nice! Would you mind sharing the steps to use that app / get its data with the Companion app? Thanks in advance.

you dont need to use the companion app, you can just install the sleep as android app and use the webhooks feature or mqtt feature with your server. It can be independent of the app in that case.

Thanks, but I was hoping for something mediated by the Companion app. I don’t have MQTT and I would prefer something that goes over the Home Assistant bus rather than maintain yet another webhook on an ongoing basis. If Sleep as Android supported sending intents to the Companion app, that would be okay.

Thanks either way!

it does support sending intents, check out their docs: Intent API - Sleep as Android