Comment on I need a new alarm app.
wreckedcarzz@lemmy.world 1 week ago
This is likely way overkill for your needs, but I have Home Assistant control my phone’s alarms, based on my various calendars that I sync using CalDav through DAVx5. HA will adjust the wake-up buffer based on what calendar the event is - so if yesterday I had an in-person appointment at 10am, and the buffer was 2.5h, but tomorrow’s event is remote, I don’t need to wake up as early, and so it adjusts tgst buffer because of it.
Main automation
alias: wreckedcarzz - Auto-Set Phone Alarm from CalDAV description: ‘’ triggers: - trigger: calendar event: start offset: ‘-8:0:0’ entity_id: calendar.appointments id: in_person - trigger: calendar event: start offset: ‘-8:0:0’ entity_id: calendar.appointments_remote id: remote - trigger: calendar event: start offset: ‘-8:0:0’ entity_id: calendar.trips_and_vacations id: trips enabled: false - trigger: calendar event: start offset: ‘-8:0:0’ entity_id: calendar.work_schedule id: work conditions: - condition: template value_template: ‘{{ trigger.calendar_event.all_day == false }}’ alias: Make sure the event is not for the whole day - alias: Last triggered at least 12 hours ago condition: template value_template: >- {{ this.attributes.last_triggered == None or (now() - this.attributes.last_triggered) > timedelta(hours=12) }} actions: - variables: new_buffer: >- {% set current = states(‘input_number.alarm_wake_up_time_buffer’) | float(0) %} {% if trigger.id == ‘in_person’ %} {{ current if 2.5 <= current <= 3.5 else 3 }} {% elif trigger.id == ‘remote’ %} {{ current if 0.5 <= current <= 2.0 else 1 }} {% elif trigger.id == ‘work’ %} {{ current if 1.5 <= current <= 2.5 else 2 }} {% elif trigger.id == ‘trips’ %} {{ current if 1.0 <= current <= 2.0 else 1.5 }} {% else %} {{ current if 1.5 <= current <= 3.5 else 2.5 }} {% endif %} alarm_hour: >- {{ ((as_datetime(trigger.calendar_event.start) | as_local) - timedelta(hours=new_buffer | float)).hour }} alarm_min: >- {{ ((as_datetime(trigger.calendar_event.start) | as_local) - timedelta(hours=new_buffer | float)).minute }} event_title: >- {{ trigger.calendar_event.summary | replace(‘,’, ‘’) | replace(‘:’, ‘’) }} - alias: Update the dashboard slider action: input_number.set_value target: entity_id: input_number.alarm_wake_up_time_buffer data: value: ‘{{ new_buffer | float }}’ - alias: Send the alarm command action: notify.mobile_app_wreckedcarzz_phone data: message: command_activity data: ttl: 0 priority: high intent_action: android.intent.action.SET_ALARM intent_extras: >- android.intent.extra.alarm.HOUR:{{ alarm_hour }},android.intent.extra.alarm.MINUTES:{{ alarm_min }},android.intent.extra.alarm.MESSAGE:{{ event_title }},android.intent.extra.alarm.SKIP_UI:true
Then I created the necessary helper (input_number.alarm_wake_up_time_buffer) for how early to set the alarm at runtime. Integrate CalDav of course, syncing your calendars to HA, and adjust the automation script as needed. Make sure HA can run in the background/is not limited by battery optimization.
Boom, with all that in-place, I just set my events into my calendar, they sync, HA triggers a couple hours before I need to wake up, it sets the alarm, and I get woken up at the planned time.
I use the Google clock, so no promises for any other system, but I’ve been using this for 6+ months and it’s been great. It does add a point of failure (server/HA freezes; internet outage when the automation triggers) but it hasn’t happened yet, just hypotheticals.
needanke@feddit.org 1 week ago
I did not know homeassistant could et alarms, that’s so cool!