Simplified normal text notifications further

Additionally made the script capable of clearing notifications. Should be almost no need to call notify services directly at all anymore.
This commit is contained in:
2023-02-28 18:14:44 -05:00
parent 2146ddb955
commit 9445c2a4c4
5 changed files with 66 additions and 135 deletions

View File

@ -459,8 +459,10 @@
entity_id: input_boolean.vacation_mode entity_id: input_boolean.vacation_mode
state: 'off' state: 'off'
action: action:
- service: notify.all_ios - service: script.text_notify
data: data:
type: alert
who: all
message: clear_notification message: clear_notification
data: data:
tag: tornado-warning tag: tornado-warning

View File

@ -692,7 +692,7 @@ script:
name: 'Title' name: 'Title'
description: 'The title of the notification' description: 'The title of the notification'
example: 'Greetings' example: 'Greetings'
required: true required: false
selector: selector:
text: text:
message: message:
@ -778,101 +778,29 @@ script:
state: 'on' state: 'on'
- if: - if:
- condition: template - condition: template
value_template: '{{ who == "tony"}}' value_template: >
then: {% if who == 'tony' %}
- if: {{ is_state('input_boolean.text_notify_tony','on') }}
- condition: state {% elif who == 'tina' %}
entity_id: input_boolean.text_notify_tony {{ is_state('input_boolean.text_notify_tina','on') }}
state: 'on' {% elif who == 'kallen' %}
then: {{ is_state('input_boolean.text_notify_kallen','on') }}
- service: notify.ios_tony {% elif who == 'parents' %}
data: {{ is_state('input_boolean.text_notify_parents','on') }}
title: '{{ title }}' {% elif who == 'nerds' %}
message: '{{ message }}' {{ is_state('input_boolean.text_notify_nerds','on') }}
data: {% elif who == 'all' %}
tag: > {{ is_state('input_boolean.text_notify_all','on') }}
{% if tag is defined %}
{{ tag }}
{% else %}
{}
{% endif %} {% endif %}
- if:
- condition: template
value_template: '{{ who == "tina"}}'
then:
- if:
- condition: state
entity_id: input_boolean.text_notify_tina
state: 'on'
then:
- service: notify.ios_tina
data:
title: '{{ title }}'
message: '{{ message }}'
data:
tag: >
{% if tag is defined %}
{{ tag }}
{% else %}
{}
{% endif %}
- if:
- condition: template
value_template: '{{ who == "kallen"}}'
then:
- if:
- condition: state
entity_id: input_boolean.text_notify_kallen
state: 'on'
then:
- service: notify.ios_kallen
data:
title: '{{ title }}'
message: '{{ message }}'
data:
tag: >
{% if tag is defined %}
{{ tag }}
{% else %}
{}
{% endif %}
- if:
- condition: template
value_template: '{{ who == "parents"}}'
then:
- if:
- condition: state
entity_id: input_boolean.text_notify_parents
state: 'on'
then: then:
- service: > - service: >
{% if is_state('input_boolean.text_notify_tina','off') and is_state('input_boolean.text_notify_tony','on') %} {% if who == 'tony' %}
notify.ios_tony notify.ios_tony
{% elif is_state('input_boolean.text_notify_tina','on') and is_state('input_boolean.text_notify_tony','off') %} {% elif who == 'tina' %}
notify.ios_tina notify.ios_tina
{% else %} {% elif who == 'kallen' %}
notify.ios_parents notify.ios_kallen
{% endif %} {% elif who == 'nerds' %}
data:
title: '{{ title }}'
message: '{{ message }}'
data:
tag: >
{% if tag is defined %}
{{ tag }}
{% else %}
{}
{% endif %}
- if:
- condition: template
value_template: '{{ who == "nerds"}}'
then:
- if:
- condition: state
entity_id: input_boolean.text_notify_nerds
state: 'on'
then:
- service: >
{% if is_state('input_boolean.text_notify_tony','on') and is_state('input_boolean.text_notify_kallen','off') %} {% if is_state('input_boolean.text_notify_tony','on') and is_state('input_boolean.text_notify_kallen','off') %}
notify.ios_tony notify.ios_tony
{% elif is_state('input_boolean.text_notify_tony','off') and is_state('input_boolean.text_notify_kallen','on') %} {% elif is_state('input_boolean.text_notify_tony','off') and is_state('input_boolean.text_notify_kallen','on') %}
@ -880,26 +808,17 @@ script:
{% else %} {% else %}
notify.ios_nerds notify.ios_nerds
{% endif %} {% endif %}
data: {% elif who == 'parents' %}
title: '{{ title }}' {% if is_state('input_boolean.text_notify_tina','off') and is_state('input_boolean.text_notify_tony','on') %}
message: '{{ message }}' notify.ios_tony
data: {% elif is_state('input_boolean.text_notify_tina','on') and is_state('input_boolean.text_notify_tony','off') %}
tag: > notify.ios_tina
{% if tag is defined %}
{{ tag }}
{% else %} {% else %}
{} notify.ios_parents
{% endif %}
{% elif who == 'all' %}
notify.all_ios
{% endif %} {% endif %}
- if:
- condition: template
value_template: '{{ who == "all"}}'
then:
- if:
- condition: state
entity_id: input_boolean.text_notify_all
state: 'on'
then:
- service: notify.all_ios
data: data:
title: '{{ title }}' title: '{{ title }}'
message: '{{ message }}' message: '{{ message }}'

View File

@ -487,8 +487,10 @@ script:
continue_on_timeout: true continue_on_timeout: true
timeout: timeout:
minutes: 1 minutes: 1
- service: notify.all_ios - service: script.text_notify
data: data:
type: alert
who: all
message: "clear_notification" message: "clear_notification"
data: data:
tag: skip-away tag: skip-away

View File

@ -320,6 +320,8 @@ automation:
then: then:
- service: notify.all_ios - service: notify.all_ios
data: data:
type: alert
who: all
message: clear_notification message: clear_notification
data: data:
tag: lockdown-issue tag: lockdown-issue

View File

@ -1560,8 +1560,10 @@ automation:
- condition: template - condition: template
value_template: "{{ is_state('binary_sensor.windows','off') and is_state('binary_sensor.precipitation','on') }}" value_template: "{{ is_state('binary_sensor.windows','off') and is_state('binary_sensor.precipitation','on') }}"
sequence: sequence:
- service: notify.all_ios - service: script.text_notify
data: data:
type: alert
who: all
message: clear_notification message: clear_notification
data: data:
tag: rain-window-warning tag: rain-window-warning
@ -1573,8 +1575,10 @@ automation:
- condition: template - condition: template
value_template: "{{ is_state('binary_sensor.precipitation','off') }}" value_template: "{{ is_state('binary_sensor.precipitation','off') }}"
sequence: sequence:
- service: notify.all_ios - service: script.text_notify
data: data:
type: alert
who: all
message: clear_notification message: clear_notification
data: data:
tag: rain-window-warning tag: rain-window-warning
@ -1658,8 +1662,10 @@ script:
lightning_clear: lightning_clear:
alias: 'Lightning Clear' alias: 'Lightning Clear'
sequence: sequence:
- service: notify.all_ios - service: script.text_notify
data: data:
type: alert
who: all
message: clear_notification message: clear_notification
data: data:
tag: lightning-warning tag: lightning-warning