Works fine if triggered manually. But will not trigger at time set. Any help please
The Automation
- id: 'xxxxxxxxxxxxxxx'
alias: Days to Next Appt
description: ''
trigger:
- platform: time
at: '17:58:00'
condition:
- condition: template
value_template: '"{{ states.sensor.days_to_next_appt.state | int > 0 and states.sensor.days_to_next_appt.state
| int < 4 }}"'
action:
- service: media_player.volume_set
data:
entity_id: media_player.home
volume_level: 1
- service: tts.say
data:
entity_id: media_player.home
message: Appointment Reminder.... {{ states.sensor.next_appt_message.state }}
with {{ states.sensor.next_appt_description.state }} is {{ states.sensor.days_to_next_appt.state
}}
mode: single
The Sensors * note all sensors seem to be working *
################# Appontments ####################################
- platform: template
sensors:
next_appt_time:
friendly_name: "Next Appt Time"
value_template: "{{ states.calendar.xxxxxxxxxxxx_gmail_com.attributes.start_time | timestamp_custom('%I:%M %p') }}"
- platform: template
sensors:
next_appt_message:
friendly_name: "Next Appt Type"
value_template: "{{ states.calendar.xxxxxxxxxxx_gmail_com.attributes.message }}"
- platform: template
sensors:
next_appt_description:
friendly_name: "Next Appt Description"
value_template: "{{ states.calendar.xxxxxxxxxxx_gmail_com.attributes.description }}"
- platform: template
sensors:
days_to_next_appt:
friendly_name: "Days to Next Appt"
value_template: >
{% set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
{% set event = states('sensor.next_appt_date_time') | as_timestamp %}
{% set int = ((event - midnight) // 86400) | int %}
{% if int == 0 %}
0
{% elif int == 1 %}
In {{ int }} Day
{% elif int == 2 %}
In {{ int }} Days
{% else %}
In {{ int }} Days
{% endif %}