Add multiple devices notification support to sockets control blueprint

This commit is contained in:
2026-06-29 00:39:38 +01:00
parent 1dba5c2f14
commit c9edc7bb78
@@ -1,6 +1,6 @@
blueprint:
name: Occupancy Socket Control with Power Alert
description: Turns off sockets when everyone leaves home and turns them back on when someone returns. Sends an alert if an appliance was actively drawing power when the home became empty.
name: Occupancy Socket Control with Power Alert (Multi-Device)
description: Turns off sockets when everyone leaves home and turns them back on when someone returns. Sends an alert to multiple chosen mobile devices if an appliance was actively drawing power when the home became empty.
domain: automation
input:
home_zone:
@@ -34,20 +34,21 @@ blueprint:
step: 0.1
unit_of_measurement: W
default: 1.0
notify_device:
name: Notification Device
description: Choose the mobile app device that should receive the notification.
notify_devices:
name: Notification Devices
description: Select one or more mobile devices to receive the alert.
selector:
device:
integration: mobile_app
multiple: true
mode: restart
# Bridge blueprint inputs into variables so Jinja can read them
variables:
switch_target: !input target_switches
sensor_entity: !input power_sensor
zone_entity: !input home_zone
target_devices: !input notify_devices
trigger:
- platform: zone
@@ -73,23 +74,26 @@ action:
entity_id: !input home_zone
below: 1
sequence:
# Check power consumption before killing the switch
- if:
- condition: numeric_state
entity_id: !input power_sensor
above: !input power_threshold
then:
- domain: mobile_app
type: notify
device_id: !input notify_device
title: "⚠️ Appliance Safely Turned Off"
message: >-
{% set switch_entity = switch_target.entity_id if switch_target.entity_id is string else (switch_target.entity_id | first | default('')) %}
{% set name = state_attr(switch_entity, 'friendly_name') | default('An appliance') | lower %}
{% set area = area_name(switch_entity) | default('') %}
{% set zone_name = state_attr(zone_entity, 'friendly_name') | default('home') | lower %}
# Loop through each selected device and push the notification
- repeat:
for_each: "{{ target_devices }}"
sequence:
- domain: mobile_app
type: notify
device_id: "{{ repeat.item }}"
title: "⚠️ Appliance Safely Turned Off"
message: >-
{% set switch_entity = switch_target.entity_id if switch_target.entity_id is string else (switch_target.entity_id | first | default('')) %}
{% set name = state_attr(switch_entity, 'friendly_name') | default('An appliance') | lower %}
{% set area = area_name(switch_entity) | default('') %}
{% set zone_name = state_attr(zone_entity, 'friendly_name') | default('home') | lower %}
The {{ name }}{% if area %} in the {{ area | lower }}{% endif %} was actively drawing power when you left {{ zone_name }}. It has been shut down automatically. Please verify if this requires further attention.
The {{ name }}{% if area %} in the {{ area | lower }}{% endif %} was actively drawing power when you left {{ zone_name }}. It has been shut down automatically. Please verify if this requires further attention.
# Turn off the target sockets
- action: switch.turn_off