blueprint: 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: name: Home Zone description: The zone representing your home. selector: entity: domain: zone default: zone.home target_switches: name: Sockets / Switches description: The smart plugs to turn off when empty and turn on when occupied. selector: target: entity: domain: switch power_sensor: name: Power Metering Sensor description: The power sensor (Watts) to monitor for active consumption. selector: entity: domain: sensor device_class: power power_threshold: name: Power Threshold (Watts) description: Minimum wattage to trigger the alert (ignores standby power). selector: number: min: 0.1 max: 100.0 step: 0.1 unit_of_measurement: W default: 1.0 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 variables: switch_target: !input target_switches sensor_entity: !input power_sensor zone_entity: !input home_zone target_devices: !input notify_devices trigger: - platform: zone entity_id: !input home_zone event: leave zone: !input home_zone id: home_emptied - platform: zone entity_id: !input home_zone event: enter zone: !input home_zone id: someone_returned condition: [] action: - choose: # ACTION 1: EVERYONE LEAVES HOME - conditions: - condition: trigger id: home_emptied - condition: numeric_state entity_id: !input home_zone below: 1 sequence: - if: - condition: numeric_state entity_id: !input power_sensor above: !input power_threshold then: # 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. # Turn off the target sockets - action: switch.turn_off target: !input target_switches # ACTION 2: SOMEONE RETURNS HOME - conditions: - condition: trigger id: someone_returned - condition: numeric_state entity_id: !input home_zone above: 0 sequence: # Turn back on the target sockets - action: switch.turn_on target: !input target_switches