Wake up to configurable actions at next alarm (android)

Hello op00,

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?

Thanks in advance again!

Greetz,

Sarnog.

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.

Don’t make it a zone condition, but a state condition based on person.entity (home or not_home).

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

try this, it’s checking state

Invalid blueprint: missing input definition person

my bad, it should be fixed now

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).

1 Like

Thanks a lot! It’s accepting the blueprint now. I’ll test it in the comming days… Many thanks again for the contribution and quick responces!

1 Like

Hello

When importing the blueprint i get the following error:

Invalid blueprint: extra keys not allowed @ data['blueprint']['author']. Got 'op00'

Are you on the latest Home Assistant version?

Thanks for the automation, it works, but I am not seeing the option to ‘run it only during night time?’

Thank you so much for this, tried to create something similar myself but couldn’t get it to work. Only question I have is, can I set it to only trigger on the first alarm for the day? I usually have a few alarms in the morning for various things but don’t want the actions from this to trigger every time a new alarm goes off.

Wouldn’t know an easy way to implement this. The companion app sensor next alarm only has the date time value. I wish there was alarm name sent with it to. You could open a feature request, if they could implement an additional attribute such as alarm name. With that this blueprint could only trigger for a specific alarm.

Maybe you can make you own automation to enable and disable this automation for time range you’d like.

Thank you for this automation, it is almost exactly what I am looking for. My use case is I would like to open my curtains 10-15 minutes before my alarm goes off to wake us up gently. This means I would like it to only trigger if it’s light enough outside to wake me up and not too much later.

The one change I would like to request is rather than just a boolean for the active range, I would love to be able to specify sunrise to noon or sunrise to sunrise + offset.

you can add to the action an if (sun) condition, should give you all that.

I missed that conditions are available under actions. Thank you!

@dmulligan @Sh500 @Sarnog and everone : check out my new blueprint. You may be happier with this one: Adjustable Wake-up to Android alarm - Blueprints Exchange - Home Assistant Community (home-assistant.io)

1 Like

thank you so much for that, I am quite new to HASS and this was exactly what I am looking for!
Now my electric floor heating in bathroom switches on automatically 30 minutes before my alarm rings :)!

1 Like