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: blueprint:
name: Occupancy Socket Control with Power Alert 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 if an appliance was actively drawing power when the home became empty. 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 domain: automation
input: input:
home_zone: home_zone:
@@ -34,20 +34,21 @@ blueprint:
step: 0.1 step: 0.1
unit_of_measurement: W unit_of_measurement: W
default: 1.0 default: 1.0
notify_device: notify_devices:
name: Notification Device name: Notification Devices
description: Choose the mobile app device that should receive the notification. description: Select one or more mobile devices to receive the alert.
selector: selector:
device: device:
integration: mobile_app integration: mobile_app
multiple: true
mode: restart mode: restart
# Bridge blueprint inputs into variables so Jinja can read them
variables: variables:
switch_target: !input target_switches switch_target: !input target_switches
sensor_entity: !input power_sensor sensor_entity: !input power_sensor
zone_entity: !input home_zone zone_entity: !input home_zone
target_devices: !input notify_devices
trigger: trigger:
- platform: zone - platform: zone
@@ -73,15 +74,18 @@ action:
entity_id: !input home_zone entity_id: !input home_zone
below: 1 below: 1
sequence: sequence:
# Check power consumption before killing the switch
- if: - if:
- condition: numeric_state - condition: numeric_state
entity_id: !input power_sensor entity_id: !input power_sensor
above: !input power_threshold above: !input power_threshold
then: then:
# Loop through each selected device and push the notification
- repeat:
for_each: "{{ target_devices }}"
sequence:
- domain: mobile_app - domain: mobile_app
type: notify type: notify
device_id: !input notify_device device_id: "{{ repeat.item }}"
title: "⚠️ Appliance Safely Turned Off" title: "⚠️ Appliance Safely Turned Off"
message: >- message: >-
{% set switch_entity = switch_target.entity_id if switch_target.entity_id is string else (switch_target.entity_id | first | default('')) %} {% set switch_entity = switch_target.entity_id if switch_target.entity_id is string else (switch_target.entity_id | first | default('')) %}