❌ deprecated: Wake up to lights at next alarm (android)

:construction: deprecated in favor of Adjustable Wake-up to Android alarm - Blueprints Exchange - Home Assistant Community (home-assistant.io) :construction:

This blueprint wakes you up to lights at your phones next alarm with an offset. There is a more advanced version of this blueprint that allows you to configure the actions. see here: https://community.home-assistant.io/t/wake-up-to-configurable-actions-at-next-alarm-android/438300

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

:tipping_hand_man: Usage

  1. Create Date and/or time entity
    The Automation will use this to store the (phone alarm time - offset)
    No need to manually set a time there.
    Open your Home Assistant instance and show your helper entities.

  2. Enable next alarm sensor on the HA Android App
    HA App → Settings → Companion App → Manage Sensors → Next Alarm → enable

  3. Import the Blueprint
    Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

  4. Create an Automation based on the imported Blueprint Wake up to lights at next alarm
    Open your Home Assistant instance and show your blueprints.

  5. Set an alarm on your phone

:sparkles: Features

  • Offset (how many seconds before the alarm goes off)
  • Target brightness of the lights
  • Transition duration to the target brightness
  • Only runs when a selected person is home (or any other location)

:wrench: Requirements

  • Android phone with mobile app
  • Next alarm sensor activated
  • Date and time helper entity

:hammer_and_wrench: Changelog

  • 2022-07-09: Added unit_of_measurement: “Seconds”

blueprint:
  name: Wake up to lights at next alarm
  description: Wakes you up to lights at your phones next alarm with an offset
  domain: automation
  author: op00
  input:
    offset:
      name: Offset
      description:
        Set a offset in seconds to the next alarm. When (before) the lights
        should turn on
      selector:
        number:
          min: 0.0
          max: 3600.0
          mode: box
          step: 1.0
          unit_of_measurement: "Seconds"
    target_light:
      name: Lights
      description: The lights that will wake you up
      selector:
        target:
          entity:
            domain: light
    transition:
      name: Transition Time
      description:
        Set a transition time in seconds for the lights to go to the target
        brightness
      selector:
        number:
          min: 0.0
          max: 300.0
          mode: slider
          step: 1.0
          unit_of_measurement: "Seconds"
    brightness:
      name: Brightness
      description:
        Number indicating percentage of full brightness, where 0 turns
        the light off, 1 is the minimum brightness and 100 is the maximum brightness
        supported by the light
      selector:
        number:
          min: 0.0
          max: 100.0
          unit_of_measurement: "%"
          mode: slider
          step: 1.0
    alarm_source:
      name: Alarm Source
      description: Select the alarm source
      selector:
        entity:
          integration: mobile_app
          device_class: timestamp
          multiple: false
    alarm_helper:
      name: Alarm Helper
      description: Select the date time helper
      selector:
        entity:
          integration: input_datetime
          multiple: false
    location:
      name: Location
      description: Location where people need to be for the alarm to go off
      selector:
        entity:
          integration: zone
          multiple: false
    people:
      name: People
      description: Alarm only when these people are home
      selector:
        entity:
          integration: person
          multiple: false
  source_url: https://community.home-assistant.io/t/wake-up-to-lights-at-next-alarm-android/438277
variables:
  offset: !input offset
trigger:
  - platform: time
    at: !input alarm_helper
    id: wake_up
  - platform: state
    entity_id:
      - !input alarm_source
    id: helper_update
action:
  - choose:
      - conditions:
          - condition: trigger
            id: helper_update
          - condition: template
            value_template:
              '{{ trigger.to_state.state not in ["unknown","unavailable"]
              }}'
        sequence:
          - service: input_datetime.set_datetime
            data:
              timestamp: "{{ (as_timestamp(trigger.to_state.state) |int ) - (offset)}}"
            target:
              entity_id: !input alarm_helper
      - conditions:
          - condition: trigger
            id: wake_up
          - condition: zone
            entity_id: !input people
            zone: !input location
        sequence:
          - service: light.turn_on
            data:
              transition: !input transition
              brightness_pct: !input brightness
            target: !input target_light
    default: []
mode: single

:construction: ToDo

  • :white_check_mark: ToDo list
  • :white_check_mark: Create my link to import the blueprint
  • :black_square_button: Spellcheck

🧑🏼‍🤝‍🧑🏻 Contributions

  • Very welcomed and please do
2 Likes

Just used this and it worked well. One thing to others so it’s clear: The required helper is one you need to create to set the new trigger time.

Hello, could you explain me how to create this new trigger time please ?

The required helper is one you need to create to set the new trigger time

Actually it is being used as a temporary storage of the the wake up time. No need to set the time there. The automation runs when there is a new alarm set on the phone. It will update the time minus the configured offset.
So make sure you have enabled the sensor.
HA App → Settings → Companion App → Manage Sensors → Next Alarm → enable

To create the helper, go to: Open your Home Assistant instance and show your helper entities.

Hope that helps. I’ll try to add this to the first post for clarification.

see the updated first post, let me know if that helps

I’m returning to this older topic because I’ve run into the problem that the time of the next alarm is not only set by the alarm, but also by calendar events.
I’m on home office, I get notifications for appointments and wonder why someone keeps turning on the bedroom light :-). So that’s why.
The solution is quite simple. One of the attributes (Package) of the next alarm sensor is which application set the next alarm.
I am attaching the whole automation below.
My contribution is these lines:

  - condition: state
    entity_id: sensor.honzovo_mobil_next_alarm
    attribute: Package
    state: com.sec.android.app.clockpackage

The complete automation in YAML:

alias: Honzovo budík
description: ""
trigger:
  - platform: time
    at: sensor.honzovo_mobil_next_alarm
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: sensor.honzovo_mobil_wifi_connection
        state: blabla
      - condition: state
        state: blablabla
        entity_id: sensor.honzovo_mobil_wifi_connection
  - condition: state
    entity_id: sensor.honzovo_mobil_next_alarm
    attribute: Package
    state: com.sec.android.app.clockpackage
action:
  - service: light.turn_on
    metadata: {}
    data:
      brightness_step_pct: 5
    target:
      entity_id: light.bedroom_light
mode: single

Thanks @Johny5,
btw: i have deprecated This in favor of Adjustable Wake-up to Android alarm - Blueprints Exchange - Home Assistant Community (home-assistant.io)

To your point: I have been looking into this a while ago, the problem is there are different stock clocks out there. In my case it’s, com.google.android.deskclock.

I guess the options are:

  • bake in a list of all various android stock alarm apps
  • exclude calendar events with a (un-) match rule on the package name.
  • somehow read the current sensor state with the attribute
  • The HA app would need to have create separate sensors

Getting trouble when I don’t set an alarm. it sets the the time helper automatic to 12:30 for no reason I can find. Works great when I set an alarm every day

are you using this deprecated blueprint ?
The new Adjustable Wake-up to Android alarm should deal with disabling alarms.

Yes I do but I found out a samsung update always triggers a alarm at 12:30 so I updated and fixed the problem