I’ve been away from HA for a while so I’m very rusty!
I’d also like to have the pushbullet notification message read either grey or green bin, based on which condition triggered it?
I canake it work using 2 separate automations, but feel like it can be achieved in 1?
Any help much appreciated
Also, you might as well have your message tell you which bin to take out.
action:
- data_template:
message: >
Take the
{% if (state_attr('sensor.grey_bin', 'days')|int) == 1 %} GREY
{% else %} GREEN
{% endif %}
Bin out
title: Home Assistant
service: notify.pushbullet
Thanks, I figured the or condition out myself
I was using the GUI editor which isn’t as powerful as direct yaml I guess.
For the notification data template I’m getting an error:
can not read a block mapping entry; a multiline key may not be an implicit key at line 84, column 10:
title: Home Assistant
^
Yeah I figured it was an indentation error… but I’m still failing
action:
service: notify.pushbullet
- data_template:
message: >
Take the
{% if (state_attr('sensor.grey_bin', 'days')|int) == 1 %} GREY
{% else %} GREEN
{% endif %}
Bin out
title: Home Assistant
Service should be indented…and have the dash if you move it up there. Or just remove the dash because it’s only a single action.
action:
- service: notify.pushbullet
data_template:
message: >
Take the
{% if (state_attr('sensor.grey_bin', 'days')|int) == 1 %} GREY
{% else %} GREEN
{% endif %}
Bin out
title: Home Assistant
Two other ways to structure the template (using inline-if):
action:
- service: notify.pushbullet
data_template:
title: Home Assistant
message: >
{% set d = state_attr('sensor.grey_bin', 'days')|int %}
Take the {{ 'GREY' if d == 1 else 'GREEN' }} bin out
action:
- service: notify.pushbullet
data_template:
title: Home Assistant
message: "Take the {{ 'GREY' if (state_attr('sensor.grey_bin', 'days')|int) == 1 else 'GREEN' }} bin out"
Yeah ok, makes sense.
I currently have only 1 automations.yaml file.
At some point I’ll get round to splitting them out, but I’m doing a full reinstall of my system so just wanted to get it up and running.