Initial commit
This commit is contained in:
commit
7703f5532a
10 files changed
+889
No files matched your search
@@ -0,0 +1,32 @@
|
||||
# Notify People
|
||||
|
||||
Helper script meant as central place for sending notifications in Home Assistant. Multiple parameters are available
|
||||
including selecting notified people, only notifying people at home and a way to dismiss notification. Has options for
|
||||
handling HA persistent notifications with the same message.
|
||||
|
||||
[](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgitea.marquis.site%2FHomeAssistant%2Fblueprints%2Fscripts%2Fnotify_people%2Fnotify_people.yaml)
|
||||
|
||||
## General
|
||||
|
||||
Loops over the provided `people` items and calls their [notification script](../notify_person/README.md).
|
||||
If `home` is true, script calls for people not at home will be skipped.
|
||||
Persistent notification management can be enabled by setting `create_persistent_notification` to true. An additional
|
||||
condition template can be supplied to dynamically control creation of persistent notifications with
|
||||
`persistent_notification_condition`.
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Default |
|
||||
|------------------------------------------|--------------------------------------------------------------------------------------------------------------|--------------|
|
||||
| Title | The title of the notification | |
|
||||
| Message | The message of the notification | |
|
||||
| URL | Url for click action target | |
|
||||
| Tag | Tag for replacing / clearing later on | |
|
||||
| Group | Group name for notification grouping | |
|
||||
| Clear | Removes notifications with given tag | `false` |
|
||||
| Channel | Android notification Channel | |
|
||||
| Actions | Actions to add to mobile app notifications | |
|
||||
| People | People to notify. Defaults to everyone. | <everyone> |
|
||||
| Only Home | If true, only sends notifications to people who are at home | `false` |
|
||||
| Create persistent Notification | If true, creates a persistent notification in Home Assistant additionally | `false` |
|
||||
| Create persistent Notification Condition | Creates a persistent notification in Home Assistant only of the given condition matches. Ignored if omitted. | `{{ true }}` |
|
||||
@@ -0,0 +1,259 @@
|
||||
blueprint:
|
||||
name: Notify People
|
||||
domain: script
|
||||
description: >
|
||||
Helper script meant as central place for sending notifications in Home Assistant. Multiple parameters available
|
||||
including selecting notified people, only notifying people at home and a way to dismiss notification.
|
||||
input:
|
||||
|
||||
people:
|
||||
name: People
|
||||
description: >
|
||||
List of People that can be notified. Everyone on this list will be notified per default by this script.
|
||||
selector:
|
||||
entity:
|
||||
multiple: true
|
||||
filter:
|
||||
domain: person
|
||||
|
||||
home:
|
||||
name: Home Zone
|
||||
description: >
|
||||
Home zone for this Home Assistant Instance.
|
||||
default: zone.home
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
domain: zone
|
||||
|
||||
|
||||
### --- Script Fields --- ###
|
||||
fields:
|
||||
|
||||
title:
|
||||
name: Title
|
||||
description: The title of the notification
|
||||
required: false
|
||||
example: Notification Title
|
||||
selector:
|
||||
text:
|
||||
multiline: false
|
||||
multiple: false
|
||||
|
||||
message:
|
||||
name: Message
|
||||
description: The message of the notification
|
||||
required: false
|
||||
example: My notification message.
|
||||
selector:
|
||||
text:
|
||||
multiline: true
|
||||
multiple: false
|
||||
|
||||
url:
|
||||
name: URL
|
||||
description: Url for click action target
|
||||
required: false
|
||||
example: /lovelace-light/lighting
|
||||
selector:
|
||||
text:
|
||||
type: url
|
||||
|
||||
tag:
|
||||
name: Tag
|
||||
description: Tag for replacing / clearing later on
|
||||
required: false
|
||||
example: my_notification
|
||||
selector:
|
||||
text:
|
||||
multiple: false
|
||||
multiline: false
|
||||
|
||||
group:
|
||||
name: Group
|
||||
description: Group name for notification grouping
|
||||
required: false
|
||||
example: climate_notification
|
||||
selector:
|
||||
text:
|
||||
multiple: false
|
||||
multiline: false
|
||||
|
||||
clear:
|
||||
name: Clear
|
||||
description: Removes notifications with given tag
|
||||
required: false
|
||||
example: true
|
||||
selector:
|
||||
boolean:
|
||||
|
||||
channel:
|
||||
name: Channel
|
||||
description: Android notification Channel
|
||||
required: false
|
||||
example: Important Alert
|
||||
selector:
|
||||
text:
|
||||
multiline: false
|
||||
multiple: false
|
||||
|
||||
actions:
|
||||
name: Notification actions
|
||||
description: Actions to add to mobile app notifications
|
||||
required: false
|
||||
example: >
|
||||
[{"action": "URI", "title": "Open Url", "uri": "https://home-assistant.io"}]
|
||||
selector:
|
||||
object:
|
||||
multiple: true
|
||||
fields:
|
||||
action:
|
||||
label: Action
|
||||
required: true
|
||||
selector:
|
||||
text:
|
||||
title:
|
||||
label: Title
|
||||
required: true
|
||||
selector:
|
||||
text:
|
||||
uri:
|
||||
label: URL
|
||||
selector:
|
||||
text:
|
||||
behavior:
|
||||
label: Behavior
|
||||
selector:
|
||||
text:
|
||||
authenticationRequired:
|
||||
label: Authentication Required
|
||||
selector:
|
||||
boolean:
|
||||
|
||||
people:
|
||||
name: People
|
||||
description: People to notify. Defaults to everyone.
|
||||
required: false
|
||||
default: !input people
|
||||
selector:
|
||||
entity:
|
||||
multiple: true
|
||||
include_entities: !input people
|
||||
filter:
|
||||
domain: person
|
||||
|
||||
only_home:
|
||||
name: Only Home
|
||||
description: If true, only sends notifications to people who are at home
|
||||
required: false
|
||||
default: false
|
||||
example: true
|
||||
selector:
|
||||
boolean:
|
||||
|
||||
create_persistent_notification:
|
||||
name: Create persistent Notification
|
||||
description: If true, creates a persistent notification in Home Assistant additionally
|
||||
required: false
|
||||
default: false
|
||||
example: true
|
||||
selector:
|
||||
boolean:
|
||||
|
||||
persistent_notification_condition:
|
||||
name: Create persistent Notification Condition
|
||||
description: >
|
||||
Creates a persistent notification in Home Assistant only of the given condition matches. Ignored if omitted.
|
||||
required: false
|
||||
selector:
|
||||
template:
|
||||
|
||||
|
||||
### --- Script Settings --- ###
|
||||
mode: queued
|
||||
max: 10
|
||||
description: >-
|
||||
Helper script for customizable notifications. Notification targets can be
|
||||
chosen, defaults to notifying everyone. Option for excluding people not at
|
||||
home.
|
||||
|
||||
|
||||
### --- Global Script Variables --- ###
|
||||
variables:
|
||||
all_people: !input people
|
||||
home_zone: !input home
|
||||
# clear=(clear | default(false))
|
||||
message_data: >-
|
||||
{%- set message_data = [ '"clear": '~clear | default(false) | to_json ] %}
|
||||
{%- if title is defined %}
|
||||
{%- set message_data = message_data + [ '"title": "'~title~'"' ] %}
|
||||
{%- endif %}
|
||||
{%- if message is defined %}
|
||||
{%- set message_data = message_data + [ '"message": "'~message~'"' ] %}
|
||||
{%- endif %}
|
||||
{%- if tag is defined %}
|
||||
{%- set message_data = message_data + [ '"tag": "'~tag~'"' ] %}
|
||||
{%- endif %}
|
||||
{%- if url is defined %}
|
||||
{%- set message_data = message_data + [ '"url": "'~url~'"' ] %}
|
||||
{%- endif %}
|
||||
{%- if group is defined %}
|
||||
{%- set message_data = message_data + [ '"group": "'~group~'"' ] %}
|
||||
{%- endif %}
|
||||
{%- if channel is defined %}
|
||||
{%- set message_data = message_data + [ '"channel": "'~channel~'"' ] %}
|
||||
{%- endif %}
|
||||
{{ ('{'~message_data | join(',')~'}') | from_json }}
|
||||
clear: "{{ clear | default(false) }}"
|
||||
home: "{{ only_home | default(false) }}"
|
||||
create_persistent_notification: "{{ create_persistent_notification | default(false) }}"
|
||||
notification_id: "{{ tag | default(this.context.id) }}"
|
||||
persistent_notification_condition: >
|
||||
{{ persistent_notification_condition | default(true) }}
|
||||
|
||||
|
||||
### --- Script Sequence --- ###
|
||||
sequence:
|
||||
|
||||
- alias: Run for each person
|
||||
repeat:
|
||||
for_each: "{{ people | default(all_people) | map('regex_replace', 'person\\.(.+)', '\\\\1') | list }}"
|
||||
sequence:
|
||||
|
||||
- alias: Test if {{ person }} is at home
|
||||
if:
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{ not home or (home and 'person.' + repeat.item in state_attr(home_zone, 'persons')) }}
|
||||
then:
|
||||
# Trigger Sub-Scripts in non-blocking (async) mode
|
||||
- action: script.turn_on
|
||||
target:
|
||||
entity_id: script.notify_{{ repeat.item }}
|
||||
data:
|
||||
variables: '{{ iif(actions is defined, message_data | combine(dict(actions=actions)), message_data) }}'
|
||||
|
||||
- alias: Persistent Notification
|
||||
if:
|
||||
- condition: template
|
||||
value_template: '{{ create_persistent_notification }}'
|
||||
alias: Test if persistent notifications are enabled
|
||||
then:
|
||||
- alias: Test if we are in clearing mode
|
||||
if:
|
||||
- condition: template
|
||||
value_template: '{{ clear }}'
|
||||
then:
|
||||
- action: persistent_notification.dismiss
|
||||
data:
|
||||
notification_id: '{{ notification_id }}'
|
||||
else:
|
||||
- if:
|
||||
- condition: template
|
||||
value_template: '{{ persistent_notification_condition }}'
|
||||
then:
|
||||
- action: persistent_notification.create
|
||||
data:
|
||||
title: "{{ title }}"
|
||||
message: "{{ message }}"
|
||||
notification_id: "{{ notification_id }}"
|
||||
@@ -0,0 +1,23 @@
|
||||
# Notify Person
|
||||
|
||||
Helper script to notify a single person. Used to prevent the need of changing every occurrence of a notification
|
||||
entity by instead only updating this script in case of a device change. Provides convenience to dismiss messages.
|
||||
|
||||
[](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgitea.marquis.site%2FHomeAssistant%2Fblueprints%2Fscripts%2Fnotify_person%2Fnotify_person.yaml)
|
||||
|
||||
## General
|
||||
|
||||
The only action for this script is to call the handler function and wait for its completion.
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Default |
|
||||
|---------|--------------------------------------------|---------|
|
||||
| Title | The title of the notification | |
|
||||
| Message | The message of the notification | |
|
||||
| URL | Url for click action target | |
|
||||
| Tag | Tag for replacing / clearing later on | |
|
||||
| Group | Group name for notification grouping | |
|
||||
| Clear | Removes notifications with given tag | `false` |
|
||||
| Channel | Android notification Channel | |
|
||||
| Actions | Actions to add to mobile app notifications | |
|
||||
@@ -0,0 +1,161 @@
|
||||
blueprint:
|
||||
name: Notify Person
|
||||
domain: script
|
||||
description: >
|
||||
Helper script to notify a single person. Used to prevent the need of changing every occurrence of a notification
|
||||
entity by instead only updating this script in case of a device change. Provides convenience to dismiss messages.
|
||||
input:
|
||||
|
||||
handler:
|
||||
name: Handler Entity
|
||||
description: >
|
||||
Notification handler for the person.
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
domain: notify
|
||||
|
||||
|
||||
### --- Script Fields --- ###
|
||||
fields:
|
||||
|
||||
title:
|
||||
name: Title
|
||||
description: The title of the notification
|
||||
required: false
|
||||
example: Notification Title
|
||||
selector:
|
||||
text:
|
||||
multiline: false
|
||||
multiple: false
|
||||
|
||||
message:
|
||||
name: Message
|
||||
description: The message of the notification
|
||||
required: false
|
||||
example: My notification message.
|
||||
selector:
|
||||
text:
|
||||
multiline: true
|
||||
multiple: false
|
||||
|
||||
url:
|
||||
name: URL
|
||||
description: Url for click action target
|
||||
required: false
|
||||
example: /lovelace-light/lighting
|
||||
selector:
|
||||
text:
|
||||
type: url
|
||||
|
||||
tag:
|
||||
name: Tag
|
||||
description: Tag for replacing / clearing later on
|
||||
required: false
|
||||
example: my_notification
|
||||
selector:
|
||||
text:
|
||||
multiple: false
|
||||
multiline: false
|
||||
|
||||
group:
|
||||
name: Group
|
||||
description: Group name for notification grouping
|
||||
required: false
|
||||
example: climate_notification
|
||||
selector:
|
||||
text:
|
||||
multiple: false
|
||||
multiline: false
|
||||
|
||||
clear:
|
||||
name: Clear
|
||||
description: Removes notifications with given tag
|
||||
required: false
|
||||
example: true
|
||||
selector:
|
||||
boolean:
|
||||
|
||||
channel:
|
||||
name: Channel
|
||||
description: Android notification Channel
|
||||
required: false
|
||||
example: Important Alert
|
||||
selector:
|
||||
text:
|
||||
multiline: false
|
||||
multiple: false
|
||||
|
||||
actions:
|
||||
name: Notification actions
|
||||
description: Actions to add to mobile app notifications
|
||||
required: false
|
||||
example: >
|
||||
[{"action": "URI", "title": "Open Url", "uri": "https://home-assistant.io"}]
|
||||
selector:
|
||||
object:
|
||||
multiple: true
|
||||
fields:
|
||||
action:
|
||||
label: Action
|
||||
required: true
|
||||
selector:
|
||||
text:
|
||||
title:
|
||||
label: Title
|
||||
required: true
|
||||
selector:
|
||||
text:
|
||||
uri:
|
||||
label: URL
|
||||
selector:
|
||||
text:
|
||||
behavior:
|
||||
label: Behavior
|
||||
selector:
|
||||
text:
|
||||
authenticationRequired:
|
||||
label: Authentication Required
|
||||
selector:
|
||||
boolean:
|
||||
|
||||
|
||||
### --- Script Settings --- ###
|
||||
mode: queued
|
||||
max: 10
|
||||
description: >-
|
||||
Helper script for customizable notifications targeting one person.
|
||||
|
||||
|
||||
### --- Global Script Variables --- ###
|
||||
variables:
|
||||
handler: !input handler
|
||||
message_title: "{{ title | default('') }}"
|
||||
message_content: "{{ iif(clear, 'clear_notification', message) }}"
|
||||
extra_data: >-
|
||||
{%- set extra_data = [] %}
|
||||
{%- if tag is defined %}
|
||||
{%- set extra_data = extra_data + [ '"tag": "'~tag~'"' ] %}
|
||||
{%- endif %}
|
||||
{%- if url is defined %}
|
||||
{%- set extra_data = extra_data + [ '"url": "'~url~'"' ] %}
|
||||
{%- endif %}
|
||||
{%- if url is defined %}
|
||||
{%- set extra_data = extra_data + [ '"clickAction": "'~url~'"' ] %}
|
||||
{%- endif %}
|
||||
{%- if group is defined %}
|
||||
{%- set extra_data = extra_data + [ '"group": "'~group~'"' ] %}
|
||||
{%- endif %}
|
||||
{%- if channel is defined %}
|
||||
{%- set extra_data = extra_data + [ '"channel": "'~channel~'"' ] %}
|
||||
{%- endif %}
|
||||
{{ ('{'~extra_data | join(',')~'}') | from_json }}
|
||||
|
||||
|
||||
### --- Script Sequence --- ###
|
||||
sequence:
|
||||
- action: "{{ handler | regex_replace('notify.', 'notify.mobile_app_') }}"
|
||||
data:
|
||||
title: "{{ message_title }}"
|
||||
message: "{{ message_content }}"
|
||||
data: "{{ iif(actions is defined, extra_data | combine(dict(actions=actions)), extra_data) }}"
|
||||
@@ -0,0 +1,22 @@
|
||||
# Smart Close Cover
|
||||
|
||||
Helper script to intelligently close a cover entity when the sun is below the horizon after waiting for its window to be
|
||||
closed. Useful in time-based cover automations.
|
||||
|
||||
[](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgitea.marquis.site%2FHomeAssistant%2Fblueprints%2Fscripts%2Fsmart_close_cover%2Fsmart_close_cover.yaml)
|
||||
|
||||
## General
|
||||
|
||||
This script chains a window entity to a cover for the action of closing the cover once if the sun is down. You can
|
||||
optionally specify extra actions to be executed once the cover starts closing for example to activate a scene or send a
|
||||
notification. If the window hasn't been closed after a configurable period of 14 hours, the script execution is,
|
||||
canceled because the sun is probably up again.
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Default |
|
||||
|--------------------|--------------------------------------------------------------------------------------|---------|
|
||||
| Cover Entity | **Required.** The cover entity to close | |
|
||||
| Window Entity | **Required.** The window to wait for if open at the time this script is triggered | |
|
||||
| Close Duration (s) | The duration in seconds that the window needs to be closed before the cover is reset | `4` |
|
||||
| extra_actions | Extra Actions to run when the cover starts closing | |
|
||||
@@ -0,0 +1,152 @@
|
||||
blueprint:
|
||||
name: Smart close cover
|
||||
domain: script
|
||||
description: >
|
||||
Helper script to intelligently close a cover entity when the sun is below the horizon after waiting for its window
|
||||
to be closed. Useful in time-based cover automations.
|
||||
input:
|
||||
|
||||
window_close_duration_default:
|
||||
name: Window close duration default (s)
|
||||
description: >
|
||||
The default duration the window has to be cosed before triggering the cover closing.
|
||||
default: 4
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
step: 1
|
||||
|
||||
window_close_wait_timeout:
|
||||
name: Window close wait timeout (h)
|
||||
description: >
|
||||
The default duration the window has to be cosed before triggering the cover closing.
|
||||
default: 14
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
step: 1
|
||||
|
||||
|
||||
### --- Script Fields --- ###
|
||||
fields:
|
||||
|
||||
cover:
|
||||
name: Cover Entity
|
||||
description: The cover entity to close
|
||||
required: true
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
- domain: cover
|
||||
|
||||
window:
|
||||
name: Window Entity
|
||||
description: The window to wait for if open at the time this script is triggered
|
||||
required: true
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
- domain: binary_sensor
|
||||
device_class: window
|
||||
|
||||
window_close_duration_seconds:
|
||||
name: Close Duration (s)
|
||||
description: >-
|
||||
The duration in seconds the window needs to be closed before the cover will be reset
|
||||
default: !input window_close_duration_default
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
step: 1
|
||||
|
||||
extra_actions:
|
||||
name: Extra Actions to run when the cover starts closing
|
||||
selector:
|
||||
action: {}
|
||||
|
||||
|
||||
### --- Script Settings --- ###
|
||||
mode: parallel
|
||||
max: 10
|
||||
icon: mdi:arrow-down-box
|
||||
description: >-
|
||||
Helper script to intelligently close a cover entity after waiting for its window to be closed. Useful in time-based
|
||||
cover automations.
|
||||
|
||||
|
||||
### --- Global Script Variables --- ###
|
||||
variables:
|
||||
window_close_duration_default: !input window_close_duration_default
|
||||
|
||||
|
||||
### --- Script Sequence --- ###
|
||||
sequence:
|
||||
- if:
|
||||
- condition: template
|
||||
value_template: "{{ states(window) == 'on' }}"
|
||||
then:
|
||||
- wait_for_trigger:
|
||||
- trigger: template
|
||||
value_template: |
|
||||
{{ states(window) == "off" }}
|
||||
for:
|
||||
seconds: "{{ window_close_duration_seconds | default(window_close_duration_default) | int }}"
|
||||
timeout:
|
||||
hours: !input window_close_wait_timeout
|
||||
|
||||
- condition: sun
|
||||
after: sunset
|
||||
before: sunrise
|
||||
enabled: true
|
||||
|
||||
- wait_template: |
|
||||
{{ states(cover) != "unavailable" }}
|
||||
continue_on_timeout: false
|
||||
|
||||
- action: cover.close_cover
|
||||
target:
|
||||
entity_id:
|
||||
- '{{ cover }}'
|
||||
|
||||
- repeat:
|
||||
for_each: '{{ extra_actions }}'
|
||||
sequence:
|
||||
- choose:
|
||||
# 1) Condition
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{
|
||||
repeat.item.condition is defined and
|
||||
repeat.item.condition == "template" and
|
||||
repeat.item.value_template is defined
|
||||
}}
|
||||
sequence:
|
||||
- condition: template
|
||||
value_template: '{{ repeat.item.value_template }}'
|
||||
# 2) Action with target & data
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{ repeat.item.target is defined and repeat.item.data is defined }}
|
||||
sequence:
|
||||
- action: '{{ repeat.item.action }}'
|
||||
target: '{{ repeat.item.target }}'
|
||||
data: '{{ repeat.item.data }}'
|
||||
# 3) Action with target
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ repeat.item.target is defined }}'
|
||||
sequence:
|
||||
- action: '{{ repeat.item.action }}'
|
||||
target: '{{ repeat.item.target }}'
|
||||
# 4) Action with data
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: '{{ repeat.item.data is defined }}'
|
||||
sequence:
|
||||
- action: '{{ repeat.item.action }}'
|
||||
data: '{{ repeat.item.data }}'
|
||||
# 5) Only action
|
||||
default:
|
||||
- action: '{{ repeat.item.action }}'
|
||||
Reference in new issue
Block a user