Help with timestamp template

Hi

I want a condition to check that the time is not between input_datetime.skema_morgen_slut_kl and input_datetime.skema_eftermiddag_start_kl

how would the template look like ? a got no clue :slight_smile:

For Input datetime helpers with date and time or just date you can use:

condition:
  - condition: template
    value_template: >
      {{ now() > states('input_datetime.skema_morgen_slut_kl') | as_datetime | as_local or 
      now() < states('input_datetime.skema_eftermiddag_start_kl') | as_datetime | as_local}}

or

condition:
  - condition: template
    value_template: >
      {{ not ( states('input_datetime.calendar_add_event_start_time') | as_datetime | as_local
      < now() <= states('input_datetime.skema_morgen_slut_kl') | as_datetime | as_local) }}

For time-only Input datetime helpers you can use a Time condition with a Not condition

condition:
  - not:
    - condition: time
      after: "input_datetime.calendar_add_event_start_time"
      before: "input_datetime.skema_morgen_slut_kl"

or a Template condition with the today_at() function:

condition:
  - condition: template
    value_template: >
      {{ not ( today_at(states('input_datetime.calendar_add_event_start_time'))
      < now() <= today_at(states('input_datetime.skema_morgen_slut_kl')) ) }}
1 Like

WOW !!! Thanks !