Hi, I’m new in YAML and HA programming.
I have automation which notifies if next day is garbage collection day.
5 different types of garbage are being collected, sometimes 2-3 types same day.
Action section of automation:
action:
- if:
- condition: template
value_template: >-
{{ state_attr('sensor.glass_and_metal','days_to_pickup') | string == '1' }}
then:
- service: notify.mobile_app_phone
data:
message: "Garbage collection tomorrow: glass and metal."
title: Home Assistant - garbage collection
- if:
- condition: template
value_template: >-
{{ state_attr('sensor.garbage_foodwaste','days_to_pickup') | string == '1' }}
then:
- service: notify.mobile_app_phone
data:
message: "Garbage collection tomorrow: food waste."
title: Home Assistant - garbage collection
- if:
- condition: template
value_template: >-
{{ state_attr('sensor.garbage_paper','days_to_pickup') | string == '1' }}
then:
- service: notify.mobile_app_phone
data:
message: "Garbage collection tomorrow: paper."
title: Home Assistant - garbage collection
- if:
- condition: template
value_template: >-
{{ state_attr('sensor.garbage_plastic','days_to_pickup') | string == '1' }}
then:
- service: notify.mobile_app_phone
data:
message: "Garbage collection tomorrow: plastic."
title: Home Assistant - garbage collection
- if:
- condition: template
value_template: >-
{{ state_attr('sensor.garbage_mixed','days_to_pickup') | string == '1' }}
then:
- service: notify.mobile_app_phone
data:
message: "Garbage collection tomorrow: mixed."
title: Home Assistant - garbage collection
Currently I’m getting notification for each type of garbage collection separately. My goal is to have just one notification with all types to be collected next day separated by new line.
I know I need to use variable and concatenate string for every if / then condition but how to do that then?