Mabaelst
(Bart Teuwen)
August 4, 2023, 6:37pm
1
Hello everyone,
I’m trying to create an actionable notification but I keep getting an error message: ‘Error: In ‘template’ condition: UndefinedError: ‘wait’ is undefined’. What’s wrong here?
Below my automation:
alias: aaaastofgaa
description: ""
trigger:
- platform: state
entity_id:
- camera.whoopsie
attribute: vacuum_position
condition:
- condition: template
value_template: "{{state_attr('camera.whoopsie','vacuum_position').x >=27000}}"
action:
- service: notify.bart_ios
data:
message: Test
title: Stofzuiger
data:
image: /local/afbeeldingen/bart.jpg
actions:
- action: WOOPSIE_GA_VERDER
title: Whoopsie Ga Verder
- action: WOOPSIE_GA_NAAR_DOCK
title: Whoopsie Ga Naar Dock
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{WOOPSIE_GA_NAAR_DOCK}}"
id: Dock
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{WOOPSIE_GA_VERDER}}"
id: Verder
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
continue_on_timeout: false
- choose:
- conditions:
- condition: template
value_template: "{{wait.trigger.id == 'Dock'}}"
sequence:
- service: vacuum.return_to_base
data: {}
target:
entity_id: vacuum.whoopsie
mode: single
Thanks for all responses
tom_l
August 4, 2023, 6:49pm
2
Your entire wait for trigger block is indented too far. It should be under the action block, not the actions block inside the message.
action:
- service: notify.bart_ios
data:
message: Test
title: Stofzuiger
data:
image: /local/afbeeldingen/bart.jpg
actions:
- action: WOOPSIE_GA_VERDER
title: Whoopsie Ga Verder
- action: WOOPSIE_GA_NAAR_DOCK
title: Whoopsie Ga Naar Dock
- wait_for_trigger:
- platform: event
event_type: etc...
...
- choose:
- conditions:
- condition: template
value_template: etc...
See the example here: Actionable Notifications | Home Assistant Companion Docs
Mabaelst
(Bart Teuwen)
August 4, 2023, 7:41pm
3
Thank you very much for your response.
This worked great for me, but now I’m running into another problem, the automation always chooses the first option and never the second. What I don’t see here, my automation now looks like this:
alias: aaaastofgaa
description: ""
trigger:
- platform: state
entity_id:
- camera.whoopsie
attribute: vacuum_position
condition:
- condition: template
value_template: "{{state_attr('camera.whoopsie','vacuum_position').x >=27000}}"
action:
- service: notify.bart_ios
data:
message: Test
title: Stofzuiger
data:
image: /local/afbeeldingen/bart.jpg
actions:
- action: WOOPSIE_GA_VERDER
title: Whoopsie Ga Verder
- action: WOOPSIE_GA_NAAR_DOCK
title: Whoopsie Ga Naar Dock
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: WOOPSIE_GA_VERDER
id: Verder
- platform: event
event_type: mobile_app_notification_action
event_data:
action: WOOPSIE_GA_NAAR_DOCK
id: Dock
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
continue_on_timeout: false
- choose:
- conditions:
- condition: template
value_template: "{{wait.trigger_id == Verder}}"
sequence:
- service: vacuum.start
data: {}
target:
entity_id: vacuum.whoopsie
- conditions:
- condition: template
value_template: "{{wait.trigger_id == Dock}}"
sequence:
- service: vacuum.return_to_base
data: {}
target:
entity_id: vacuum.whoopsie
mode: single
Mabaelst
(Bart Teuwen)
August 4, 2023, 7:50pm
4
Ok, thanks for your help but I already found the problem. So the correct automation is:
alias: aaaastofgaa
description: ""
trigger:
- platform: state
entity_id:
- camera.whoopsie
attribute: vacuum_position
condition:
- condition: template
value_template: "{{state_attr('camera.whoopsie','vacuum_position').x >=27000}}"
action:
- service: notify.bart_ios
data:
message: Test
title: Stofzuiger
data:
image: /local/afbeeldingen/bart.jpg
actions:
- action: WOOPSIE_GA_VERDER
title: Whoopsie Ga Verder
- action: WOOPSIE_GA_NAAR_DOCK
title: Whoopsie Ga Naar Dock
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: WOOPSIE_GA_VERDER
id: Verder
- platform: event
event_type: mobile_app_notification_action
event_data:
action: WOOPSIE_GA_NAAR_DOCK
id: Dock
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
continue_on_timeout: false
- choose:
- conditions:
- condition: template
value_template: "{{wait.trigger.id == 'Verder'}}"
sequence:
- service: vacuum.start
data: {}
target:
entity_id: vacuum.whoopsie
- conditions:
- condition: template
value_template: "{{wait.trigger.id == 'Dock'}}"
sequence:
- service: vacuum.return_to_base
data: {}
target:
entity_id: vacuum.whoopsie
mode: single