sorry I trimmed the code down as its quite large, here’s the full version:
- alias: "Family Greeting"
trigger:
- platform: state
entity_id:
- input_boolean.her_present
- input_boolean.me_present
from: 'off'
to: 'on'
for: '00:01:45'
condition:
- condition: time
after: '09:00:00'
before: '22:00:01'
action:
- delay: "00:00:05"
- wait_template: "{{ is_state('script.say_greeting', 'off') }}"
- wait_template: "{{ is_state('binary_sensor.fibaro_system_fgms001zw5_motion_sensor_sensor', 'on') }}"
- delay: "00:00:25"
- service: script.say_greeting
data_template:
entity_id: "media_player.mr_s_echo_dot"
person: >
{{ trigger.to_state.name }}
{%- for s in states.input_boolean
|rejectattr('entity_id','eq',trigger.entity_id)
|selectattr('state','eq','on')
if '_present' in s.entity_id and
(now() - s.last_changed).total_seconds() < 2 -%}
{{ (' and ' if loop.last else ', ') ~ s.name }}
{%- endfor %}
message: >
{{ ["Welcome home PERSON, how about some BBC Radio 2, you've earned it!",
"Welcome home PERSON, time for some relaxing tunes",
"Hi PERSON The fridge & cooker had a fight while you were out, please don't leave again!",
"Hey PERSON Thank goodness you're back, I have a list of jobs for you to do.",
"Welcome home PERSON, you get the kettle on and I'll sort the tunes out",
"Welcome home PERSON, I bet your feet are cold so I'll set the heating to full power captain!",
"Hey PERSON Good to have you back, the kettle is on standbye",
"Welcome home PERSON, mine is a large tea with 15 sugars",
"Welcome home PERSON, shoes off, kettle on and how about some radio?",
"Welcome home PERSON, I think there is a spoon in the knife draw. Can you check?",
"Welcome home PERSON, I've been working on a joke. Here goes. A furniture store keeps calling me, All I wanted was, one, night, stand",
"Welcome home PERSON, I've been working on a new joke. Here goes. I used to work, in a shoe recycling shop, It was sole destroying",
"Welcome home PERSON, I think I've cracked this joke thing. Here goes. Why did the scarecrow win an award? Because he was outstanding in his field",
] | random }}
- delay: '00:00:05'
- service: media_player.volume_set
entity_id: media_player.family_room
data:
volume_level: 0.16
- condition: template
value_template: "{{ is_state('media_player.family_room', 'idle') or is_state('media_player.family_room', 'paused') or is_state('media_player.family_room', 'off) }}"
- service: media_player.select_source
entity_id: media_player.family_room
data:
source: "BBC Radio 2"
if I remove the condition element in the action part, the error no longer shows.