425 lines
15 KiB
YAML
425 lines
15 KiB
YAML
# Dreame Vacuum Notifications
|
||
# Sends notifications for Dreame vacuum events (cleaning, errors, consumables).
|
||
# See README.md for detailed documentation.
|
||
#
|
||
# Author: Alexei Dolgolyov (dolgolyov.alexei@gmail.com)
|
||
|
||
blueprint:
|
||
name: "Custom: Dreame Vacuum Notifications"
|
||
description: >
|
||
Sends customizable notifications for Dreame vacuum events including
|
||
cleaning status, consumable alerts, warnings, and errors.
|
||
Requires the Dreame Vacuum integration (github.com/Tasshack/dreame-vacuum).
|
||
domain: automation
|
||
|
||
# ===========================================================================
|
||
# INPUT CONFIGURATION
|
||
# ===========================================================================
|
||
input:
|
||
|
||
# -------------------------------------------------------------------------
|
||
# Vacuum Configuration
|
||
# -------------------------------------------------------------------------
|
||
vacuum_group:
|
||
name: "Vacuum"
|
||
collapsed: false
|
||
input:
|
||
vacuum_entity:
|
||
name: Vacuum Entity
|
||
description: "The Dreame vacuum entity to monitor."
|
||
selector:
|
||
entity:
|
||
integration: dreame_vacuum
|
||
domain: vacuum
|
||
|
||
# -------------------------------------------------------------------------
|
||
# Notification Configuration
|
||
# -------------------------------------------------------------------------
|
||
notification_group:
|
||
name: "Notification"
|
||
collapsed: false
|
||
input:
|
||
notify_targets:
|
||
name: Notification Targets
|
||
description: "Notification service entities to send messages to (select one or more)."
|
||
selector:
|
||
entity:
|
||
domain: notify
|
||
multiple: true
|
||
|
||
# -------------------------------------------------------------------------
|
||
# Event Toggles
|
||
# -------------------------------------------------------------------------
|
||
toggles_group:
|
||
name: "Event Toggles"
|
||
collapsed: false
|
||
input:
|
||
enable_cleaning_started:
|
||
name: Cleaning Started
|
||
description: "Send notification when the vacuum starts cleaning."
|
||
default: true
|
||
selector:
|
||
boolean:
|
||
|
||
enable_cleaning_completed:
|
||
name: Cleaning Completed
|
||
description: "Send notification when the vacuum finishes cleaning."
|
||
default: true
|
||
selector:
|
||
boolean:
|
||
|
||
enable_consumable:
|
||
name: Consumable Depleted
|
||
description: "Send notification when a consumable reaches end-of-life."
|
||
default: true
|
||
selector:
|
||
boolean:
|
||
|
||
enable_warning:
|
||
name: Warning
|
||
description: "Send notification for device warnings."
|
||
default: true
|
||
selector:
|
||
boolean:
|
||
|
||
enable_error:
|
||
name: Error
|
||
description: "Send notification for device errors."
|
||
default: true
|
||
selector:
|
||
boolean:
|
||
|
||
enable_information:
|
||
name: Information
|
||
description: "Send notification for informational alerts (e.g., blocked by DND)."
|
||
default: true
|
||
selector:
|
||
boolean:
|
||
|
||
# -------------------------------------------------------------------------
|
||
# Message Templates
|
||
# -------------------------------------------------------------------------
|
||
messages_group:
|
||
name: "Message Templates"
|
||
collapsed: true
|
||
input:
|
||
message_cleaning_started:
|
||
name: "Cleaning Started Message"
|
||
description: >
|
||
Message sent when the vacuum starts cleaning.
|
||
Variables: `{vacuum_name}`, `{cleaning_mode}`, `{status}`
|
||
default: "🧹 {vacuum_name} started cleaning ({cleaning_mode})."
|
||
selector:
|
||
text:
|
||
multiline: true
|
||
|
||
message_cleaning_completed:
|
||
name: "Cleaning Completed Message"
|
||
description: >
|
||
Message sent when the vacuum finishes cleaning.
|
||
Variables: `{vacuum_name}`, `{cleaning_mode}`, `{status}`,
|
||
`{cleaned_area}`, `{cleaning_time}`
|
||
default: "✅ {vacuum_name} finished cleaning. Area: {cleaned_area} m², time: {cleaning_time} min."
|
||
selector:
|
||
text:
|
||
multiline: true
|
||
|
||
message_consumable:
|
||
name: "Consumable Depleted Message"
|
||
description: >
|
||
Message sent when a consumable reaches end-of-life.
|
||
Variables: `{vacuum_name}`, `{consumable}`
|
||
default: "🔧 {vacuum_name}: {consumable} needs replacement."
|
||
selector:
|
||
text:
|
||
multiline: true
|
||
|
||
message_warning:
|
||
name: "Warning Message"
|
||
description: >
|
||
Message sent for device warnings.
|
||
Variables: `{vacuum_name}`, `{warning}`, `{code}`
|
||
default: "⚠️ {vacuum_name} warning: {warning} (code: {code})."
|
||
selector:
|
||
text:
|
||
multiline: true
|
||
|
||
message_error:
|
||
name: "Error Message"
|
||
description: >
|
||
Message sent for device errors.
|
||
Variables: `{vacuum_name}`, `{error}`, `{code}`
|
||
default: "❌ {vacuum_name} error: {error} (code: {code})."
|
||
selector:
|
||
text:
|
||
multiline: true
|
||
|
||
message_information:
|
||
name: "Information Message"
|
||
description: >
|
||
Message sent for informational alerts.
|
||
Variables: `{vacuum_name}`, `{information}`
|
||
default: "ℹ️ {vacuum_name}: {information}."
|
||
selector:
|
||
text:
|
||
multiline: true
|
||
|
||
# -------------------------------------------------------------------------
|
||
# Debug
|
||
# -------------------------------------------------------------------------
|
||
debug:
|
||
name: "Debug"
|
||
collapsed: true
|
||
input:
|
||
enable_debug_notifications:
|
||
name: Enable Debug Notifications
|
||
description: >
|
||
Send persistent notifications for debugging automation behavior.
|
||
Shows raw event data and filtering decisions.
|
||
default: false
|
||
selector:
|
||
boolean:
|
||
|
||
# Queued mode to avoid dropping rapid events
|
||
mode: queued
|
||
max: 5
|
||
|
||
# =============================================================================
|
||
# TRIGGERS
|
||
# =============================================================================
|
||
trigger:
|
||
# Cleaning job started or completed
|
||
- platform: event
|
||
event_type: dreame_vacuum_task_status
|
||
id: "task_status"
|
||
|
||
# Consumable reached end-of-life
|
||
- platform: event
|
||
event_type: dreame_vacuum_consumable
|
||
id: "consumable"
|
||
|
||
# Informational alert (job blocked by user settings)
|
||
- platform: event
|
||
event_type: dreame_vacuum_information
|
||
id: "information"
|
||
|
||
# Dismissible device warning
|
||
- platform: event
|
||
event_type: dreame_vacuum_warning
|
||
id: "warning"
|
||
|
||
# Device fault
|
||
- platform: event
|
||
event_type: dreame_vacuum_error
|
||
id: "error"
|
||
|
||
# =============================================================================
|
||
# VARIABLES
|
||
# =============================================================================
|
||
variables:
|
||
# ---------------------------------------------------------------------------
|
||
# Input References
|
||
# ---------------------------------------------------------------------------
|
||
vacuum_entity: !input vacuum_entity
|
||
notify_targets: !input notify_targets
|
||
enable_debug_notifications: !input enable_debug_notifications
|
||
|
||
# Event toggles
|
||
enable_cleaning_started: !input enable_cleaning_started
|
||
enable_cleaning_completed: !input enable_cleaning_completed
|
||
enable_consumable: !input enable_consumable
|
||
enable_warning: !input enable_warning
|
||
enable_error: !input enable_error
|
||
enable_information: !input enable_information
|
||
|
||
# Message templates
|
||
message_cleaning_started_template: !input message_cleaning_started
|
||
message_cleaning_completed_template: !input message_cleaning_completed
|
||
message_consumable_template: !input message_consumable
|
||
message_warning_template: !input message_warning
|
||
message_error_template: !input message_error
|
||
message_information_template: !input message_information
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Vacuum Info
|
||
# ---------------------------------------------------------------------------
|
||
vacuum_name: "{{ state_attr(vacuum_entity, 'friendly_name') | default(vacuum_entity) }}"
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Event Data (flat structure — fields are directly on trigger.event.data)
|
||
# ---------------------------------------------------------------------------
|
||
event_entity_id: "{{ trigger.event.data.entity_id | default('') }}"
|
||
|
||
# Task status fields
|
||
task_cleaning_mode: "{{ trigger.event.data.cleaning_mode | default('unknown') }}"
|
||
task_status_value: "{{ trigger.event.data.status | default('unknown') }}"
|
||
task_completed: "{{ trigger.event.data.completed | default(false) }}"
|
||
task_cleaned_area: "{{ trigger.event.data.cleaned_area | default(0) }}"
|
||
task_cleaning_time: "{{ trigger.event.data.cleaning_time | default(0) }}"
|
||
|
||
# Consumable fields
|
||
consumable_name: "{{ (trigger.event.data.consumable | default('unknown')) | replace('_', ' ') | title }}"
|
||
|
||
# Warning fields
|
||
warning_description: "{{ trigger.event.data.warning | default('unknown') }}"
|
||
warning_code: "{{ trigger.event.data.code | default('') }}"
|
||
|
||
# Error fields
|
||
error_description: "{{ trigger.event.data.error | default('unknown') }}"
|
||
error_code: "{{ trigger.event.data.code | default('') }}"
|
||
|
||
# Information fields
|
||
information_description: "{{ (trigger.event.data.information | default('unknown')) | replace('_', ' ') | title }}"
|
||
|
||
# =============================================================================
|
||
# CONDITIONS
|
||
# =============================================================================
|
||
condition:
|
||
# Only process events from the configured vacuum entity.
|
||
# The Dreame Vacuum integration uses generate_entity_id() for the entity_id
|
||
# in event data, which may append a numeric suffix (e.g., _2) since the
|
||
# actual vacuum entity already occupies the base entity_id.
|
||
- condition: template
|
||
value_template: >
|
||
{{ event_entity_id == vacuum_entity
|
||
or event_entity_id.startswith(vacuum_entity ~ '_') }}
|
||
|
||
# =============================================================================
|
||
# ACTIONS
|
||
# =============================================================================
|
||
action:
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Debug Logging
|
||
# ---------------------------------------------------------------------------
|
||
- choose:
|
||
- conditions:
|
||
- condition: template
|
||
value_template: "{{ enable_debug_notifications }}"
|
||
sequence:
|
||
- service: persistent_notification.create
|
||
data:
|
||
title: "Dreame Vacuum Debug"
|
||
message: >
|
||
**Trigger:** {{ trigger.id }}
|
||
**Entity:** {{ event_entity_id }}
|
||
**Vacuum:** {{ vacuum_name }}
|
||
**Event Data:** {{ trigger.event.data }}
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Send Notification Based on Event Type
|
||
# ---------------------------------------------------------------------------
|
||
- choose:
|
||
|
||
# CASE 1: Cleaning Started
|
||
- conditions:
|
||
- condition: template
|
||
value_template: >
|
||
{{ trigger.id == 'task_status'
|
||
and not task_completed
|
||
and enable_cleaning_started }}
|
||
sequence:
|
||
- variables:
|
||
message: >
|
||
{% set tpl = message_cleaning_started_template %}
|
||
{{ tpl | replace('{vacuum_name}', vacuum_name)
|
||
| replace('{cleaning_mode}', task_cleaning_mode)
|
||
| replace('{status}', task_status_value) }}
|
||
- service: notify.send_message
|
||
target:
|
||
entity_id: "{{ notify_targets }}"
|
||
data:
|
||
message: "{{ message }}"
|
||
|
||
# CASE 2: Cleaning Completed
|
||
- conditions:
|
||
- condition: template
|
||
value_template: >
|
||
{{ trigger.id == 'task_status'
|
||
and task_completed
|
||
and enable_cleaning_completed }}
|
||
sequence:
|
||
- variables:
|
||
message: >
|
||
{% set tpl = message_cleaning_completed_template %}
|
||
{{ tpl | replace('{vacuum_name}', vacuum_name)
|
||
| replace('{cleaning_mode}', task_cleaning_mode)
|
||
| replace('{status}', task_status_value)
|
||
| replace('{cleaned_area}', task_cleaned_area | string)
|
||
| replace('{cleaning_time}', task_cleaning_time | string) }}
|
||
- service: notify.send_message
|
||
target:
|
||
entity_id: "{{ notify_targets }}"
|
||
data:
|
||
message: "{{ message }}"
|
||
|
||
# CASE 3: Consumable Depleted
|
||
- conditions:
|
||
- condition: template
|
||
value_template: >
|
||
{{ trigger.id == 'consumable' and enable_consumable }}
|
||
sequence:
|
||
- variables:
|
||
message: >
|
||
{% set tpl = message_consumable_template %}
|
||
{{ tpl | replace('{vacuum_name}', vacuum_name)
|
||
| replace('{consumable}', consumable_name) }}
|
||
- service: notify.send_message
|
||
target:
|
||
entity_id: "{{ notify_targets }}"
|
||
data:
|
||
message: "{{ message }}"
|
||
|
||
# CASE 4: Warning
|
||
- conditions:
|
||
- condition: template
|
||
value_template: >
|
||
{{ trigger.id == 'warning' and enable_warning }}
|
||
sequence:
|
||
- variables:
|
||
message: >
|
||
{% set tpl = message_warning_template %}
|
||
{{ tpl | replace('{vacuum_name}', vacuum_name)
|
||
| replace('{warning}', warning_description)
|
||
| replace('{code}', warning_code | string) }}
|
||
- service: notify.send_message
|
||
target:
|
||
entity_id: "{{ notify_targets }}"
|
||
data:
|
||
message: "{{ message }}"
|
||
|
||
# CASE 5: Error
|
||
- conditions:
|
||
- condition: template
|
||
value_template: >
|
||
{{ trigger.id == 'error' and enable_error }}
|
||
sequence:
|
||
- variables:
|
||
message: >
|
||
{% set tpl = message_error_template %}
|
||
{{ tpl | replace('{vacuum_name}', vacuum_name)
|
||
| replace('{error}', error_description)
|
||
| replace('{code}', error_code | string) }}
|
||
- service: notify.send_message
|
||
target:
|
||
entity_id: "{{ notify_targets }}"
|
||
data:
|
||
message: "{{ message }}"
|
||
|
||
# CASE 6: Information
|
||
- conditions:
|
||
- condition: template
|
||
value_template: >
|
||
{{ trigger.id == 'information' and enable_information }}
|
||
sequence:
|
||
- variables:
|
||
message: >
|
||
{% set tpl = message_information_template %}
|
||
{{ tpl | replace('{vacuum_name}', vacuum_name)
|
||
| replace('{information}', information_description) }}
|
||
- service: notify.send_message
|
||
target:
|
||
entity_id: "{{ notify_targets }}"
|
||
data:
|
||
message: "{{ message }}"
|