I’m rewriting some of my automations to make them more efficient and do some consolidation. I’m trying to use variables to store things like tts message and when I go to save the automation, it wipes out the code. Am I missing something? Do I need to do a separate file for these type of automations?
I should mention, the offending automation is using a calendar trigger.
Here is the code i’m trying to use.
trigger:
- platform: calendar
event: start
offset: "0:0:0"
entity_id: calendar.chores
id: first
variables:
tts_message: {{ state_attr('calendar.chores', 'description') }}, it is your week to wash and dry the towels, and the fold them and put them away.
e_message: [CHORE NOTIFICATION] {{ state_attr('calendar.chores', 'description') }}, it's your week to do {{ state_attr('calendar.chores', 'message') }}
e_message_target: {% if state_attr('calendar.chores', 'description') == "kidsname" %}xxxxxxxxxx{% elif state_attr('calendar.chores', 'description') == "kidsname" %}xxxxxxxxxx{% endif %}
mobile_app_target: {% if state_attr('calendar.chores', 'description') == "kidsname" %}notify.mobile_app_xxx_ha_app{% else %}notify.mobile_app_xxxx{% endif %}
- platform: calendar
event: start
offset: "1:0:0"
entity_id: calendar.chores
id: second
variables:
tts_message: {{ state_attr('calendar.chores', 'description') }}, it is your week to wash and dry the towels, and the fold them and put them away.
e_message: [CHORE NOTIFICATION] {{ state_attr('calendar.chores', 'description') }}, it's your week to do {{ state_attr('calendar.chores', 'message') }}
e_message_target: {% if state_attr('calendar.chores', 'description') == "kidsname" %}xxxxxxxxxx{% elif state_attr('calendar.chores', 'description') == "kidsname" %}xxxxxxxxxx{% endif %}
mobile_app_target: {% if state_attr('calendar.chores', 'description') == "kidsname" %}notify.mobile_app_xxx_ha_app{% else %}notify.mobile_app_xxxx{% endif %}
- platform: calendar
event: start
offset: "2:0:0"
entity_id: calendar.chores
id: third
variables:
tts_message: {{ state_attr('calendar.chores', 'description') }}, it is your week to wash and dry the towels, and the fold them and put them away.
e_message: [CHORE NOTIFICATION] {{ state_attr('calendar.chores', 'description') }}, it's your week to do {{ state_attr('calendar.chores', 'message') }}
e_message_target: {% if state_attr('calendar.chores', 'description') == "kidsname" %}xxxxxxxxxx{% elif state_attr('calendar.chores', 'description') == "kidsname" %}xxxxxxxxxx{% endif %}
mobile_app_target: {% if state_attr('calendar.chores', 'description') == "kidsname" %}notify.mobile_app_xxx_ha_app{% else %}notify.mobile_app_xxxx{% endif %}
- platform: calendar
event: start
offset: "4:0:0"
entity_id: calendar.chores
id: final
variables:
tts_message: {{ state_attr('calendar.chores', 'description') }}, it is your week to wash and dry the towels, and the fold them and put them away.
e_message: [CHORE NOTIFICATION] {{ state_attr('calendar.chores', 'description') }}, it's your week to do {{ state_attr('calendar.chores', 'message') }}
e_message_target: {% if state_attr('calendar.chores', 'description') == "kidsname" %}xxxxxxxxxx{% elif state_attr('calendar.chores', 'description') == "kidsname" %}xxxxxxxxxx{% endif %}
mobile_app_target: {% if state_attr('calendar.chores', 'description') == "kidsname" %}notify.mobile_app_xxx_ha_app{% else %}notify.mobile_app_xxxx{% endif %}
condition:
- condition: template
value_template: "{{ state_attr('calendar.chores', 'message') == 'Towels' }}"
- condition: state
entity_id: input_boolean.audible_notifications
state: "on"
- condition: or
conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.quiet_time_weekday
state: "off"
- condition: time
weekday:
- sun
- mon
- tue
- wed
- thu
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.quiet_time_weekend
state: "off"
- condition: time
weekday:
- fri
- sat
action:
- if:
- condition: template
value_template: "{{ state_attr('calendar.chores', 'description') == \"kidsname\" }}"
then:
- service: notify.textbelt
data:
target: xxxxxxxxxx
message: >-
[CHORE NOTIFICATION] {{ state_attr('calendar.chores',
'description') }}, it is your week to {{
state_attr('calendar.chores', 'message') }}
alias: Notify kidsname via Text
mode: single