#Time Triggers with pre warning Alarm clock with light

1 messages · Page 1 of 1 (latest)

swift bridge
#

Hi, i want to start an automation 20 min bevore the Time Helpers value. I have tried various options but none of them have worked. For example, I would like my alarm clock to switch the light on slowly 20 minutes before the set time.

I tried it via the detour of an additional sensor template helper.

{{ (strptime(states('input_datetime.wecker_1_zeit'), '%H:%M:%S') - timedelta(minutes=20)).strftime('%H:%M') }}

But when I use this in the automation, it is not triggered. The part at the actual time works without any problems.

alias: Wecker 1.2
description: ""
triggers:
  - trigger: time
    at: input_datetime.wecker_1_zeit
    id: Wecker 1 Weckzeit
  - trigger: time
    at: sensor.wecker_1_zeit_minus_20min_3
    id: Wecker 1 Licht an
conditions:
  - condition: state
    entity_id: input_boolean.input_boolean_wecker_aktiv
    state: "on"
  - condition: template
    value_template: "{{ now().strftime('%a').lower() in states('sensor.aktive_wecker_tage') }}"
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Wecker 1 Licht an
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              kelvin: 2000
              brightness_pct: 3
            target:
              entity_id: light.licht
      - conditions:
          - condition: trigger
            id:
              - Wecker 1 Weckzeit
        sequence:
          - action: media_player.volume_set

          - action: spotcast.start

mode: single

I have also tried different variations directly in the automation. Unfortunately, none of them led to success. If possible, I would like to do without an additional helper. If someone could help me with this, I would be very happy.

rare acorn
#

If the input datetime helper is time-only you can use:

  - trigger: template
    value_template: |
      {{ now() >= today_at(states('input_datetime.wecker_1_zeit')) - timedelta(minutes=20) }}
    id: Wecker 1 Licht an

For a date-and-time input datetime:

  - trigger: template
    value_template: |
      {% set time = states('input_datetime.wecker_1_zeit') | as_datetime | as_local %}
      {{ now() >= time - timedelta(minutes=20) }}
    id: Wecker 1 Licht an