blueprint:
name: Wake up to configurable actions at next alarm
description:
Wakes you up to configurable actions at your phones next alarm with
an offset
domain: automation
author: op00
source_url: https://community.home-assistant.io/t/wake-up-to-configurable-actions-at-next-alarm-android/438300
input:
offset:
name: Offset
description: Set a offset in seconds to the next alarm. When (before) the action should run
selector:
number:
min: 0.0
max: 3600.0
mode: box
step: 1.0
unit_of_measurement: Seconds
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 the person need to be for the action(s) to run
selector:
entity:
integration: zone
multiple: false
sunset_sunrise_active:
name: Sunset Sunrise
description: Only run during night time (between sun set and sun rise)
default: false
selector:
boolean:
people:
name: People
description: Actions only when this person is in the location specified
selector:
entity:
integration: person
multiple: false
actions:
name: Actions
description: Actions to run before alarm goes off
default: []
selector:
action: {}
variables:
offset: !input offset
sunset_sunrise_active: !input sunset_sunrise_active
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
- condition: or
conditions:
- condition: template
value_template: "{{ sunset_sunrise_active == false }}"
- condition: sun
before: sunrise
after: sunset
sequence: !input actions
default: []
mode: single
I do not understand what should be: An auxiliary date and time object?
It’s empty there, and I can’t understand what I need to add? Time sensors from the home assistant cannot be selected there.
Goto: Settings/Devices & Services/Helpers to create a helper. This is required to store the date and time of the alarm with the offset. Think of it as a variable.
e.g. that’s mine
Thanks you very much for the blueprint, i really like it! Onlything is mis is a condition that it gets triggerd only after sunset and before sunrise. Is it possible to add this? And how?
@Sarnog: I wish I could get up only when the sun has risen. You must live a luxurious life.
Anyhow, I have updated the blueprint to include this feature. Please test it and let me know.
Hahaha, well it’s not that luxurious as it sounds. I work in shifts, so sometimes i need to sleep in daylight and there for also wake up in day light. Thanks for the change! i really appriciate it.
I tested the automation this morning, but it’s not working unfortunatly.
I tried to multiple light entities and switched the sunset / sunrise option, but neighter of the sun options, triggers the light to go on.
It seems the automation is failing somewhere. Can you please review the automation?
Sarnog, I think I’m having the same issue possibly.
Looking at the trace from when the automation was supposed to run I see the following error: Error: In 'zone' condition: error matching person.ben with zone.home: entity person.ben has no 'latitude' attribute
This looks to be related to this issue:
I’ll probably just tweak the blueprint to remove those conditions and use my own in a subsequent automation.
It seems like that Sarnog had the same issue. I DM’d him/her and came to same solution. Maybe i should make the Zone thing optional in the blueprint. Don’t know how yet though.
blueprint:
name: Wake up to configurable actions at next alarm V2
description:
Wakes you up to configurable actions 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 action should run
selector:
number:
min: 0.0
max: 3600.0
mode: box
step: 1.0
unit_of_measurement: Seconds
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
active_hours:
name: Active hours
description: Only between set values below
default: false
selector:
boolean:
person:
name: Person
description: Select the person for the state condition
selector:
entity:
integration: person
multiple: false
person_state:
name: State of the person
description: condition as to when the automation runs for the person selected
selector:
select:
mode: dropdown
options:
- label: Home
value: home
- label: Away
value: not_home
- label: Unavailable
value: unavailable
- label: Unknown
value: unknown
actions:
name: Actions
description: Actions to run before alarm goes off
default: []
selector:
action: {}
variables:
offset: !input offset
hello: !input person
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: state
entity_id: !input person
state: !input person_state
- condition: or
conditions:
- condition: template
value_template: "{{ active_hours == false }}"
- condition: sun
before: sunrise
after: sunset
sequence: !input actions
default: []
mode: single
Do i -redownload this blueprint via the link on top of this post, or is it a separate one? Because you named it v2, and it seems i get the same one as before using zone…
It’s a separate one and I want to keep it that way. As I guess the original works for most users and it supports zones. These import links, AFAIK only work with one blueprint per forum topic.
Create a yaml file in your /blueprints/automation/ folder and copy the text into it. (Studio Code Server addon will be your friend).