ptdalen
December 19, 2018, 12:06am
1
So I have many automations that send notifications to my wife and myself using pushbullet
here is an example
- service: notify.pushbullet_notifications
data_template:
target:
- !secret pauls_secret_email
- !secret tracys_secret_email
title: Zigbee Devices Offline
message: message here
Sometimes I would like to be able to turn off notifications for one person or the other, but just for a while. I do have a input boolean for each person named “enable_notifications_paul” , etc. Was wondering if anyone had a recommendation on a conditional template for the “target:” based on that?
ptdalen
December 19, 2018, 6:57pm
2
I have this from a different automation
condition: "{{ is_state('input_boolean.notify_paul','on') }}"
and also
condition: "{{ is_state('input_boolean.notify_tracy','on') }}"
Could I do a template within a template for the target: based on these?
Just trying to wrap my head aroind the template within a template
ptdalen
December 19, 2018, 7:06pm
3
Does this look like it would work? I’ll test out later tonight,but was looking for a warm fuzzy.
- service: notify.pushbullet_notifications
data_template:
target: >
{% if states('input_boolean.notify_paul') == 'on' and states('input_boolean.notify_tracy') == 'on' %}
- !secret pauls_secret_email
- !secret tracys_secret_email
{% elif states('input_boolean.notify_paul') == 'on' and states('input_boolean.notify_tracy') == 'off' %}
- !secret pauls_secret_email
{% elif states('input_boolean.notify_paul') == 'off' and states('input_boolean.notify_tracy') == 'on' %}
- !secret tracys_secret_email
{% else %}
- noone
{% endif %}
title: Zigbee Devices Offline
message: message here
firstof9
(firstof9)
December 19, 2018, 7:08pm
4
Try something like this:
- service: notify.pushbullet_notifications
data_template:
target: >
{% if states('input_boolean.notify_paul') == 'on' %}
- !secret pauls_secret_email
{% elif states('input_boolean.notify_tracy') == 'on' %}
- !secret tracys_secret_email
{% endif %}
title: Zigbee Devices Offline
message: message here
To simplify.
ptdalen
December 19, 2018, 7:13pm
5
If they both had the input boolean turned on, would both receive the message? If so, that looks perfect
ptdalen
December 19, 2018, 7:18pm
7
Great, thanks. I’ll try it out tonight and report back as the solution or not.
sholofly
(Rudolf Offereins)
December 19, 2018, 7:35pm
8
In your example tracy will never receive an email when paul does. Although i’m not so good at the templates i guess something like this would work, but i’m not sure what happens when there are no targets defined:
- service: notify.pushbullet_notifications
data_template:
target: >
{% if states('input_boolean.notify_paul') == 'on' %}
- !secret pauls_secret_email
{% endif %}
{% if states('input_boolean.notify_tracy') == 'on' %}
- !secret tracys_secret_email
{% endif %}
title: Zigbee Devices Offline
message: message here
1 Like
firstof9
(firstof9)
December 19, 2018, 8:16pm
9
Ah you’re right, I just threw something together quickly to trim down the ifs for him.
Thanks for the correction.
2 Likes
ptdalen
December 20, 2018, 1:11pm
10
Only issue I have is that it’s not formatting correctly for some reason.
In the template editor it ends up like this
- !secret pauls_secret_email
- !secret tracys_secret_email
But even this shows up the same way
{% if states('input_boolean.notify_paul') == 'on' and states('input_boolean.notify_tracy') == 'on' %}
- !secret pauls_secret_email
- !secret tracys_secret_email
Edit: I should have stated, this is not working because of the formatting. Not sure how to get it to format correctly
Edit2: This is the error I see in my logs with the current formatting issue
Invalid target syntax: - !secret pauls_secret_email
- !secret tracys_secret_email
edit 3:
gave up for the moment. I’ll come back to it later.
Was trying to end up with this
action:
- service: notify.pushbullet_notifications
data_template:
target:
- !secret pauls_secret_email
- !secret tracys_secret_email
title: Doors left unlocked
message: message
Just could not get the - !secret… to work
Edit 4: 12-22
still no go. Tried this most recently
- service: notify.pushbullet_notifications
data_template: >
{% if states('input_boolean.notify_paul') == 'on' and states('input_boolean.notify_tracy') == 'on' %}
target:
- !secret pauls_secret_email
- !secret tracys_secret_email
{% elif states('input_boolean.notify_paul') == 'on' and states('input_boolean.notify_tracy') == 'off' %}
target:
- !secret pauls_secret_email
{% elif states('input_boolean.notify_paul') == 'off' and states('input_boolean.notify_tracy') == 'on' %}
target:
- !secret tracys_secret_email
{% else %}
target:
- noone
{% endif %}
title: "Goodbye Routine has ran"
message: "All lights have been turned off. Garage door has closed and locks have been locked"