HI
using this automation on an input_select in my setup, i need to add an option to switch the notification on and off.
How can that be achieved? It has to be conditioned after the service_template, since the has to happen always.
Below i have made a separate automation for now, but somehow that doesnt trigger, though the input_booleans exist and switch in and off.
full automation:
- alias: Activity selection
id: '1511601478553'
trigger:
platform: state
entity_id: input_select.activity
action:
- service_template: >
{% if is_state ('input_select.activity','Opstart') %} script.opstart
{% elif is_state ('input_select.activity','Aan de slag') %} script.aan_de_slag
{% elif is_state ('input_select.activity', 'Home theater') %} script.home_theater
{% elif is_state ('input_select.activity','Gym') %} script.gym
{% elif is_state ('input_select.activity', 'Selamat makan') %} script.selamat_makan
{% elif is_state ('input_select.activity', 'Uit huis') %} script.uit_huis
{% elif is_state ('input_select.activity', 'Naar bed') %} script.naar_bed
{% elif is_state ('input_select.activity', 'Opstaan') %} script.opstaan
{% endif %}
- delay: 00:00:02
- service: python_script.summary
data_template:
event: "{{ trigger.event }}"
- service: notify.notify
data_template:
title: "Selected Activity: {{states.input_select.activity.state}}
at {{ as_timestamp(states.input_select.activity.last_updated)
| timestamp_custom ('%H:%M') }}"
message: > {{ as_timestamp(states.input_select.activity.last_updated)
| timestamp_custom ('%H:%M') }}:
{% if is_state ('input_select.activity','Opstart') %} Starting up
{% elif is_state ('input_select.activity','Aan de slag') %}All set and ready to be productive!
{% elif is_state ('input_select.activity', 'Home theater') %} Enjoy!
{% elif is_state ('input_select.activity','Gym') %} Be fit!
{% elif is_state ('input_select.activity', 'Selamat makan') %} Selamat Makan, maak er wat van!
{% elif is_state ('input_select.activity', 'Uit huis') %} See you soon, the house is safely lit.
{% elif is_state ('input_select.activity', 'Naar bed') %} Turned down the lights, sleep tight.
{% elif is_state ('input_select.activity', 'Opstaan') %} Espresso is klaar over 10 minuten!
{% endif %}
this works and sends the correct notifications.
i was hoping an input-boolean.activity_notification could be made, but im uncertain where and how to use that in this automation.
separate for notification based on input_boolean, working fine also:
- alias: Notify activity selection
id: '1511601478554'
hide_entity: True
initial_state: 'on'
trigger:
platform: state
entity_id: input_select.activity
condition:
condition: state
entity_id: 'input_boolean.activity_notification'
state: 'on'
action:
- service: notify.notify
data_template:
title: "Selected Activity: {{states.input_select.activity.state}}"
message: >
{{ as_timestamp(states.input_select.activity.last_updated)
| timestamp_custom ('%H:%M') }}:
{% if is_state ('input_select.activity','Opstart') %} Starting up
{% elif is_state ('input_select.activity','Aan de slag') %} All set and ready to be productive!
{% elif is_state ('input_select.activity', 'Home theater') %} Enjoy!
{% elif is_state ('input_select.activity','Gym') %} Be fit!
{% elif is_state ('input_select.activity', 'Selamat makan') %} Selamat Makan, maak er wat van!
{% elif is_state ('input_select.activity', 'Uit huis') %} See you soon, the house is safely lit.
{% elif is_state ('input_select.activity', 'Naar bed') %} Turned down the lights, sleep tight.
{% endif %}
input_boolean:
input_boolean:
activity_notification:
name: Notify activity selection
initial: on
icon: mdi:message-bulleted
Please have a look?
Thanks!
Marius