Created
December 24, 2023 15:37
-
-
Save florian-asche/a3c3e8f77e2f837576621fb8304e749f to your computer and use it in GitHub Desktop.
Valetudo-RE Notification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: 'Valetudo-RE: Notifications' | |
description: Sends a notification after a successful clean-up run and on error. | |
source_url: https://github.com/mundschenk-at/ha-valetudo-blueprints/blob/main/yaml/automation/valetudo-notifications.yaml | |
domain: automation | |
homeassistant: | |
min_version: 2022.6.0 | |
input: | |
vacuum: | |
name: Vacuum Robot | |
description: The vacuum robot entity. | |
selector: | |
entity: | |
domain: vacuum | |
integration: mqtt | |
multiple: false | |
rendered_map: | |
name: Rendered Map | |
description: The vacuum map rendered as a PNG image. | |
selector: | |
entity: | |
domain: camera | |
integration: mqtt | |
multiple: false | |
error_message: | |
name: Error Message | |
description: The sensor containing the last error message. | |
selector: | |
entity: | |
domain: sensor | |
integration: mqtt | |
multiple: false | |
dashboard_url: | |
name: Dashboard URL | |
description: The dashboard that should be opened when tapping on the notification. | |
default: '/lovelace/' | |
selector: | |
text: | |
type: url | |
notify_device: | |
name: Notification Device(s) | |
description: The notified device(s). | |
default: false | |
selector: | |
device: | |
integration: mobile_app | |
multiple: true | |
notify_group: | |
name: Notification Group | |
description: "The name of the notification group to call. ('notify' for all devices)" | |
default: "" | |
language: | |
name: Language | |
description: The language used for the notifications. | |
default: English | |
selector: | |
select: | |
options: | |
- English | |
- German | |
trigger_variables: | |
rendered_map_sensor: !input rendered_map | |
error_message_sensor: !input error_message | |
notify_devices: !input notify_device | |
group_target: !input notify_group | |
language: !input language | |
trigger: | |
- platform: state | |
entity_id: !input vacuum | |
from: cleaning | |
to: returning | |
id: cleaning_finished | |
variables: | |
msg_type: success_msg | |
- platform: state | |
entity_id: !input vacuum | |
to: error | |
for: | |
hours: 0 | |
minutes: 0 | |
seconds: 5 | |
id: error | |
variables: | |
msg_type: error_msg | |
condition: | |
- condition: or | |
alias: "Finished cleaning task or error message is not empty" | |
conditions: | |
- condition: trigger | |
id: cleaning_finished | |
- condition: not | |
conditions: | |
- condition: state | |
entity_id: !input error_message | |
state: '' | |
variables: | |
strings: | |
English: | |
title: Vacuum | |
success_msg: "Cleaning task succeeded at {{ now().strftime('%-H:%M') }}." | |
error_msg: "The robot has encountered an issue: {{ states( error_message_sensor ) }}" | |
default_msg: "Everything is working fine." | |
German: | |
title: Staubsauger | |
success_msg: "Die Reinigung wurde um {{ now().strftime('%-H:%M') }} Uhr erfolgreich abgeschlossen." | |
error_msg: "Der Staubsauger hat ein Problem: {{ states( error_message_sensor ) }}" | |
default_msg: Alles gut. | |
notify_targets: >- | |
{% set ns = namespace(targets=[]) %} | |
{% if notify_devices is iterable %} | |
{% for device_id in notify_devices -%} | |
{% set ns.targets = ns.targets + [ "notify.mobile_app_" ~ device_attr( device_id, 'name' )|slugify ] %} | |
{%- endfor %} | |
{%- endif %} | |
{% if group_target is defined and group_target is string and group_target != '' %} | |
{% set ns.targets = ns.targets + [ "notify." ~ group_target|slugify ] %} | |
{%- endif %} | |
{{ns.targets}} | |
title: "{{ strings[language]['title'] }}" | |
message: "{{ strings[language][msg_type] | default(strings[language]['default_msg']) }}" | |
data: | |
entity_id: "{{ rendered_map_sensor | default(none) }}" | |
priority: high | |
# iOS URL | |
url: !input dashboard_url | |
# Android URL | |
clickAction: !input dashboard_url | |
action: | |
- repeat: | |
for_each: "{{ notify_targets }}" | |
sequence: | |
- service: "{{ repeat.item }}" | |
data: | |
title: "{{ title }}" | |
message: "{{ message }}" | |
data: "{{ data }}" | |
mode: queued |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment