Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
123 lines (115 sloc) 4.44 KB
---
automation:
- alias: event_reminder_1
trigger:
platform: template
value_template: >-
{{ is_state('sensor.event_reminder_1_1',states('sensor.time'))
or is_state('sensor.event_reminder_1_2',states('sensor.time')) }}
condition:
condition: and
conditions:
# Is today one of the selected days?
- condition: template
value_template: >
{% set day_name = now().strftime("%A")|lower -%}
{%- if day_name == 'monday' and is_state('input_boolean.event_reminder_1_mon','on') -%}{{true}}
{%- elif day_name == 'tuesday' and is_state('input_boolean.event_reminder_1_tue','on') -%}{{true}}
{%- elif day_name == 'wednesday' and is_state('input_boolean.event_reminder_1_wed','on') -%}{{true}}
{%- elif day_name == 'thursday' and is_state('input_boolean.event_reminder_1_thu','on') -%}{{true}}
{%- elif day_name == 'friday' and is_state('input_boolean.event_reminder_1_fri','on') -%}{{true}}
{%- elif day_name == 'saturday' and is_state('input_boolean.event_reminder_1_sat','on') -%}{{true}}
{%- elif day_name == 'sunday' and is_state('input_boolean.event_reminder_1_sun','on') -%}{{true}}
{%- else -%}{{false}}{%- endif %}
action:
- service_template: >
{% if is_state('input_boolean.event_reminder_1_skipnext', 'on') %}
script.event_reminder_skipnext
{% else %}
script.event_reminder_announce
{% endif %}
data_template:
media_player: "{{ states('input_select.event_reminder_1_echo') }}"
skipnext: >
{% if is_state('sensor.event_reminder_1_2',states('sensor.time')) %}
input_boolean.event_reminder_1_skipnext
{% endif %}
message: >-
{% if is_state('sensor.event_reminder_1_1',states('sensor.time')) %}
{{ states('input_text.event_reminder_1_1') }}
{% else %}
{{ states('input_text.event_reminder_1_2') }}
{% endif %}
# Run this routine for the second reminder, but not the first.
- condition: template
value_template: "{{ is_state('sensor.event_reminder_1_2',states('sensor.time')) }}"
- delay:
minutes: 2
- service: script.goodbye_routine
input_boolean:
event_reminder_1_skipnext:
name: Skip Next Reminder
icon: mdi:alarm-check
event_reminder_1_mon:
name: Monday
icon: mdi:checkbox-marked-circle
event_reminder_1_tue:
name: Tuesday
icon: mdi:checkbox-marked-circle
event_reminder_1_wed:
name: Wednesday
icon: mdi:checkbox-marked-circle
event_reminder_1_thu:
name: Thursday
icon: mdi:checkbox-marked-circle
event_reminder_1_fri:
name: Friday
icon: mdi:checkbox-marked-circle
event_reminder_1_sat:
name: Saturday
icon: mdi:checkbox-marked-circle
event_reminder_1_sun:
name: Sunday
icon: mdi:checkbox-marked-circle
input_datetime:
event_reminder_1_1:
name: First Announcement
has_date: false
has_time: true
event_reminder_1_2:
name: Second Announcement
has_date: false
has_time: true
input_select:
event_reminder_1_echo:
name: Announce on which Echo(s)?
options: !include ../../templates/speech/tts_rooms.yaml
icon: mdi:amazon-alexa
input_text:
event_reminder_1_1:
name: First Announcement
event_reminder_1_2:
name: Second Announcement
sensor:
- platform: template
sensors:
event_reminder_1_1:
entity_id: input_datetime.event_reminder_1_1
friendly_name: First Time
icon_template: mdi:clock-outline
value_template: >-
{% set reminder_time = states("input_datetime.event_reminder_1_1") -%}
{%- set reminder_hour = reminder_time.split(':')[0] -%}
{%- set reminder_minutes = reminder_time.split(':')[1] -%}
{{ "%0.02d:%0.02d" | format(reminder_hour|int, reminder_minutes|int) }}
- platform: template
sensors:
event_reminder_1_2:
entity_id: input_datetime.event_reminder_1_2
friendly_name: First Time
icon_template: mdi:clock-outline
value_template: >-
{% set reminder_time = states("input_datetime.event_reminder_1_2") -%}
{%- set reminder_hour = reminder_time.split(':')[0] -%}
{%- set reminder_minutes = reminder_time.split(':')[1] -%}
{{ "%0.02d:%0.02d" | format(reminder_hour|int, reminder_minutes|int) }}
You can’t perform that action at this time.