diff --git a/blueprints/automation/wd-close-weather-notification.yaml b/blueprints/automation/wd-close-weather-notification.yaml index 0afb0c6..0134561 100644 --- a/blueprints/automation/wd-close-weather-notification.yaml +++ b/blueprints/automation/wd-close-weather-notification.yaml @@ -4,27 +4,27 @@ blueprint: Sends notifications when windows/doors are open during specific weather conditions or temperature thresholds. domain: automation + source_url: https://github.com/yourusername/hass-blueprints input: windows_doors: name: Windows & Doors description: Select all windows and doors to monitor selector: entity: - integration: binary_sensor domain: binary_sensor device_class: - door - window - opening multiple: true + required: true - notification_target: - name: Notification Target - description: The notification target (e.g., mobile_app_phone) + notify_service: + name: Notification Service + description: The notification service to use (e.g., notify.mobile_app_phone) selector: - target: {} + text: - # Weather Trigger Section weather_entity: name: Weather Entity description: Weather entity to monitor (e.g., weather.home) @@ -52,6 +52,138 @@ blueprint: value: hail - label: Lightning value: lightning + - label: Rainy + value: rainy + - label: Snowy + value: snowy + - label: Sunny + value: sunny + - label: Windy + value: windy + default: ["rainy", "snowy"] + + temperature_sensor: + name: Temperature Sensor + description: Temperature sensor to monitor + selector: + entity: + domain: sensor + device_class: temperature + + temp_high: + name: High Temperature (°C) + description: Notify if temperature exceeds this value + default: 25 + selector: + number: + min: -20 + max: 50 + step: 0.5 + unit_of_measurement: °C + mode: box + + temp_low: + name: Low Temperature (°C) + description: Notify if temperature drops below this value + default: 10 + selector: + number: + min: -20 + max: 50 + step: 0.5 + unit_of_measurement: °C + mode: box + +trigger: + # Weather state change + - platform: state + entity_id: !input 'weather_entity' + id: weather_change + + # Temperature high + - platform: numeric_state + entity_id: !input 'temperature_sensor' + above: !input 'temp_high' + id: temp_high_trigger + + # Temperature low + - platform: numeric_state + entity_id: !input 'temperature_sensor' + below: !input 'temp_low' + id: temp_low_trigger + +condition: + # Check if any window/door is open + - condition: or + conditions: >- + [ + {% for entity in windows_doors %} + { "condition": "state", "entity_id": "{{ entity }}", "state": "on" }{% if not loop.last %},{% endif %} + {% endfor %} + ] + +action: + - variables: + open_entities: >- + [ + {% for entity in windows_doors %} + {% if is_state(entity, 'on') %} + "{{ state_attr(entity, 'friendly_name') or entity }}"{% if not loop.last %},{% endif %} + {% endif %} + {% endfor %} + ] + open_count: '{{ open_entities | count }}' + + - choose: + - conditions: + - condition: trigger + id: weather_change + - condition: template + value_template: >- + {{ state_attr(trigger.entity_id, 'state') in weather_states }} + sequence: + - service: !input 'notify_service' + data: + message: >- + Weather is {{ state_attr(trigger.entity_id, 'state') }} and + {{ open_count }} opening(s) are open: {{ open_entities | join(', ') }} + title: "🌤️ Openings Alert" + + - conditions: + - condition: trigger + id: temp_high_trigger + sequence: + - service: !input 'notify_service' + data: + message: >- + Temperature is {{ states(temperature_sensor) | float | round(1) }}°C and + {{ open_count }} opening(s) are open: {{ open_entities | join(', ') }} + title: "🌡️ High Temperature Alert" + + - conditions: + - condition: trigger + id: temp_low_trigger + sequence: + - service: !input 'notify_service' + data: + message: >- + Temperature is {{ states(temperature_sensor) | float | round(1) }}°C and + {{ open_count }} opening(s) are open: {{ open_entities | join(', ') }} + title: "❄️ Low Temperature Alert" + +mode: queued +max: 10 + value: clear-night + - label: Cloudy + value: cloudy + - label: Exceptional + value: exceptional + - label: Fog + value: fog + - label: Hail + value: hail + - label: Lightning + value: lightning - label: Lightning Rainy value: lightning-rainy - label: Partly Cloudy