Sandman Doppler Alarm Clock Actions (Active, Snoozed, Turned Off, Pre-Alarm)

Blueprint to perform actions based on active, snoozed, unarmed (turned off), and user-set pre-alarm statuses. Must use the custom component here: GitHub - pa-innovation/ha-doppler: Custom Home Assistant component for Sandman Doppler clocks to add your Doppler to your HA instance.

It is highly recommended to change your scan interval polling time in /custom_components/sandman_doppler/init.py under SCAN_INTERVAL = timedelta(seconds=60) to 5-10 seconds to more frequently monitor the status of the alarm. This will need to be done again each time the integration is updated.

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

blueprint:
  name: Sandman Doppler Alarm Actions
  description: Automations for the Sandman Doppler Alarm Clock. NOTE It is highly beneficial to change the polling interval from 60 to 5-10 seconds. You can do that under /custom_components/sandman_doppler/__init__.py under SCAN_INTERVAL = timedelta(seconds=60). This will need to be done again each time the integration is updated, though.
  domain: automation
  input:
    alarm:
      name: Alarm
      description: Alarm you want to automate from
      selector:
        entity:
          integration: sandman_doppler
          domain: switch
    active_actions:
      name: Alarm Active Actions (Optional)
      description: What you want to happen when the alarm goes off. Use Choose and Conditions to perform different actions based on time, states, days of the week etc. It also may be easier to use scripts this action can fire via a call service action.
      default: []
      selector:
        action: {}
    snoozed_actions:
      name: Alarm Snoozed Actions (Optional)
      description: What you want to happen when the alarm is snoozed. Use Choose and Conditions to perform different actions based on time, states, days of the week etc. It also may be easier to use scripts this action can fire via a call service action.
      default: []
      selector:
        action: {}
    unarmed_actions:
      name: Alarm Turned Off Actions (Optional)
      description: What you want to happen when the alarm is turned off. Use Choose and Conditions to perform different actions based on time, states, days of the week etc. It also may be easier to use scripts this action can fire via a call service action.
      default: []
      selector:
        action: {}
    pre-alarm_actions:
      name: Pre-Alarm Actions (Optional)
      description: What you want to happen before the alarm goes off. Use Choose and Conditions to perform different actions based on time, states, days of the week etc. It also may be easier to use scripts this action can fire via a call service action.
      default: []
      selector:
        action: {}
    pre-alarm_time:
      name: Pre-alarm Time (Optional, required if Pre-Alarm Actions are set)
      description: How long before the alarm you want the Pre-Alarm Actions to fire
      selector:
        number:
          min: 1
          max: 120
          unit_of_measurement: min

trigger_variables:
  alarm: !input alarm
  pre_alarm_time: !input pre-alarm_time


mode: single
trigger:
  - platform: state
    entity_id: !input alarm
    attribute: status
    to: active
    id: Alarm-Active
    alias: Alarm-Active
  - platform: state
    entity_id: !input alarm
    attribute: status
    to: snoozed
    id: Alarm-Snoozed
    alias: Alarm-Snoozed
    from: active
  - platform: state
    entity_id: !input alarm
    attribute: status
    to: unarmed
    id: Alarm-Turned Off
    alias: Alarm-Turned Off
    from: active
  - platform: state
    entity_id: !input alarm
    attribute: status
    to: unarmed
    id: Alarm-Turned Off
    alias: Alarm-Turned Off
    from: snoozed
  - platform: template
    value_template: "{{ now() + timedelta(minutes=pre_alarm_time) > today_at(state_attr(alarm, 'time')) }}"
    id: Alarm-Pre-Alarm
    alias: Alarm-Pre-Alarm

action:
  - choose:
      - conditions:
          condition: trigger
          id: Alarm-Active
        sequence:
          !input active_actions
      - conditions:
          condition: trigger
          id: Alarm-Snoozed
        sequence:
          !input snoozed_actions
      - conditions:
          condition: trigger
          id: Alarm-Turned Off
        sequence:
          !input unarmed_actions
      - conditions:
          - condition: trigger
            id: Alarm-Pre-Alarm
          - condition: or
            conditions:
              - condition: template
                value_template: "{{ ['Mo','Tu','We','Th','Fr','Sa','Su'][now().weekday()] in state_attr(alarm, 'repeat') }}"
              - condition: template
                value_template: "{{ state_attr(alarm, 'repeat') == [] }}"
          - condition: state
            entity_id: !input alarm
            state: "on"
        sequence:
          !input pre-alarm_actions