diff --git a/blueprints/automation/wd-close-weather-notification.yaml b/blueprints/automation/wd-close-weather-notification.yaml index 84a2263..b6cf941 100644 --- a/blueprints/automation/wd-close-weather-notification.yaml +++ b/blueprints/automation/wd-close-weather-notification.yaml @@ -1,5 +1,5 @@ blueprint: - name: Open Windows/Doors Notification (Clean) + name: Open Windows/Doors Notification description: Notify when windows or doors are open based on weather state or temperature thresholds. domain: automation input: @@ -37,7 +37,7 @@ blueprint: temp_above: name: Notify if Temperature Above description: Optional threshold to trigger notification - default: 24 + default: null selector: number: min: -50 @@ -46,7 +46,7 @@ blueprint: temp_below: name: Notify if Temperature Below description: Optional threshold to trigger notification - default: 15 + default: null selector: number: min: -50 @@ -63,15 +63,12 @@ blueprint: text: {} trigger: - # Trigger for weather states - platform: state entity_id: !input weather_sensor to: "{{ !input weather_trigger_states.split(',') | map('trim') | list }}" - # Trigger for temperature above - platform: numeric_state entity_id: !input temperature_sensor above: !input temp_above - # Trigger for temperature below - platform: numeric_state entity_id: !input temperature_sensor below: !input temp_below @@ -83,21 +80,26 @@ condition: action: - variables: + selected_openings: !input openings + selected_temp_sensor: !input temperature_sensor + selected_weather: !input weather_sensor + selected_notify_target: !input notify_target + selected_custom_message: !input custom_message open_entities: > - {{ states | selectattr('entity_id','in',!input.openings) | selectattr('state','eq','on') | map(attribute='attributes.friendly_name') | list }} + {{ states | selectattr('entity_id','in',selected_openings) | selectattr('state','eq','on') | map(attribute='attributes.friendly_name') | list }} trigger_state: > - {% if trigger.platform == 'numeric_state' %} + {% if trigger.platform in ['numeric_state','state'] %} {{ trigger.to_state.state }} {% else %} - {{ trigger.to_state.state }} + unknown {% endif %} - service: notify.notify data: - target: "{{ !input notify_target }}" + target: "{{ selected_notify_target }}" message: > {% for entity_name in open_entities %} - {{ !input custom_message + {{ selected_custom_message | replace('{{ entity_name }}', entity_name) | replace('{{ trigger_state }}', trigger_state) }}