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?
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:
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.
The second at a time before the alarm clock which activates my phone charger.
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.
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.
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.
I did get my alarm to trigger automations, but i like to set multible alarms with about 5 to 15 minutes in between.
I want the lights to turn on when the last alarm goes off.
So is there a way to ad a condition that if there is second alarm in the next 15 minutes it stops?