diff --git a/Occupancy_Socket_Control_with_Notifications.yaml b/Occupancy_Socket_Control_with_Notifications.yaml index 156da64..1fa64d9 100644 --- a/Occupancy_Socket_Control_with_Notifications.yaml +++ b/Occupancy_Socket_Control_with_Notifications.yaml @@ -35,13 +35,20 @@ blueprint: unit_of_measurement: W default: 1.0 notify_device: - name: Notification Action - description: The notification service to alert you when an active appliance is turned off. + name: Notification Device + description: Choose the mobile app device that should receive the notification. selector: - action: {} + device: + integration: mobile_app 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 + trigger: - platform: zone entity_id: !input home_zone @@ -72,8 +79,17 @@ action: entity_id: !input power_sensor above: !input power_threshold then: - - choose: [] - default: !input notify_device + - 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 %} + + 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