Skip to content

Instantly share code, notes, and snippets.

@NickM-27
Created June 22, 2022 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickM-27/608c3e14af530c15d1ad8986c98ef7ca to your computer and use it in GitHub Desktop.
Save NickM-27/608c3e14af530c15d1ad8986c98ef7ca to your computer and use it in GitHub Desktop.
HA notification for sending notifications only if person is home
alias: Send Dynamic Notification To All Devices
sequence:
- parallel:
- if:
- condition: template
value_template: '{{ send_to_bob | default(True) }}'
then:
- service: notify.mobile_app_pixel_6
data:
message: '{{ message }}'
title: '{{ title }}'
data:
channel: '{{ channel }}'
clickAction: '{{ video }}'
tag: '{{ notifTag }}'
group: '{{ group }}'
image: >-
{% if (importance == "default" and video != null) -%} {{ null
}} {%- else -%} {{ image }} {%- endif %}
video: >-
{% if (importance == "default" and video != null) -%} {{ video
}} {%- else -%} {{ null }} {%- endif %}
notification_icon: '{{ notifIcon }}'
importance: '{{ importance }}'
- service: notify.mobile_app_bobs_iphone
data:
message: '{{ message }}'
title: '{{ title }}'
data:
url: '{{ video }}'
tag: '{{ notifTag }}'
group: '{{ group }}'
attachment:
url: >-
{% if (importance == "default" and video != null) -%} {{
video }} {%- else -%} {{ image }} {%- endif %}
push:
interruption-level: >-
{% if importance == "max" -%} time-sensitive {%- else -%}
passive {%- endif %}
- if:
- condition: template
value_template: '{{ send_to_john }}'
then:
- service: notify.mobile_app_pixel_5
data:
message: '{{ message }}'
title: '{{ title }}'
data:
clickAction: '{{ video }}'
tag: '{{ notifTag }}'
group: '{{ group }}'
image: '{{ image }}'
notification_icon: '{{ notifIcon }}'
attachment:
url: '{{ image }}'
- if:
- condition: template
value_template: '{{ states("media_player.shield") != "off" }}'
- condition: template
value_template: '{{ importance == "max" }}'
then:
- service: notify.shield_tv
data:
message: '{{ message }}'
title: '{{ title }}'
data:
fontsize: medium
image:
url: http://192.168.1.106:5000/api/events/{{id}}/snapshot.jpg
- if:
- condition: device
device_id: 5cd87b43d1983866b953d22d6ac79ec8
domain: media_player
entity_id: media_player.bedroom_tv
type: is_on
- condition: template
value_template: '{{ importance == "max" }}'
then:
- service: notify.bedroom_tv_notifications
data:
message: '{{ message }}'
title: '{{ title }}'
data:
fontsize: medium
image:
url: http://192.168.1.106:5000/api/events/{{id}}/snapshot.jpg
mode: parallel
icon: mdi:bell-ring-outline
max: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment