Last active
April 21, 2026 01:57
-
-
Save Ltek/f58bbbde02471437ef863c334572a320 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint : Smart Garage - Door, Lighting, and Alerts by LTek
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: π Smart Garage - Door, Lighting, and Alerts by LTek | |
| description: | | |
| π **Smart Garage - Door, Lighting, and Alerts** | |
| Comprehensive Garage Automation for Door States, Notifications, Alerts, Lighting, and Auto-Close/Open | |
| π Version 2026.04.20.3c | |
| - Added: Auto-Close Bypass entity logic | |
| π Community Discussion, Help, and Details... https://community.home-assistant.io/t/smart-garage-control-doors-lighting-and-alerts/967636 | |
| source_url: https://gist.github.com/Ltek/f58bbbde02471437ef863c334572a320 | |
| Important Note: this made to work with garage doors that report as Covers entities. | |
| **FEATURES** | |
| πͺ Monitors all 5 garage door states - open, opening, closed, closing, stopped | |
| π’ Custom notifications per door state with configurable title, message, icon, color, and interruption level (iOS/Android) | |
| π Repeat notifications per state with configurable delay and max repeat count | |
| π¨ Alert notifications when door opens during restricted schedules or when a monitored entity is in a specific state | |
| π‘οΈ Notification bypass - suppress alerts by entity state or time schedule | |
| βοΈ Custom actions for each door state, alert, and lighting trigger | |
| β±οΈ Auto-close default timer - 24/7, no schedule required | |
| π Door Schedules to automatically open or close at specific days/times | |
| π‘ Independant Indoor and Outdoor lighting controls - lights, triggers, brightness, color temp, disable schedule, and timer bypass | |
| π¦ Lighting triggers include door states (opening, open, closing, stopped, closed) and additional entities (motion sensors, switches, locks, covers) | |
| β²οΈ Light Off Timer resets on every new trigger - works correctly with motion sensors and mode:restart | |
| π Debug notifications to Persistent UI with per-trigger-type filtering and optional variable dump | |
| domain: automation | |
| input: | |
| # ======================================== | |
| # GARAGE DOOR ENTITY (STANDALONE) | |
| # ======================================== | |
| garage_door_entity: | |
| name: Garage Door Entity | |
| description: The garage door cover entity to monitor | |
| selector: | |
| entity: | |
| domain: cover | |
| multiple: false | |
| # ======================================== | |
| # ALERT NOTIFICATION SECTION | |
| # ======================================== | |
| alert_notification_section: | |
| name: "Alert Notification Settings" | |
| description: "Alerts when OPENs during specific day/time schedules or based on entity state. Intended for getting an alert when the door opens during periods it should not be." | |
| icon: mdi:bell-alert | |
| collapsed: true | |
| input: | |
| alert_enable_notification: | |
| name: β Enable Alert Notifications | |
| description: Send when Time or Entity conditions are met | |
| default: false | |
| selector: | |
| boolean: {} | |
| # Alert Schedule Condition | |
| alert_enable_schedule: | |
| name: π Enable Schedule Condition | |
| description: Send alerts when door opens during specific days/times | |
| default: true | |
| selector: | |
| boolean: {} | |
| alert_days: | |
| name: ποΈ Alert Days | |
| description: Days when alerts should be sent during specified times (only if schedule condition is enabled) | |
| default: | |
| - mon | |
| - tue | |
| - wed | |
| - thu | |
| - fri | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: Monday | |
| value: mon | |
| - label: Tuesday | |
| value: tue | |
| - label: Wednesday | |
| value: wed | |
| - label: Thursday | |
| value: thu | |
| - label: Friday | |
| value: fri | |
| - label: Saturday | |
| value: sat | |
| - label: Sunday | |
| value: sun | |
| alert_start_time: | |
| name: π’ Start Time | |
| description: Start time for alert schedule when enabled. For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "22:00:00" | |
| selector: | |
| time: {} | |
| alert_end_time: | |
| name: π΄ End Time | |
| description: End time for alert schedule when enabled. For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "06:00:00" | |
| selector: | |
| time: {} | |
| # Entity State Condition | |
| alert_enable_entity: | |
| name: βοΈ Enable Entity State Condition | |
| description: Send alerts when specific entity is in specific state | |
| default: false | |
| selector: | |
| boolean: {} | |
| alert_entity: | |
| name: π Monitored Entity | |
| description: Entity to monitor for alert condition (only if entity condition is enabled) | |
| default: "" | |
| selector: | |
| entity: | |
| multiple: false | |
| alert_entity_states: | |
| name: π Monitored Entity State | |
| description: Comma-separated list of states that trigger alert (e.g., "Sleep,Away,Vacation"). If any state matches, alert is triggered. | |
| default: "on" | |
| selector: | |
| text: | |
| multiline: false | |
| alert_notify_devices: | |
| name: π² Mobile Notification Devices | |
| description: Mobile devices to receive alert notifications | |
| default: [] | |
| selector: | |
| device: | |
| integration: mobile_app | |
| multiple: true | |
| alert_notification_title: | |
| name: π¬ Alert Notification Title | |
| default: 'β οΈ Garage Door Alert' | |
| selector: | |
| text: {} | |
| alert_notification_message: | |
| name: π’ Alert Notification Message | |
| default: '{{ state_attr(garage_door_entity, "friendly_name") | default("Garage Door") }} was opened during alert hours at {{ now().strftime("%I:%M:%S %p") }}' | |
| selector: | |
| text: | |
| multiline: true | |
| alert_notification_click_url: | |
| name: π Alert Click URL | |
| default: /dashboard-garage | |
| selector: | |
| text: {} | |
| alert_notification_icon: | |
| name: π¨ Alert Notification Icon (Android) | |
| default: "bell-alert" | |
| selector: | |
| select: | |
| options: | |
| - label: "Bell Alert" | |
| value: "bell-alert" | |
| - label: "Alert Circle" | |
| value: "alert-circle" | |
| - label: "Security" | |
| value: "security" | |
| - label: "Garage Alert" | |
| value: "garage-alert" | |
| - label: "Home Alert" | |
| value: "home-alert" | |
| alert_notification_color: | |
| name: π¨ Alert Notification Color (Android) | |
| description: Hex color codes that work on both Android and iOS | |
| default: "#F44336" | |
| selector: | |
| select: | |
| options: | |
| - label: "Red (Alert)" | |
| value: "#F44336" | |
| - label: "Orange (Warning)" | |
| value: "#FF9800" | |
| - label: "Yellow" | |
| value: "#FFEB3B" | |
| - label: "Purple" | |
| value: "#9C27B0" | |
| - label: "Pink" | |
| value: "#E91E63" | |
| - label: "Blue (Info)" | |
| value: "#2196F3" | |
| - label: "Green (Success)" | |
| value: "#4CAF50" | |
| - label: "Teal" | |
| value: "#009688" | |
| - label: "Brown" | |
| value: "#795548" | |
| - label: "Grey" | |
| value: "#9E9E9E" | |
| alert_notification_persistent: | |
| name: π Alert Persistent (Android) | |
| default: true | |
| selector: | |
| boolean: {} | |
| alert_notification_interruption: | |
| name: π Alert Interruption Level (iOS) | |
| default: "critical" | |
| selector: | |
| select: | |
| options: | |
| - label: "Passive" | |
| value: "passive" | |
| - label: "Active" | |
| value: "active" | |
| - label: "Time Sensitive" | |
| value: "time-sensitive" | |
| - label: "Critical" | |
| value: "critical" | |
| alert_custom_action: | |
| name: βοΈ Alert Custom Action | |
| default: [] | |
| selector: | |
| action: {} | |
| # ======================================== | |
| # OPEN TRIGGER SETTINGS SECTION | |
| # ======================================== | |
| open_trigger_section: | |
| name: "Open Trigger Settings" | |
| description: "Configure notifications when door is OPEN" | |
| icon: mdi:garage-open | |
| collapsed: true | |
| input: | |
| open_enable_notification: | |
| name: π’ Enable Open Notifications | |
| default: true | |
| selector: | |
| boolean: {} | |
| open_duration_before_alert: | |
| name: β° Time Delay Before Open Alert | |
| description: How long door must be open before first alert | |
| default: | |
| minutes: 5 | |
| selector: | |
| duration: | |
| enable_day: true | |
| open_friendly_name: | |
| name: π·οΈ Custom Friendly Name | |
| default: 'Garage Door' | |
| selector: | |
| text: {} | |
| open_notify_devices: | |
| name: π² Mobile Notification Devices | |
| description: Mobile devices to receive notifications | |
| default: [] | |
| selector: | |
| device: | |
| integration: mobile_app | |
| multiple: true | |
| open_notification_title: | |
| name: π¬ Notification Title | |
| default: '{{ open_friendly_name }} is Open' | |
| selector: | |
| text: {} | |
| open_notification_message: | |
| name: π§ Notification Message | |
| default: 'Door has been open since {{ now().strftime("%I:%M:%S %p") }}' | |
| selector: | |
| text: | |
| multiline: true | |
| open_notification_click_url: | |
| name: π Click URL | |
| default: /dashboard-garage | |
| selector: | |
| text: {} | |
| open_repeat_notification: | |
| name: π Repeat Alerts | |
| default: true | |
| selector: | |
| boolean: {} | |
| open_max_repeat_count: | |
| name: π’ Maximum Repeat Count | |
| description: 0 for unlimited | |
| default: 0 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| mode: box | |
| open_time_between_repeats: | |
| name: β³ Delay Between Repeats | |
| default: | |
| minutes: 10 | |
| selector: | |
| duration: | |
| enable_day: true | |
| open_bypass_entities: | |
| name: π‘οΈ Bypass Entities | |
| description: No notifications when these are "on" | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| - input_boolean | |
| multiple: true | |
| open_bypass_schedule_enabled: | |
| name: π Enable Bypass Time Schedule | |
| description: Suppress notifications during specific days/times | |
| default: false | |
| selector: | |
| boolean: {} | |
| open_bypass_days: | |
| name: π Bypass Days | |
| description: Days when notifications should be suppressed during specified times | |
| default: | |
| - mon | |
| - tue | |
| - wed | |
| - thu | |
| - fri | |
| - sat | |
| - sun | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: Monday | |
| value: mon | |
| - label: Tuesday | |
| value: tue | |
| - label: Wednesday | |
| value: wed | |
| - label: Thursday | |
| value: thu | |
| - label: Friday | |
| value: fri | |
| - label: Saturday | |
| value: sat | |
| - label: Sunday | |
| value: sun | |
| open_bypass_start_time: | |
| name: π’ Bypass Start Time | |
| description: For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "00:00:00" | |
| selector: | |
| time: {} | |
| open_bypass_end_time: | |
| name: π΄ Bypass End Time | |
| description: For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "00:00:00" | |
| selector: | |
| time: {} | |
| open_notification_icon: | |
| name: π¨ Notification Icon (Android) | |
| default: "garage-open" | |
| selector: | |
| select: | |
| options: | |
| - label: "Garage Open" | |
| value: "garage-open" | |
| - label: "Garage Alert" | |
| value: "garage-alert" | |
| - label: "Alert Circle" | |
| value: "alert-circle" | |
| - label: "Door Open" | |
| value: "door-open" | |
| - label: "Home Alert" | |
| value: "home-alert" | |
| open_notification_color: | |
| name: π¨ Notification Color (Android) | |
| description: Hex color codes that work on both Android and iOS | |
| default: "#F44336" | |
| selector: | |
| select: | |
| options: | |
| - label: "Red (Alert)" | |
| value: "#F44336" | |
| - label: "Orange (Warning)" | |
| value: "#FF9800" | |
| - label: "Yellow" | |
| value: "#FFEB3B" | |
| - label: "Green (Success)" | |
| value: "#4CAF50" | |
| - label: "Blue (Info)" | |
| value: "#2196F3" | |
| - label: "Purple" | |
| value: "#9C27B0" | |
| - label: "Pink" | |
| value: "#E91E63" | |
| - label: "Teal" | |
| value: "#009688" | |
| - label: "Brown" | |
| value: "#795548" | |
| - label: "Grey" | |
| value: "#9E9E9E" | |
| open_notification_persistent: | |
| name: π Persistent (Android) | |
| default: false | |
| selector: | |
| boolean: {} | |
| open_notification_interruption: | |
| name: π Interruption Level (iOS) | |
| default: "active" | |
| selector: | |
| select: | |
| options: | |
| - label: "Passive" | |
| value: "passive" | |
| - label: "Active" | |
| value: "active" | |
| - label: "Time Sensitive" | |
| value: "time-sensitive" | |
| - label: "Critical" | |
| value: "critical" | |
| open_custom_action: | |
| name: βοΈ Custom Action | |
| default: [] | |
| selector: | |
| action: {} | |
| # ======================================== | |
| # OPENING TRIGGER SETTINGS SECTION | |
| # ======================================== | |
| opening_trigger_section: | |
| name: "Opening Trigger Settings" | |
| description: "Configure notifications when door is OPENING" | |
| icon: mdi:arrow-up | |
| collapsed: true | |
| input: | |
| opening_enable_notification: | |
| name: π’ Enable Opening Notifications | |
| default: false | |
| selector: | |
| boolean: {} | |
| opening_duration_before_alert: | |
| name: β° Time Delay Before Opening Alert | |
| default: | |
| seconds: 0 | |
| selector: | |
| duration: | |
| enable_day: true | |
| opening_friendly_name: | |
| name: π·οΈ Custom Friendly Name | |
| default: 'Garage Door' | |
| selector: | |
| text: {} | |
| opening_notify_devices: | |
| name: π² Mobile Notification Devices | |
| description: Mobile devices to receive notifications | |
| default: [] | |
| selector: | |
| device: | |
| integration: mobile_app | |
| multiple: true | |
| opening_notification_title: | |
| name: π¬ Notification Title | |
| default: '{{ opening_friendly_name }} is Opening' | |
| selector: | |
| text: {} | |
| opening_notification_message: | |
| name: π§ Notification Message | |
| default: 'Door started opening at {{ now().strftime("%I:%M:%S %p") }}' | |
| selector: | |
| text: | |
| multiline: true | |
| opening_notification_click_url: | |
| name: π Click URL | |
| default: /dashboard-garage | |
| selector: | |
| text: {} | |
| opening_repeat_notification: | |
| name: π Repeat Alerts | |
| default: false | |
| selector: | |
| boolean: {} | |
| opening_max_repeat_count: | |
| name: π’ Maximum Repeat Count | |
| default: 0 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| mode: box | |
| opening_time_between_repeats: | |
| name: β³ Delay Between Repeats | |
| default: | |
| minutes: 1 | |
| selector: | |
| duration: | |
| enable_day: true | |
| opening_bypass_entities: | |
| name: π‘οΈ Bypass Entities | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| - input_boolean | |
| multiple: true | |
| opening_notification_icon: | |
| name: π¨ Notification Icon (Android) | |
| default: "garage-open-variant" | |
| selector: | |
| select: | |
| options: | |
| - label: "Garage Open Variant" | |
| value: "garage-open-variant" | |
| - label: "Garage" | |
| value: "garage" | |
| - label: "Arrow Up" | |
| value: "arrow-up" | |
| - label: "Door Open" | |
| value: "door-open" | |
| opening_notification_color: | |
| name: π¨ Notification Color (Android) | |
| description: Hex color codes that work on both Android and iOS | |
| default: "#FF9800" | |
| selector: | |
| select: | |
| options: | |
| - label: "Orange (Warning)" | |
| value: "#FF9800" | |
| - label: "Red (Alert)" | |
| value: "#F44336" | |
| - label: "Yellow" | |
| value: "#FFEB3B" | |
| - label: "Green (Success)" | |
| value: "#4CAF50" | |
| - label: "Blue (Info)" | |
| value: "#2196F3" | |
| - label: "Purple" | |
| value: "#9C27B0" | |
| - label: "Pink" | |
| value: "#E91E63" | |
| opening_notification_persistent: | |
| name: π Persistent (Android) | |
| default: false | |
| selector: | |
| boolean: {} | |
| opening_notification_interruption: | |
| name: π Interruption Level (iOS) | |
| default: "passive" | |
| selector: | |
| select: | |
| options: | |
| - label: "Passive" | |
| value: "passive" | |
| - label: "Active" | |
| value: "active" | |
| - label: "Time Sensitive" | |
| value: "time-sensitive" | |
| - label: "Critical" | |
| value: "critical" | |
| opening_custom_action: | |
| name: βοΈ Custom Action | |
| default: [] | |
| selector: | |
| action: {} | |
| # ======================================== | |
| # CLOSED TRIGGER SETTINGS SECTION | |
| # ======================================== | |
| closed_trigger_section: | |
| name: "Closed Trigger Settings" | |
| description: "Configure notifications when door is CLOSED" | |
| icon: mdi:garage | |
| collapsed: true | |
| input: | |
| closed_enable_notification: | |
| name: π’ Enable Closed Notifications | |
| default: false | |
| selector: | |
| boolean: {} | |
| closed_duration_before_alert: | |
| name: β° Time Delay Before Closed Alert | |
| default: | |
| seconds: 0 | |
| selector: | |
| duration: | |
| enable_day: true | |
| closed_friendly_name: | |
| name: π·οΈ Custom Friendly Name | |
| default: 'Garage Door' | |
| selector: | |
| text: {} | |
| closed_notify_devices: | |
| name: π² Mobile Notification Devices | |
| description: Mobile devices to receive notifications | |
| default: [] | |
| selector: | |
| device: | |
| integration: mobile_app | |
| multiple: true | |
| closed_notification_title: | |
| name: π¬ Notification Title | |
| default: '{{ closed_friendly_name }} is Closed' | |
| selector: | |
| text: {} | |
| closed_notification_message: | |
| name: π§ Notification Message | |
| default: 'Door closed at {{ now().strftime("%I:%M:%S %p") }}' | |
| selector: | |
| text: | |
| multiline: true | |
| closed_notification_click_url: | |
| name: π Click URL | |
| default: /dashboard-garage | |
| selector: | |
| text: {} | |
| closed_repeat_notification: | |
| name: π Repeat Alerts | |
| default: false | |
| selector: | |
| boolean: {} | |
| closed_max_repeat_count: | |
| name: π’ Maximum Repeat Count | |
| default: 0 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| mode: box | |
| closed_time_between_repeats: | |
| name: β³ Delay Between Repeats | |
| default: | |
| minutes: 1 | |
| selector: | |
| duration: | |
| enable_day: true | |
| closed_bypass_entities: | |
| name: π‘οΈ Bypass Entities | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| - input_boolean | |
| multiple: true | |
| closed_notification_icon: | |
| name: π¨ Notification Icon (Android) | |
| default: "garage" | |
| selector: | |
| select: | |
| options: | |
| - label: "Garage" | |
| value: "garage" | |
| - label: "Garage Variant" | |
| value: "garage-variant" | |
| - label: "Check Circle" | |
| value: "check-circle" | |
| - label: "Door Closed" | |
| value: "door-closed" | |
| closed_notification_color: | |
| name: π¨ Notification Color (Android) | |
| description: Hex color codes that work on both Android and iOS | |
| default: "#4CAF50" | |
| selector: | |
| select: | |
| options: | |
| - label: "Green (Success)" | |
| value: "#4CAF50" | |
| - label: "Blue (Info)" | |
| value: "#2196F3" | |
| - label: "Red (Alert)" | |
| value: "#F44336" | |
| - label: "Orange (Warning)" | |
| value: "#FF9800" | |
| - label: "Yellow" | |
| value: "#FFEB3B" | |
| - label: "Purple" | |
| value: "#9C27B0" | |
| - label: "Teal" | |
| value: "#009688" | |
| closed_notification_persistent: | |
| name: π Persistent (Android) | |
| default: false | |
| selector: | |
| boolean: {} | |
| closed_notification_interruption: | |
| name: π Interruption Level (iOS) | |
| default: "passive" | |
| selector: | |
| select: | |
| options: | |
| - label: "Passive" | |
| value: "passive" | |
| - label: "Active" | |
| value: "active" | |
| - label: "Time Sensitive" | |
| value: "time-sensitive" | |
| - label: "Critical" | |
| value: "critical" | |
| closed_custom_action: | |
| name: βοΈ Custom Action | |
| default: [] | |
| selector: | |
| action: {} | |
| # ======================================== | |
| # CLOSING TRIGGER SETTINGS SECTION | |
| # ======================================== | |
| closing_trigger_section: | |
| name: "Closing Trigger Settings" | |
| description: "Configure notifications when door is CLOSING" | |
| icon: mdi:arrow-down | |
| collapsed: true | |
| input: | |
| closing_enable_notification: | |
| name: π¬ Enable Closing Notifications | |
| default: false | |
| selector: | |
| boolean: {} | |
| closing_duration_before_alert: | |
| name: β° Time Delay Before Closing Alert | |
| default: | |
| seconds: 0 | |
| selector: | |
| duration: | |
| enable_day: true | |
| closing_friendly_name: | |
| name: π·οΈ Custom Friendly Name | |
| default: 'Garage Door' | |
| selector: | |
| text: {} | |
| closing_notify_devices: | |
| name: π² Mobile Notification Devices | |
| description: Mobile devices to receive notifications | |
| default: [] | |
| selector: | |
| device: | |
| integration: mobile_app | |
| multiple: true | |
| closing_notification_title: | |
| name: π¬ Notification Title | |
| default: '{{ closing_friendly_name }} is Closing' | |
| selector: | |
| text: {} | |
| closing_notification_message: | |
| name: π§ Notification Message | |
| default: 'Door started closing at {{ now().strftime("%I:%M:%S %p") }}' | |
| selector: | |
| text: | |
| multiline: true | |
| closing_notification_click_url: | |
| name: π Click URL | |
| default: /dashboard-garage | |
| selector: | |
| text: {} | |
| closing_repeat_notification: | |
| name: π Repeat Alerts | |
| default: false | |
| selector: | |
| boolean: {} | |
| closing_max_repeat_count: | |
| name: π’ Maximum Repeat Count | |
| default: 0 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| mode: box | |
| closing_time_between_repeats: | |
| name: β³ Delay Between Repeats | |
| default: | |
| minutes: 1 | |
| selector: | |
| duration: | |
| enable_day: true | |
| closing_bypass_entities: | |
| name: π‘οΈ Bypass Entities | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| - input_boolean | |
| multiple: true | |
| closing_notification_icon: | |
| name: π¨ Notification Icon (Android) | |
| default: "garage-variant" | |
| selector: | |
| select: | |
| options: | |
| - label: "Garage Variant" | |
| value: "garage-variant" | |
| - label: "Garage" | |
| value: "garage" | |
| - label: "Arrow Down" | |
| value: "arrow-down" | |
| - label: "Door Closed" | |
| value: "door-closed" | |
| closing_notification_color: | |
| name: π¨ Notification Color (Android) | |
| description: Hex color codes that work on both Android and iOS | |
| default: "#2196F3" | |
| selector: | |
| select: | |
| options: | |
| - label: "Blue (Info)" | |
| value: "#2196F3" | |
| - label: "Green (Success)" | |
| value: "#4CAF50" | |
| - label: "Red (Alert)" | |
| value: "#F44336" | |
| - label: "Orange (Warning)" | |
| value: "#FF9800" | |
| - label: "Yellow" | |
| value: "#FFEB3B" | |
| - label: "Purple" | |
| value: "#9C27B0" | |
| - label: "Teal" | |
| value: "#009688" | |
| closing_notification_persistent: | |
| name: π Persistent (Android) | |
| default: false | |
| selector: | |
| boolean: {} | |
| closing_notification_interruption: | |
| name: π Interruption Level (iOS) | |
| default: "passive" | |
| selector: | |
| select: | |
| options: | |
| - label: "Passive" | |
| value: "passive" | |
| - label: "Active" | |
| value: "active" | |
| - label: "Time Sensitive" | |
| value: "time-sensitive" | |
| - label: "Critical" | |
| value: "critical" | |
| closing_custom_action: | |
| name: βοΈ Custom Action | |
| default: [] | |
| selector: | |
| action: {} | |
| # ======================================== | |
| # STOPPED TRIGGER SETTINGS SECTION | |
| # ======================================== | |
| stopped_trigger_section: | |
| name: "Stopped Trigger Settings" | |
| description: "Configure notifications when door is STOPPED" | |
| icon: mdi:alert-circle | |
| collapsed: true | |
| input: | |
| stopped_enable_notification: | |
| name: π’ Enable Stopped Notifications | |
| default: true | |
| selector: | |
| boolean: {} | |
| stopped_duration_before_alert: | |
| name: β° Time Delay Before Stopped Alert | |
| default: | |
| seconds: 5 | |
| selector: | |
| duration: | |
| enable_day: true | |
| stopped_friendly_name: | |
| name: π·οΈ Custom Friendly Name | |
| default: 'Garage Door' | |
| selector: | |
| text: {} | |
| stopped_notify_devices: | |
| name: π² Mobile Notification Devices | |
| description: Mobile devices to receive notifications | |
| default: [] | |
| selector: | |
| device: | |
| integration: mobile_app | |
| multiple: true | |
| stopped_notification_title: | |
| name: π¬ Notification Title | |
| default: 'β οΈ {{ stopped_friendly_name }} Stopped Mid-Position' | |
| selector: | |
| text: {} | |
| stopped_notification_message: | |
| name: π§ Notification Message | |
| default: 'Door stopped at {{ now().strftime("%I:%M:%S %p") }}' | |
| selector: | |
| text: | |
| multiline: true | |
| stopped_notification_click_url: | |
| name: π Click URL | |
| default: /dashboard-garage | |
| selector: | |
| text: {} | |
| stopped_repeat_notification: | |
| name: π Repeat Alerts | |
| default: true | |
| selector: | |
| boolean: {} | |
| stopped_max_repeat_count: | |
| name: π’ Maximum Repeat Count | |
| default: 3 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| mode: box | |
| stopped_time_between_repeats: | |
| name: β³ Delay Between Repeats | |
| default: | |
| minutes: 5 | |
| selector: | |
| duration: | |
| enable_day: true | |
| stopped_bypass_entities: | |
| name: π‘οΈ Bypass Entities | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| - input_boolean | |
| multiple: true | |
| stopped_notification_icon: | |
| name: π¨ Notification Icon (Android) | |
| default: "alert-circle" | |
| selector: | |
| select: | |
| options: | |
| - label: "Alert Circle" | |
| value: "alert-circle" | |
| - label: "Alert" | |
| value: "alert" | |
| - label: "Pause Circle" | |
| value: "pause-circle" | |
| - label: "Garage Alert" | |
| value: "garage-alert" | |
| stopped_notification_color: | |
| name: π¨ Notification Color (Android) | |
| description: Hex color codes that work on both Android and iOS | |
| default: "#FF9800" | |
| selector: | |
| select: | |
| options: | |
| - label: "Orange (Warning)" | |
| value: "#FF9800" | |
| - label: "Red (Alert)" | |
| value: "#F44336" | |
| - label: "Yellow" | |
| value: "#FFEB3B" | |
| - label: "Purple" | |
| value: "#9C27B0" | |
| - label: "Pink" | |
| value: "#E91E63" | |
| - label: "Blue (Info)" | |
| value: "#2196F3" | |
| - label: "Green (Success)" | |
| value: "#4CAF50" | |
| stopped_notification_persistent: | |
| name: π Persistent (Android) | |
| default: true | |
| selector: | |
| boolean: {} | |
| stopped_notification_interruption: | |
| name: π Interruption Level (iOS) | |
| default: "time-sensitive" | |
| selector: | |
| select: | |
| options: | |
| - label: "Passive" | |
| value: "passive" | |
| - label: "Active" | |
| value: "active" | |
| - label: "Time Sensitive" | |
| value: "time-sensitive" | |
| - label: "Critical" | |
| value: "critical" | |
| stopped_custom_action: | |
| name: βοΈ Custom Action | |
| default: [] | |
| selector: | |
| action: {} | |
| # ======================================== | |
| # INDOOR LIGHTING SECTION | |
| # ======================================== | |
| lighting_section: | |
| name: "Indoor Light Controls" | |
| description: "Indoor lighting triggers for Door States, Additional Entities, and Light Settings; plus Custom Actions!" | |
| icon: mdi:lightbulb | |
| collapsed: true | |
| input: | |
| lighting_enable_control: | |
| name: π― Enable Lighting Control | |
| description: Enable automatic lighting control based triggers below | |
| default: false | |
| selector: | |
| boolean: {} | |
| lighting_entities: | |
| name: π‘ Lights to Control | |
| description: Select the lights to control | |
| default: [] | |
| selector: | |
| entity: | |
| domain: light | |
| multiple: true | |
| lighting_trigger_entity: | |
| name: β‘ Triggers to Turn Lights ON | |
| description: Lights turn on when these entities change to ON (motion sensor, lock, door sensor, switch, cover/door) | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| - switch | |
| - lock | |
| - cover | |
| - motion | |
| multiple: true | |
| lighting_triggers: | |
| name: π Door State Triggers | |
| description: Select which door states should turn lights ON | |
| default: | |
| - open | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: "πΌ Turn On when Opening" | |
| value: opening | |
| - label: "π΅ Turn On when 100% Open" | |
| value: open | |
| - label: "π½ Turn On when Closing" | |
| value: closing | |
| - label: "β οΈ Turn On when Stopped mid-cycle" | |
| value: stopped | |
| lighting_turn_off_on_close: | |
| name: β Turn Off Lights when Door Closes | |
| description: > | |
| Turn off indoor lights when the door reaches fully closed (after the delay below). | |
| Recommended: keep enabled so lights are not left on when mode:restart | |
| cancels a running timer due to a new door state trigger. | |
| default: true | |
| selector: | |
| boolean: {} | |
| lighting_turn_off_on_close_delay: | |
| name: β±οΈ Turn Off Delay when Door Closes | |
| description: > | |
| How long to wait after the door closes before turning off indoor lights. | |
| Set to 0 for immediate off. Increase if people may still be in the garage | |
| when the door closes and need time to exit before the lights turn off. | |
| default: | |
| seconds: 0 | |
| selector: | |
| duration: | |
| enable_day: false | |
| lighting_off_timer: | |
| name: β±οΈ Light Off Timer | |
| description: Turn lights off after this delay (0 to disable auto-off) | |
| default: | |
| minutes: 5 | |
| selector: | |
| duration: | |
| enable_day: true | |
| lighting_manual_control_timer: | |
| name: β±οΈ Light Off Timer Works for Manual Control Also | |
| description: > | |
| When enabled, manually turning on a light will also start the Light Off Timer. | |
| The automation adds your configured lights as additional trigger entities and uses | |
| context detection to prevent infinite loops (only triggers on human/external changes, | |
| not on changes made by this automation itself). | |
| default: false | |
| selector: | |
| boolean: {} | |
| lighting_bypass_timer_enabled: | |
| name: π« Enable Light Off Timer Bypass | |
| description: When enabled, the Bypass Entity below can disable the Light Off Timer function | |
| default: false | |
| selector: | |
| boolean: {} | |
| lighting_bypass_timer_entity: | |
| name: π Light Off Timer Bypass Entity | |
| description: > | |
| When the condition defined here is true, the Light Off Timer will be bypassed and lights | |
| will not be auto-turned off. Only active if "Enable Light Off Timer Bypass" is turned on. | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| - input_boolean | |
| - switch | |
| multiple: true | |
| lighting_brightness: | |
| name: π Light Brightness | |
| description: Brightness percentage when turning lights on (1-100) | |
| default: 100 | |
| selector: | |
| number: | |
| min: 1 | |
| max: 100 | |
| step: 1 | |
| unit_of_measurement: '%' | |
| mode: slider | |
| lighting_color_temp: | |
| name: π¨ Light Color Temperature | |
| description: Color temperature in Kelvin (optional) | |
| default: 3000 | |
| selector: | |
| number: | |
| min: 2000 | |
| max: 6500 | |
| step: 100 | |
| unit_of_measurement: 'K' | |
| mode: box | |
| lighting_schedule_enabled: | |
| name: π Use Disable Schedule? | |
| description: Disable lighting control during specific days/times | |
| default: false | |
| selector: | |
| boolean: {} | |
| lighting_schedule_days: | |
| name: π Disabled Days | |
| description: Days when lighting control should be disabled | |
| default: | |
| - mon | |
| - tue | |
| - wed | |
| - thu | |
| - fri | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: Monday | |
| value: mon | |
| - label: Tuesday | |
| value: tue | |
| - label: Wednesday | |
| value: wed | |
| - label: Thursday | |
| value: thu | |
| - label: Friday | |
| value: fri | |
| - label: Saturday | |
| value: sat | |
| - label: Sunday | |
| value: sun | |
| lighting_schedule_start_time: | |
| name: π’ Disabled Start Time | |
| description: Disable lighting control starts at this time. For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "06:00:00" | |
| selector: | |
| time: {} | |
| lighting_schedule_end_time: | |
| name: π΄ Disabled End Time | |
| description: Disable lighting control ends at this time. For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "17:00:00" | |
| selector: | |
| time: {} | |
| lighting_custom_action: | |
| name: βοΈ Custom Lighting Action | |
| description: Custom action to run for lighting control | |
| default: [] | |
| selector: | |
| action: {} | |
| # ======================================== | |
| # OUTDOOR LIGHTING SECTION | |
| # ======================================== | |
| outdoor_lighting_section: | |
| name: "Outdoor Light Controls" | |
| description: "Outdoor lighting triggers for Door States, Additional Entities, and Light Settings; plus Custom Actions!" | |
| icon: mdi:coach-lamp | |
| collapsed: true | |
| input: | |
| outdoor_lighting_enable_control: | |
| name: π― Enable Outdoor Lighting Control | |
| description: Enable automatic outdoor lighting control based triggers below | |
| default: false | |
| selector: | |
| boolean: {} | |
| outdoor_lighting_entities: | |
| name: π‘ Outdoor Lights to Control | |
| description: Select the outdoor lights to control | |
| default: [] | |
| selector: | |
| entity: | |
| domain: light | |
| multiple: true | |
| outdoor_lighting_trigger_entity: | |
| name: β‘ Triggers to Turn Outdoor Lights ON | |
| description: Outdoor lights turn on when these entities change to ON (motion sensor, lock, door sensor, switch, cover/door) | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| - switch | |
| - lock | |
| - cover | |
| - motion | |
| multiple: true | |
| outdoor_lighting_triggers: | |
| name: π Door State Triggers | |
| description: Select which door states should turn outdoor lights ON | |
| default: | |
| - open | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: "πΌ Turn On when Opening" | |
| value: opening | |
| - label: "π΅ Turn On when 100% Open" | |
| value: open | |
| - label: "π½ Turn On when Closing" | |
| value: closing | |
| - label: "β οΈ Turn On when Stopped mid-cycle" | |
| value: stopped | |
| outdoor_lighting_turn_off_on_close: | |
| name: β Turn Off Outdoor Lights when Door Closes | |
| description: > | |
| Turn off outdoor lights when the door reaches fully closed (after the delay below). | |
| Recommended: keep enabled so lights are not left on when mode:restart | |
| cancels a running timer due to a new door state trigger. | |
| default: true | |
| selector: | |
| boolean: {} | |
| outdoor_lighting_turn_off_on_close_delay: | |
| name: β±οΈ Turn Off Delay when Door Closes | |
| description: > | |
| How long to wait after the door closes before turning off outdoor lights. | |
| Set to 0 for immediate off. Increase if people may still be outside | |
| and need time before the lights turn off. | |
| default: | |
| seconds: 0 | |
| selector: | |
| duration: | |
| enable_day: false | |
| outdoor_lighting_off_timer: | |
| name: β±οΈ Outdoor Light Off Timer | |
| description: Turn outdoor lights off after this delay (0 to disable auto-off) | |
| default: | |
| minutes: 5 | |
| selector: | |
| duration: | |
| enable_day: true | |
| outdoor_lighting_manual_control_timer: | |
| name: β±οΈ Outdoor Light Off Timer Works for Manual Control Also | |
| description: > | |
| When enabled, manually turning on an outdoor light will also start the Outdoor Light Off Timer. | |
| The automation adds your configured outdoor lights as additional trigger entities and uses | |
| context detection to prevent infinite loops (only triggers on human/external changes, | |
| not on changes made by this automation itself). | |
| default: false | |
| selector: | |
| boolean: {} | |
| outdoor_lighting_bypass_timer_enabled: | |
| name: π« Enable Outdoor Light Off Timer Bypass | |
| description: When enabled, the Bypass Entity below can disable the Outdoor Light Off Timer function | |
| default: false | |
| selector: | |
| boolean: {} | |
| outdoor_lighting_bypass_timer_entity: | |
| name: π Outdoor Light Off Timer Bypass Entity | |
| description: > | |
| When the condition defined here is true, the Outdoor Light Off Timer will be bypassed and outdoor lights | |
| will not be auto-turned off. Only active if "Enable Outdoor Light Off Timer Bypass" is turned on. | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - binary_sensor | |
| - input_boolean | |
| - switch | |
| multiple: true | |
| outdoor_lighting_brightness: | |
| name: π Outdoor Light Brightness | |
| description: Brightness percentage when turning outdoor lights on (1-100) | |
| default: 100 | |
| selector: | |
| number: | |
| min: 1 | |
| max: 100 | |
| step: 1 | |
| unit_of_measurement: '%' | |
| mode: slider | |
| outdoor_lighting_color_temp: | |
| name: π¨ Outdoor Light Color Temperature | |
| description: Color temperature in Kelvin (optional) | |
| default: 3000 | |
| selector: | |
| number: | |
| min: 2000 | |
| max: 6500 | |
| step: 100 | |
| unit_of_measurement: 'K' | |
| mode: box | |
| outdoor_lighting_schedule_enabled: | |
| name: π Use Outdoor Disable Schedule? | |
| description: Disable outdoor lighting control during specific days/times | |
| default: false | |
| selector: | |
| boolean: {} | |
| outdoor_lighting_schedule_days: | |
| name: π Outdoor Disabled Days | |
| description: Days when outdoor lighting control should be disabled | |
| default: | |
| - mon | |
| - tue | |
| - wed | |
| - thu | |
| - fri | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: Monday | |
| value: mon | |
| - label: Tuesday | |
| value: tue | |
| - label: Wednesday | |
| value: wed | |
| - label: Thursday | |
| value: thu | |
| - label: Friday | |
| value: fri | |
| - label: Saturday | |
| value: sat | |
| - label: Sunday | |
| value: sun | |
| outdoor_lighting_schedule_start_time: | |
| name: π’ Outdoor Disabled Start Time | |
| description: Disable outdoor lighting control starts at this time. For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "06:00:00" | |
| selector: | |
| time: {} | |
| outdoor_lighting_schedule_end_time: | |
| name: π΄ Outdoor Disabled End Time | |
| description: Disable outdoor lighting control ends at this time. For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "17:00:00" | |
| selector: | |
| time: {} | |
| outdoor_lighting_custom_action: | |
| name: βοΈ Custom Outdoor Lighting Action | |
| description: Custom action to run for outdoor lighting control | |
| default: [] | |
| selector: | |
| action: {} | |
| # ======================================== | |
| # AUTO-CLOSE DEFAULT SECTION | |
| # ======================================== | |
| autoclose_default_section: | |
| name: "Auto-Close Default" | |
| description: "Auto-close door after a set time (does not use a schedule)" | |
| icon: mdi:timer-outline | |
| collapsed: true | |
| input: | |
| autoclose_default_enabled: | |
| name: π Enable Auto-Close Default | |
| description: Auto-close door after delay below when door opens (24/7) | |
| default: false | |
| selector: | |
| boolean: {} | |
| autoclose_default_delay: | |
| name: β±οΈ Auto-Close Delay | |
| description: How long door stays open before auto-closing | |
| default: | |
| minutes: 10 | |
| selector: | |
| duration: | |
| enable_day: true | |
| autoclose_bypass_entity: | |
| name: π‘οΈ Auto-Close Bypass Entity (Optional) | |
| description: > | |
| When this entity is 'on', the auto-close will be skipped. | |
| Useful for holding the door open while someone is working in the garage, | |
| a guest is present, etc. Leave blank to disable bypass. | |
| default: [] | |
| selector: | |
| entity: | |
| multiple: true | |
| # ======================================== | |
| # DOOR SCHEDULE 1 SECTION | |
| # ======================================== | |
| door_schedule1_section: | |
| name: "Door Schedule 1" | |
| description: "Schedule to automatically open or close the door. For 24-hour coverage, set both start and end times to 00:00:00." | |
| icon: mdi:calendar-clock | |
| collapsed: true | |
| input: | |
| schedule1_enabled: | |
| name: π Enable Door Schedule 1 | |
| default: false | |
| selector: | |
| boolean: {} | |
| schedule1_action: | |
| name: βοΈ Schedule Action | |
| description: Whether to open or close the door during this schedule | |
| default: close | |
| selector: | |
| select: | |
| options: | |
| - label: Close Door | |
| value: close | |
| - label: Open Door | |
| value: open | |
| schedule1_days: | |
| name: π Active Days | |
| default: | |
| - mon | |
| - tue | |
| - wed | |
| - thu | |
| - fri | |
| - sat | |
| - sun | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: Monday | |
| value: mon | |
| - label: Tuesday | |
| value: tue | |
| - label: Wednesday | |
| value: wed | |
| - label: Thursday | |
| value: thu | |
| - label: Friday | |
| value: fri | |
| - label: Saturday | |
| value: sat | |
| - label: Sunday | |
| value: sun | |
| schedule1_start_time: | |
| name: π’ Start Time | |
| description: For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "00:00:00" | |
| selector: | |
| time: {} | |
| schedule1_end_time: | |
| name: π΄ End Time | |
| description: For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "00:00:00" | |
| selector: | |
| time: {} | |
| schedule1_delay: | |
| name: β±οΈ Action Delay | |
| description: How long after door opens before closing (for close action) or how long after schedule starts before opening (for open action) | |
| default: | |
| minutes: 10 | |
| selector: | |
| duration: | |
| enable_day: true | |
| # ======================================== | |
| # DOOR SCHEDULE 2 SECTION | |
| # ======================================== | |
| door_schedule2_section: | |
| name: "Door Schedule 2" | |
| description: "Schedule to automatically open or close the door. For 24-hour coverage, set both start and end times to 00:00:00." | |
| icon: mdi:calendar-clock | |
| collapsed: true | |
| input: | |
| schedule2_enabled: | |
| name: π Enable Door Schedule 2 | |
| default: false | |
| selector: | |
| boolean: {} | |
| schedule2_action: | |
| name: βοΈ Schedule Action | |
| description: Whether to open or close the door during this schedule | |
| default: close | |
| selector: | |
| select: | |
| options: | |
| - label: Close Door | |
| value: close | |
| - label: Open Door | |
| value: open | |
| schedule2_days: | |
| name: π Active Days | |
| default: | |
| - mon | |
| - tue | |
| - wed | |
| - thu | |
| - fri | |
| - sat | |
| - sun | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: Monday | |
| value: mon | |
| - label: Tuesday | |
| value: tue | |
| - label: Wednesday | |
| value: wed | |
| - label: Thursday | |
| value: thu | |
| - label: Friday | |
| value: fri | |
| - label: Saturday | |
| value: sat | |
| - label: Sunday | |
| value: sun | |
| schedule2_start_time: | |
| name: π’ Start Time | |
| description: For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "00:00:00" | |
| selector: | |
| time: {} | |
| schedule2_end_time: | |
| name: π΄ End Time | |
| description: For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "00:00:00" | |
| selector: | |
| time: {} | |
| schedule2_delay: | |
| name: β±οΈ Action Delay | |
| description: How long after door opens before closing (for close action) or how long after schedule starts before opening (for open action) | |
| default: | |
| minutes: 15 | |
| selector: | |
| duration: | |
| enable_day: true | |
| # ======================================== | |
| # DOOR SCHEDULE 3 SECTION | |
| # ======================================== | |
| door_schedule3_section: | |
| name: "Door Schedule 3" | |
| description: "Schedule to automatically open or close the door. For 24-hour coverage, set both start and end times to 00:00:00." | |
| icon: mdi:calendar-clock | |
| collapsed: true | |
| input: | |
| schedule3_enabled: | |
| name: π Enable Door Schedule 3 | |
| default: false | |
| selector: | |
| boolean: {} | |
| schedule3_action: | |
| name: βοΈ Schedule Action | |
| description: Whether to open or close the door during this schedule | |
| default: close | |
| selector: | |
| select: | |
| options: | |
| - label: Close Door | |
| value: close | |
| - label: Open Door | |
| value: open | |
| schedule3_days: | |
| name: π Active Days | |
| default: | |
| - mon | |
| - tue | |
| - wed | |
| - thu | |
| - fri | |
| - sat | |
| - sun | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: Monday | |
| value: mon | |
| - label: Tuesday | |
| value: tue | |
| - label: Wednesday | |
| value: wed | |
| - label: Thursday | |
| value: thu | |
| - label: Friday | |
| value: fri | |
| - label: Saturday | |
| value: sat | |
| - label: Sunday | |
| value: sun | |
| schedule3_start_time: | |
| name: π’ Start Time | |
| description: For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "00:00:00" | |
| selector: | |
| time: {} | |
| schedule3_end_time: | |
| name: π΄ End Time | |
| description: For 24-hour coverage, set both start and end times to 00:00:00. | |
| default: "00:00:00" | |
| selector: | |
| time: {} | |
| schedule3_delay: | |
| name: β±οΈ Action Delay | |
| description: How long after door opens before closing (for close action) or how long after schedule starts before opening (for open action) | |
| default: | |
| minutes: 5 | |
| selector: | |
| duration: | |
| enable_day: true | |
| # ======================================== | |
| # DEBUG SECTION | |
| # ======================================== | |
| debug_section: | |
| name: "Debug Settings" | |
| description: "Enable debug notifications for troubleshooting" | |
| icon: mdi:bug | |
| collapsed: true | |
| input: | |
| debug_enabled: | |
| name: π Enable Debug Notifications | |
| description: Send persistent notifications for debugging automation triggers and actions | |
| default: false | |
| selector: | |
| boolean: {} | |
| debug_notification_id: | |
| name: π§ Debug Notification ID | |
| description: Unique ID for debug notifications (for clearing/updating) | |
| default: "smart_garage_debug" | |
| selector: | |
| text: {} | |
| debug_include_variables: | |
| name: π Include Variables in Debug | |
| description: Show variable values in debug notifications | |
| default: false | |
| selector: | |
| boolean: {} | |
| debug_trigger_types: | |
| name: β‘ Debug Trigger Types | |
| description: Select which trigger types to debug | |
| default: | |
| - door_states | |
| - lighting | |
| - schedules | |
| - alerts | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: Door State Changes | |
| value: door_states | |
| - label: Lighting Triggers | |
| value: lighting | |
| - label: Schedule Checks | |
| value: schedules | |
| - label: Alert Checks | |
| value: alerts | |
| - label: All Triggers | |
| value: all | |
| mode: restart | |
| max_exceeded: silent | |
| trigger_variables: | |
| garage_door_entity: !input garage_door_entity | |
| trigger: | |
| - platform: state | |
| entity_id: !input garage_door_entity | |
| to: "open" | |
| for: !input open_duration_before_alert | |
| id: trigger_open | |
| - platform: state | |
| entity_id: !input garage_door_entity | |
| to: "opening" | |
| for: !input opening_duration_before_alert | |
| id: trigger_opening | |
| - platform: state | |
| entity_id: !input garage_door_entity | |
| to: "closed" | |
| for: !input closed_duration_before_alert | |
| id: trigger_closed | |
| - platform: state | |
| entity_id: !input garage_door_entity | |
| to: "closing" | |
| for: !input closing_duration_before_alert | |
| id: trigger_closing | |
| - platform: template | |
| value_template: > | |
| {% set door = garage_door_entity %} | |
| {% set door_state = states(door) %} | |
| {# Check if door is unavailable/unknown #} | |
| {% if door_state in ['unavailable', 'unknown', 'none'] %} | |
| false | |
| {% else %} | |
| {% set position = state_attr(door, 'current_position') %} | |
| {# Handle None, string, or missing position attribute #} | |
| {% if position is none or position is string %} | |
| false | |
| {% else %} | |
| {% set pos_num = position | float(0) %} | |
| {{ door_state not in ['opening', 'closing'] and | |
| pos_num > 0 and pos_num < 100 }} | |
| {% endif %} | |
| {% endif %} | |
| for: !input stopped_duration_before_alert | |
| id: trigger_stopped | |
| - platform: state | |
| entity_id: !input garage_door_entity | |
| to: "open" | |
| for: !input autoclose_default_delay | |
| id: trigger_autoclose | |
| - platform: state | |
| entity_id: !input lighting_trigger_entity | |
| id: trigger_lighting_entities | |
| - platform: state | |
| entity_id: !input lighting_entities | |
| to: "on" | |
| id: trigger_lighting_entities | |
| - platform: state | |
| entity_id: !input outdoor_lighting_trigger_entity | |
| id: trigger_outdoor_lighting_entities | |
| - platform: state | |
| entity_id: !input outdoor_lighting_entities | |
| to: "on" | |
| id: trigger_outdoor_lighting_entities | |
| - platform: time_pattern | |
| hours: "/1" | |
| minutes: "0" | |
| seconds: "0" | |
| id: check_door_schedules | |
| variables: | |
| # GARAGE DOOR ENTITY (STANDALONE) | |
| garage_door_entity: !input garage_door_entity | |
| # TIMESTAMP VARIABLE - generated once at automation start | |
| current_timestamp: "{{ now().strftime('%I:%M:%S %p') }}" | |
| # DEBUG VARIABLES with defaults | |
| debug_enabled: !input debug_enabled | |
| debug_notification_id: !input debug_notification_id | |
| debug_include_variables: !input debug_include_variables | |
| debug_trigger_types: !input debug_trigger_types | |
| automation_friendly_name: > | |
| {{ this.attributes.friendly_name | trim | default('Smart Garage', true) }} | |
| # ALERT NOTIFICATION VARIABLES with defaults | |
| alert_enable_notification: !input alert_enable_notification | |
| alert_enable_schedule: !input alert_enable_schedule | |
| alert_days: !input alert_days | |
| alert_start_time: !input alert_start_time | |
| alert_end_time: !input alert_end_time | |
| alert_enable_entity: !input alert_enable_entity | |
| alert_entity: !input alert_entity | |
| alert_entity_states: !input alert_entity_states | |
| alert_notify_devices: !input alert_notify_devices | |
| alert_notification_title: !input alert_notification_title | |
| alert_notification_message: !input alert_notification_message | |
| alert_notification_click_url: !input alert_notification_click_url | |
| alert_notification_icon: !input alert_notification_icon | |
| alert_notification_color: !input alert_notification_color | |
| alert_notification_persistent: !input alert_notification_persistent | |
| alert_notification_interruption: !input alert_notification_interruption | |
| alert_custom_action: !input alert_custom_action | |
| # OPEN TRIGGER VARIABLES with defaults | |
| enable_open_notification: !input open_enable_notification | |
| open_duration_before_alert: !input open_duration_before_alert | |
| open_friendly_name: !input open_friendly_name | |
| open_notify_devices: !input open_notify_devices | |
| open_notification_title: !input open_notification_title | |
| open_notification_message: !input open_notification_message | |
| open_notification_click_url: !input open_notification_click_url | |
| open_repeat_notification: !input open_repeat_notification | |
| open_max_repeat_count: !input open_max_repeat_count | |
| open_time_between_repeats: !input open_time_between_repeats | |
| open_bypass_entities: !input open_bypass_entities | |
| open_bypass_schedule_enabled: !input open_bypass_schedule_enabled | |
| open_bypass_days: !input open_bypass_days | |
| open_bypass_start_time: !input open_bypass_start_time | |
| open_bypass_end_time: !input open_bypass_end_time | |
| open_notification_icon: !input open_notification_icon | |
| open_notification_color: !input open_notification_color | |
| open_notification_persistent: !input open_notification_persistent | |
| open_notification_interruption: !input open_notification_interruption | |
| open_custom_action: !input open_custom_action | |
| # OPENING TRIGGER VARIABLES with defaults | |
| enable_opening_notification: !input opening_enable_notification | |
| opening_duration_before_alert: !input opening_duration_before_alert | |
| opening_friendly_name: !input opening_friendly_name | |
| opening_notify_devices: !input opening_notify_devices | |
| opening_notification_title: !input opening_notification_title | |
| opening_notification_message: !input opening_notification_message | |
| opening_notification_click_url: !input opening_notification_click_url | |
| opening_repeat_notification: !input opening_repeat_notification | |
| opening_max_repeat_count: !input opening_max_repeat_count | |
| opening_time_between_repeats: !input opening_time_between_repeats | |
| opening_bypass_entities: !input opening_bypass_entities | |
| opening_notification_icon: !input opening_notification_icon | |
| opening_notification_color: !input opening_notification_color | |
| opening_notification_persistent: !input opening_notification_persistent | |
| opening_notification_interruption: !input opening_notification_interruption | |
| opening_custom_action: !input opening_custom_action | |
| # CLOSED TRIGGER VARIABLES with defaults | |
| enable_closed_notification: !input closed_enable_notification | |
| closed_duration_before_alert: !input closed_duration_before_alert | |
| closed_friendly_name: !input closed_friendly_name | |
| closed_notify_devices: !input closed_notify_devices | |
| closed_notification_title: !input closed_notification_title | |
| closed_notification_message: !input closed_notification_message | |
| closed_notification_click_url: !input closed_notification_click_url | |
| closed_repeat_notification: !input closed_repeat_notification | |
| closed_max_repeat_count: !input closed_max_repeat_count | |
| closed_time_between_repeats: !input closed_time_between_repeats | |
| closed_bypass_entities: !input closed_bypass_entities | |
| closed_notification_icon: !input closed_notification_icon | |
| closed_notification_color: !input closed_notification_color | |
| closed_notification_persistent: !input closed_notification_persistent | |
| closed_notification_interruption: !input closed_notification_interruption | |
| closed_custom_action: !input closed_custom_action | |
| # CLOSING TRIGGER VARIABLES with defaults | |
| enable_closing_notification: !input closing_enable_notification | |
| closing_duration_before_alert: !input closing_duration_before_alert | |
| closing_friendly_name: !input closing_friendly_name | |
| closing_notify_devices: !input closing_notify_devices | |
| closing_notification_title: !input closing_notification_title | |
| closing_notification_message: !input closing_notification_message | |
| closing_notification_click_url: !input closing_notification_click_url | |
| closing_repeat_notification: !input closing_repeat_notification | |
| closing_max_repeat_count: !input closing_max_repeat_count | |
| closing_time_between_repeats: !input closing_time_between_repeats | |
| closing_bypass_entities: !input closing_bypass_entities | |
| closing_notification_icon: !input closing_notification_icon | |
| closing_notification_color: !input closing_notification_color | |
| closing_notification_persistent: !input closing_notification_persistent | |
| closing_notification_interruption: !input closing_notification_interruption | |
| closing_custom_action: !input closing_custom_action | |
| # STOPPED TRIGGER VARIABLES with defaults | |
| enable_stopped_notification: !input stopped_enable_notification | |
| stopped_duration_before_alert: !input stopped_duration_before_alert | |
| stopped_friendly_name: !input stopped_friendly_name | |
| stopped_notify_devices: !input stopped_notify_devices | |
| stopped_notification_title: !input stopped_notification_title | |
| stopped_notification_message: !input stopped_notification_message | |
| stopped_notification_click_url: !input stopped_notification_click_url | |
| stopped_repeat_notification: !input stopped_repeat_notification | |
| stopped_max_repeat_count: !input stopped_max_repeat_count | |
| stopped_time_between_repeats: !input stopped_time_between_repeats | |
| stopped_bypass_entities: !input stopped_bypass_entities | |
| stopped_notification_icon: !input stopped_notification_icon | |
| stopped_notification_color: !input stopped_notification_color | |
| stopped_notification_persistent: !input stopped_notification_persistent | |
| stopped_notification_interruption: !input stopped_notification_interruption | |
| stopped_custom_action: !input stopped_custom_action | |
| # LIGHTING VARIABLES with defaults | |
| enable_lighting_control: !input lighting_enable_control | |
| light_entities: !input lighting_entities | |
| lighting_trigger_entity: !input lighting_trigger_entity | |
| lighting_triggers: !input lighting_triggers | |
| lighting_turn_off_on_close: !input lighting_turn_off_on_close | |
| lighting_turn_off_on_close_delay: !input lighting_turn_off_on_close_delay | |
| light_off_timer: !input lighting_off_timer | |
| lighting_manual_control_timer: !input lighting_manual_control_timer | |
| lighting_bypass_timer_enabled: !input lighting_bypass_timer_enabled | |
| lighting_bypass_timer_entity: !input lighting_bypass_timer_entity | |
| light_brightness: !input lighting_brightness | |
| light_color_temp: !input lighting_color_temp | |
| lighting_schedule_enabled: !input lighting_schedule_enabled | |
| lighting_schedule_days: !input lighting_schedule_days | |
| lighting_schedule_start_time: !input lighting_schedule_start_time | |
| lighting_schedule_end_time: !input lighting_schedule_end_time | |
| lighting_custom_action: !input lighting_custom_action | |
| # OUTDOOR LIGHTING VARIABLES with defaults | |
| enable_outdoor_lighting_control: !input outdoor_lighting_enable_control | |
| outdoor_light_entities: !input outdoor_lighting_entities | |
| outdoor_lighting_trigger_entity: !input outdoor_lighting_trigger_entity | |
| outdoor_lighting_triggers: !input outdoor_lighting_triggers | |
| outdoor_lighting_turn_off_on_close: !input outdoor_lighting_turn_off_on_close | |
| outdoor_lighting_turn_off_on_close_delay: !input outdoor_lighting_turn_off_on_close_delay | |
| outdoor_light_off_timer: !input outdoor_lighting_off_timer | |
| outdoor_lighting_manual_control_timer: !input outdoor_lighting_manual_control_timer | |
| outdoor_lighting_bypass_timer_enabled: !input outdoor_lighting_bypass_timer_enabled | |
| outdoor_lighting_bypass_timer_entity: !input outdoor_lighting_bypass_timer_entity | |
| outdoor_light_brightness: !input outdoor_lighting_brightness | |
| outdoor_light_color_temp: !input outdoor_lighting_color_temp | |
| outdoor_lighting_schedule_enabled: !input outdoor_lighting_schedule_enabled | |
| outdoor_lighting_schedule_days: !input outdoor_lighting_schedule_days | |
| outdoor_lighting_schedule_start_time: !input outdoor_lighting_schedule_start_time | |
| outdoor_lighting_schedule_end_time: !input outdoor_lighting_schedule_end_time | |
| outdoor_lighting_custom_action: !input outdoor_lighting_custom_action | |
| # AUTO-CLOSE DEFAULT VARIABLES with defaults | |
| autoclose_default_enabled: !input autoclose_default_enabled | |
| autoclose_default_delay: !input autoclose_default_delay | |
| autoclose_bypass_entity: !input autoclose_bypass_entity | |
| # DOOR SCHEDULE VARIABLES with defaults | |
| schedule1_enabled: !input schedule1_enabled | |
| schedule1_action: !input schedule1_action | |
| schedule1_days: !input schedule1_days | |
| schedule1_start_time: !input schedule1_start_time | |
| schedule1_end_time: !input schedule1_end_time | |
| schedule1_delay: !input schedule1_delay | |
| schedule2_enabled: !input schedule2_enabled | |
| schedule2_action: !input schedule2_action | |
| schedule2_days: !input schedule2_days | |
| schedule2_start_time: !input schedule2_start_time | |
| schedule2_end_time: !input schedule2_end_time | |
| schedule2_delay: !input schedule2_delay | |
| schedule3_enabled: !input schedule3_enabled | |
| schedule3_action: !input schedule3_action | |
| schedule3_days: !input schedule3_days | |
| schedule3_start_time: !input schedule3_start_time | |
| schedule3_end_time: !input schedule3_end_time | |
| schedule3_delay: !input schedule3_delay | |
| action: | |
| # Clear previous debug notification at start with safe check | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled and debug_notification_id is defined }}" | |
| then: | |
| - service: persistent_notification.dismiss | |
| data: | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Start of main choose block | |
| - choose: | |
| # Handle OPEN trigger | |
| - conditions: | |
| - condition: trigger | |
| id: trigger_open | |
| sequence: | |
| # Capture trigger time at the beginning of the sequence | |
| - variables: | |
| trigger_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| # Debug notification with safe checks | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - OPEN Triggered" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Start: {{ action_time }} | |
| πͺ Door Entity: {{ garage_door_entity }} | |
| π Door State: {{ states(garage_door_entity) if states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| {% if debug_include_variables %} | |
| π Variables: | |
| - enable_open_notification: {{ enable_open_notification }} | |
| - open_friendly_name: {{ open_friendly_name }} | |
| - open_duration_before_alert: {{ open_duration_before_alert }} | |
| - open_notify_devices count: {{ open_notify_devices | length }} | |
| {% endif %} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Set variables for this trigger | |
| - variables: | |
| friendly_name: "{{ open_friendly_name }}" | |
| notification_tag: "garage-open-{{ garage_door_entity }}" | |
| current_day: "{{ now().strftime('%a').lower() }}" | |
| current_time: "{{ now().strftime('%H:%M:%S') }}" | |
| # Check if open notifications are enabled and conditions met | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_open_notification }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| - condition: template | |
| value_template: > | |
| {% set open_bypass_entities = open_bypass_entities if open_bypass_entities is defined else [] %} | |
| {% if open_bypass_entities | length > 0 %} | |
| {{ not (open_bypass_entities | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0) }} | |
| {% else %} | |
| true | |
| {% endif %} | |
| - condition: template | |
| value_template: > | |
| {% if open_bypass_schedule_enabled %} | |
| {% set open_bypass_days = open_bypass_days if open_bypass_days is defined else [] %} | |
| {% set day_match = current_day in open_bypass_days %} | |
| {% if day_match %} | |
| {% if open_bypass_start_time <= open_bypass_end_time %} | |
| {{ not (current_time >= open_bypass_start_time and current_time <= open_bypass_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= open_bypass_start_time or current_time <= open_bypass_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for sending open notifications | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Sending OPEN Notifications" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Notification Time: {{ action_time }} | |
| πͺ Door: {{ friendly_name }} | |
| π± Devices: {{ open_notify_devices | length }} device(s) | |
| π¬ Title: {{ open_notification_title }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # OPEN - Send notifications to all selected devices | |
| - repeat: | |
| for_each: "{{ open_notify_devices if open_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ open_notification_message }}" | |
| title: "{{ open_notification_title }}" | |
| data: | |
| clickAction: "{{ open_notification_click_url }}" | |
| url: "{{ open_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ open_notification_color }}" | |
| notification_icon: "mdi:{{ open_notification_icon }}" | |
| push: | |
| interruption-level: "{{ open_notification_interruption }}" | |
| persistent: "{{ open_notification_persistent }}" | |
| sticky: "{{ open_notification_persistent }}" | |
| # Execute custom action | |
| - if: | |
| - condition: template | |
| value_template: "{{ open_custom_action is defined and open_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input open_custom_action | |
| # Handle repeat notifications if enabled | |
| - if: | |
| - condition: template | |
| value_template: "{{ open_repeat_notification }}" | |
| then: | |
| - variables: | |
| repeat_counter: 0 | |
| - repeat: | |
| while: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| - condition: template | |
| value_template: "{{ open_max_repeat_count == 0 or repeat_counter < open_max_repeat_count }}" | |
| sequence: | |
| - delay: "{{ open_time_between_repeats }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| - condition: template | |
| value_template: "{{ open_max_repeat_count == 0 or repeat_counter < open_max_repeat_count }}" | |
| then: | |
| - repeat: | |
| for_each: "{{ open_notify_devices if open_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ open_notification_message }}" | |
| title: "{{ open_notification_title }}" | |
| data: | |
| clickAction: "{{ open_notification_click_url }}" | |
| url: "{{ open_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ open_notification_color }}" | |
| notification_icon: "mdi:{{ open_notification_icon }}" | |
| push: | |
| interruption-level: "{{ open_notification_interruption }}" | |
| persistent: "{{ open_notification_persistent }}" | |
| sticky: "{{ open_notification_persistent }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ open_custom_action is defined and open_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input open_custom_action | |
| - variables: | |
| repeat_counter: "{{ repeat_counter + 1 }}" | |
| # Handle alert notification for OPEN based on conditions | |
| - if: | |
| - condition: template | |
| value_template: "{{ alert_enable_notification }}" | |
| - condition: or | |
| conditions: | |
| # Schedule condition | |
| - condition: and | |
| conditions: | |
| - condition: template | |
| value_template: "{{ alert_enable_schedule }}" | |
| - condition: template | |
| value_template: > | |
| {% set alert_days = alert_days if alert_days is defined else [] %} | |
| {{ current_day in alert_days }} | |
| - condition: template | |
| value_template: > | |
| {% if alert_start_time <= alert_end_time %} | |
| {{ current_time >= alert_start_time and current_time <= alert_end_time }} | |
| {% else %} | |
| {{ current_time >= alert_start_time or current_time <= alert_end_time }} | |
| {% endif %} | |
| # Entity condition | |
| - condition: and | |
| conditions: | |
| - condition: template | |
| value_template: "{{ alert_enable_entity }}" | |
| - condition: template | |
| value_template: "{{ alert_entity != '' }}" | |
| - condition: template | |
| value_template: > | |
| {% if alert_enable_entity and alert_entity != '' and alert_entity_states != '' %} | |
| {% set states_list = alert_entity_states.split(',') | map('trim') | list %} | |
| {% if states(alert_entity) not in ['unavailable', 'unknown', 'none'] %} | |
| {{ states(alert_entity) in states_list }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| {% else %} | |
| false | |
| {% endif %} | |
| then: | |
| # Debug notification for alert | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'alerts' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Sending ALERT Notifications" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Alert Time: {{ action_time }} | |
| πͺ Door: {{ friendly_name }} | |
| π Schedule Match: {{ alert_enable_schedule and current_day in alert_days and ((alert_start_time <= alert_end_time and current_time >= alert_start_time and current_time <= alert_end_time) or (alert_start_time > alert_end_time and (current_time >= alert_start_time or current_time <= alert_end_time))) }} | |
| βοΈ Entity Match: {{ alert_enable_entity and alert_entity != '' and (states(alert_entity) in alert_entity_states.split(',')) if states(alert_entity) not in ['unavailable', 'unknown', 'none'] else false }} | |
| π± Alert Devices: {{ alert_notify_devices | length }} device(s) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # ALERT - Send alert notifications to all selected devices | |
| - repeat: | |
| for_each: "{{ alert_notify_devices if alert_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ alert_notification_message }}" | |
| title: "{{ alert_notification_title }}" | |
| data: | |
| clickAction: "{{ alert_notification_click_url }}" | |
| url: "{{ alert_notification_click_url }}" | |
| tag: "garage-alert-{{ garage_door_entity }}" | |
| color: "{{ alert_notification_color }}" | |
| notification_icon: "mdi:{{ alert_notification_icon }}" | |
| push: | |
| interruption-level: "{{ alert_notification_interruption }}" | |
| persistent: "{{ alert_notification_persistent }}" | |
| sticky: "{{ alert_notification_persistent }}" | |
| # Execute alert custom action | |
| - if: | |
| - condition: template | |
| value_template: "{{ alert_custom_action is defined and alert_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input alert_custom_action | |
| # Handle lighting control for OPEN state (INDOOR) | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ 'open' in lighting_triggers }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_schedule_enabled %} | |
| {% set lighting_schedule_days = lighting_schedule_days if lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if lighting_schedule_start_time <= lighting_schedule_end_time %} | |
| {{ not (current_time >= lighting_schedule_start_time and current_time <= lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= lighting_schedule_start_time or current_time <= lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for lighting control | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'lighting' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - OPEN Lighting Control" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| π Brightness: {{ light_brightness }}% | |
| π¨ Color Temp: {{ light_color_temp }}K | |
| β±οΈ Off Timer: {{ light_off_timer }} | |
| π Schedule Enabled: {{ lighting_schedule_enabled }} | |
| π Schedule Active: {{ not (lighting_schedule_enabled and current_day in lighting_schedule_days and ((lighting_schedule_start_time <= lighting_schedule_end_time and current_time >= lighting_schedule_start_time and current_time <= lighting_schedule_end_time) or (lighting_schedule_start_time > lighting_schedule_end_time and (current_time >= lighting_schedule_start_time or current_time <= lighting_schedule_end_time)))) }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Turn lights on with specified settings | |
| - if: | |
| - condition: template | |
| value_template: "{{ light_entities is defined and light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| data: | |
| brightness_pct: "{{ light_brightness }}" | |
| color_temp_kelvin: "{{ light_color_temp }}" | |
| # Execute custom lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ lighting_custom_action is defined and lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input lighting_custom_action | |
| # Light Off Timer - inline so mode:restart resets it on every new trigger | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = light_off_timer if light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_bypass_timer_entity is defined and lighting_bypass_timer_entity %} | |
| {{ lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Light Off Timer BYPASSED (OPEN)" | |
| message: | | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Lights OFF Timer Expired (OPEN)" | |
| message: | | |
| β±οΈ Timer expired with no new trigger - lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle outdoor lighting control for OPEN state | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_outdoor_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ 'open' in outdoor_lighting_triggers }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_schedule_enabled %} | |
| {% set outdoor_lighting_schedule_days = outdoor_lighting_schedule_days if outdoor_lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in outdoor_lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if outdoor_lighting_schedule_start_time <= outdoor_lighting_schedule_end_time %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time and current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time or current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Turn outdoor lights on with specified settings | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_light_entities is defined and outdoor_light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| data: | |
| brightness_pct: "{{ outdoor_light_brightness }}" | |
| color_temp_kelvin: "{{ outdoor_light_color_temp }}" | |
| # Execute custom outdoor lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_custom_action is defined and outdoor_lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input outdoor_lighting_custom_action | |
| # Outdoor Light Off Timer - inline so mode:restart resets it on every new trigger | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = outdoor_light_off_timer if outdoor_light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_bypass_timer_entity is defined and outdoor_lighting_bypass_timer_entity %} | |
| {{ outdoor_lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Light Off Timer BYPASSED (OPEN)" | |
| message: | | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Lights OFF Timer Expired (OPEN)" | |
| message: | | |
| β±οΈ Timer expired with no new trigger - outdoor lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle Auto-Close Default | |
| - if: | |
| - condition: template | |
| value_template: "{{ autoclose_default_enabled }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| then: | |
| # Debug notification for auto-close | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Auto-Close Started" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Start Time: {{ action_time }} | |
| πͺ Door: {{ friendly_name }} | |
| β±οΈ Close Delay: {{ autoclose_default_delay }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| - condition: template | |
| value_template: > | |
| {% set bypass = autoclose_bypass_entity if autoclose_bypass_entity is defined else [] %} | |
| {% if bypass | length > 0 %} | |
| {{ not (bypass | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0) }} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for auto-close action | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Auto-Close Executing" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Close Time: {{ action_time }} | |
| πͺ Door: {{ friendly_name }} | |
| π Door State: {{ states(garage_door_entity) }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - service: cover.close_cover | |
| target: | |
| entity_id: !input garage_door_entity | |
| # Handle OPENING trigger | |
| - conditions: | |
| - condition: trigger | |
| id: trigger_opening | |
| sequence: | |
| # Capture trigger time at the beginning of the sequence | |
| - variables: | |
| trigger_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| # Debug notification | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - OPENING Triggered" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Start: {{ action_time }} | |
| πͺ Door Entity: {{ garage_door_entity }} | |
| π Door State: {{ states(garage_door_entity) if states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| {% if debug_include_variables %} | |
| π Variables: | |
| - enable_opening_notification: {{ enable_opening_notification }} | |
| - opening_friendly_name: {{ opening_friendly_name }} | |
| {% endif %} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - variables: | |
| friendly_name: "{{ opening_friendly_name }}" | |
| notification_tag: "garage-opening-{{ garage_door_entity }}" | |
| current_day: "{{ now().strftime('%a').lower() }}" | |
| current_time: "{{ now().strftime('%H:%M:%S') }}" | |
| # Check if opening notifications are enabled and conditions met | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_opening_notification }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'opening' }}" | |
| - condition: template | |
| value_template: > | |
| {% set opening_bypass_entities = opening_bypass_entities if opening_bypass_entities is defined else [] %} | |
| {% if opening_bypass_entities | length > 0 %} | |
| {{ not (opening_bypass_entities | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0) }} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for sending opening notifications | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Sending OPENING Notifications" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Notification Time: {{ action_time }} | |
| πͺ Door: {{ friendly_name }} | |
| π± Devices: {{ opening_notify_devices | length }} device(s) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # OPENING - Send notifications to all selected devices | |
| - repeat: | |
| for_each: "{{ opening_notify_devices if opening_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ opening_notification_message }}" | |
| title: "{{ opening_notification_title }}" | |
| data: | |
| clickAction: "{{ opening_notification_click_url }}" | |
| url: "{{ opening_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ opening_notification_color }}" | |
| notification_icon: "mdi:{{ opening_notification_icon }}" | |
| push: | |
| interruption-level: "{{ opening_notification_interruption }}" | |
| persistent: "{{ opening_notification_persistent }}" | |
| sticky: "{{ opening_notification_persistent }}" | |
| # Execute custom action | |
| - if: | |
| - condition: template | |
| value_template: "{{ opening_custom_action is defined and opening_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input opening_custom_action | |
| # Handle repeat notifications if enabled | |
| - if: | |
| - condition: template | |
| value_template: "{{ opening_repeat_notification }}" | |
| then: | |
| - variables: | |
| repeat_counter: 0 | |
| - repeat: | |
| while: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'opening' }}" | |
| - condition: template | |
| value_template: "{{ opening_max_repeat_count == 0 or repeat_counter < opening_max_repeat_count }}" | |
| sequence: | |
| - delay: "{{ opening_time_between_repeats }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'opening' }}" | |
| - condition: template | |
| value_template: "{{ opening_max_repeat_count == 0 or repeat_counter < opening_max_repeat_count }}" | |
| then: | |
| - repeat: | |
| for_each: "{{ opening_notify_devices if opening_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ opening_notification_message }}" | |
| title: "{{ opening_notification_title }}" | |
| data: | |
| clickAction: "{{ opening_notification_click_url }}" | |
| url: "{{ opening_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ opening_notification_color }}" | |
| notification_icon: "mdi:{{ opening_notification_icon }}" | |
| push: | |
| interruption-level: "{{ opening_notification_interruption }}" | |
| persistent: "{{ opening_notification_persistent }}" | |
| sticky: "{{ opening_notification_persistent }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ opening_custom_action is defined and opening_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input opening_custom_action | |
| - variables: | |
| repeat_counter: "{{ repeat_counter + 1 }}" | |
| # Handle alert notification for OPENING based on conditions | |
| - if: | |
| - condition: template | |
| value_template: "{{ alert_enable_notification }}" | |
| - condition: or | |
| conditions: | |
| # Schedule condition | |
| - condition: and | |
| conditions: | |
| - condition: template | |
| value_template: "{{ alert_enable_schedule }}" | |
| - condition: template | |
| value_template: > | |
| {% set alert_days = alert_days if alert_days is defined else [] %} | |
| {{ current_day in alert_days }} | |
| - condition: template | |
| value_template: > | |
| {% if alert_start_time <= alert_end_time %} | |
| {{ current_time >= alert_start_time and current_time <= alert_end_time }} | |
| {% else %} | |
| {{ current_time >= alert_start_time or current_time <= alert_end_time }} | |
| {% endif %} | |
| # Entity condition | |
| - condition: and | |
| conditions: | |
| - condition: template | |
| value_template: "{{ alert_enable_entity }}" | |
| - condition: template | |
| value_template: "{{ alert_entity != '' }}" | |
| - condition: template | |
| value_template: > | |
| {% if alert_enable_entity and alert_entity != '' and alert_entity_states != '' %} | |
| {% set states_list = alert_entity_states.split(',') | map('trim') | list %} | |
| {% if states(alert_entity) not in ['unavailable', 'unknown', 'none'] %} | |
| {{ states(alert_entity) in states_list }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| {% else %} | |
| false | |
| {% endif %} | |
| then: | |
| # Debug notification for alert | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'alerts' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Sending ALERT Notifications (Opening)" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Alert Time: {{ action_time }} | |
| πͺ Door: {{ friendly_name }} | |
| π Schedule Match: {{ alert_enable_schedule and current_day in alert_days and ((alert_start_time <= alert_end_time and current_time >= alert_start_time and current_time <= alert_end_time) or (alert_start_time > alert_end_time and (current_time >= alert_start_time or current_time <= alert_end_time))) }} | |
| βοΈ Entity Match: {{ alert_enable_entity and alert_entity != '' and (states(alert_entity) in alert_entity_states.split(',')) if states(alert_entity) not in ['unavailable', 'unknown', 'none'] else false }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Send alert notifications to all selected devices | |
| - repeat: | |
| for_each: "{{ alert_notify_devices if alert_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ alert_notification_message }}" | |
| title: "{{ alert_notification_title }}" | |
| data: | |
| clickAction: "{{ alert_notification_click_url }}" | |
| url: "{{ alert_notification_click_url }}" | |
| tag: "garage-alert-{{ garage_door_entity }}" | |
| color: "{{ alert_notification_color }}" | |
| notification_icon: "mdi:{{ alert_notification_icon }}" | |
| push: | |
| interruption-level: "{{ alert_notification_interruption }}" | |
| persistent: "{{ alert_notification_persistent }}" | |
| sticky: "{{ alert_notification_persistent }}" | |
| # Execute alert custom action | |
| - if: | |
| - condition: template | |
| value_template: "{{ alert_custom_action is defined and alert_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input alert_custom_action | |
| # Handle lighting control for OPENING state | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ 'opening' in lighting_triggers }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_schedule_enabled %} | |
| {% set lighting_schedule_days = lighting_schedule_days if lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if lighting_schedule_start_time <= lighting_schedule_end_time %} | |
| {{ not (current_time >= lighting_schedule_start_time and current_time <= lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= lighting_schedule_start_time or current_time <= lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for lighting control | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'lighting' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - OPENING Lighting Control" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| π Brightness: {{ light_brightness }}% | |
| π¨ Color Temp: {{ light_color_temp }}K | |
| β±οΈ Off Timer: {{ light_off_timer }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ light_entities is defined and light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| data: | |
| brightness_pct: "{{ light_brightness }}" | |
| color_temp_kelvin: "{{ light_color_temp }}" | |
| # Execute custom lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ lighting_custom_action is defined and lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input lighting_custom_action | |
| # Light Off Timer - inline so mode:restart resets it on every new trigger | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = light_off_timer if light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_bypass_timer_entity is defined and lighting_bypass_timer_entity %} | |
| {{ lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Light Off Timer BYPASSED (OPENING)" | |
| message: | | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Lights OFF Timer Expired (OPENING)" | |
| message: | | |
| β±οΈ Timer expired with no new trigger - lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle outdoor lighting control for OPENING state | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_outdoor_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ 'opening' in outdoor_lighting_triggers }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_schedule_enabled %} | |
| {% set outdoor_lighting_schedule_days = outdoor_lighting_schedule_days if outdoor_lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in outdoor_lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if outdoor_lighting_schedule_start_time <= outdoor_lighting_schedule_end_time %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time and current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time or current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_light_entities is defined and outdoor_light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| data: | |
| brightness_pct: "{{ outdoor_light_brightness }}" | |
| color_temp_kelvin: "{{ outdoor_light_color_temp }}" | |
| # Execute custom outdoor lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_custom_action is defined and outdoor_lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input outdoor_lighting_custom_action | |
| # Outdoor Light Off Timer - inline so mode:restart resets it on every new trigger | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = outdoor_light_off_timer if outdoor_light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_bypass_timer_entity is defined and outdoor_lighting_bypass_timer_entity %} | |
| {{ outdoor_lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Light Off Timer BYPASSED (OPENING)" | |
| message: | | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Lights OFF Timer Expired (OPENING)" | |
| message: | | |
| β±οΈ Timer expired with no new trigger - outdoor lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle CLOSED trigger | |
| - conditions: | |
| - condition: trigger | |
| id: trigger_closed | |
| sequence: | |
| # Capture trigger time at the beginning of the sequence | |
| - variables: | |
| trigger_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| # Debug notification | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Garage Door CLOSED Triggered" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Start: {{ action_time }} | |
| πͺ Door Entity: {{ garage_door_entity }} | |
| π Door State: {{ states(garage_door_entity) if states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| {% if debug_include_variables %} | |
| π Variables: | |
| - enable_closed_notification: {{ enable_closed_notification }} | |
| - closed_friendly_name: {{ closed_friendly_name }} | |
| {% endif %} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - variables: | |
| friendly_name: "{{ closed_friendly_name }}" | |
| notification_tag: "garage-closed-{{ garage_door_entity }}" | |
| current_day: "{{ now().strftime('%a').lower() }}" | |
| current_time: "{{ now().strftime('%H:%M:%S') }}" | |
| # Check if closed notifications are enabled and conditions met | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_closed_notification }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closed' }}" | |
| - condition: template | |
| value_template: > | |
| {% set closed_bypass_entities = closed_bypass_entities if closed_bypass_entities is defined else [] %} | |
| {% if closed_bypass_entities | length > 0 %} | |
| {{ not (closed_bypass_entities | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0) }} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for sending closed notifications | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Sending CLOSED Notifications" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Notification Time: {{ action_time }} | |
| πͺ Door: {{ friendly_name }} | |
| π± Devices: {{ closed_notify_devices | length }} device(s) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # CLOSED - Send notifications to all selected devices | |
| - repeat: | |
| for_each: "{{ closed_notify_devices if closed_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ closed_notification_message }}" | |
| title: "{{ closed_notification_title }}" | |
| data: | |
| clickAction: "{{ closed_notification_click_url }}" | |
| url: "{{ closed_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ closed_notification_color }}" | |
| notification_icon: "mdi:{{ closed_notification_icon }}" | |
| push: | |
| interruption-level: "{{ closed_notification_interruption }}" | |
| persistent: "{{ closed_notification_persistent }}" | |
| sticky: "{{ closed_notification_persistent }}" | |
| # Execute custom action | |
| - if: | |
| - condition: template | |
| value_template: "{{ closed_custom_action is defined and closed_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input closed_custom_action | |
| # Handle repeat notifications if enabled | |
| - if: | |
| - condition: template | |
| value_template: "{{ closed_repeat_notification }}" | |
| then: | |
| - variables: | |
| repeat_counter: 0 | |
| - repeat: | |
| while: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closed' }}" | |
| - condition: template | |
| value_template: "{{ closed_max_repeat_count == 0 or repeat_counter < closed_max_repeat_count }}" | |
| sequence: | |
| - delay: "{{ closed_time_between_repeats }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closed' }}" | |
| - condition: template | |
| value_template: "{{ closed_max_repeat_count == 0 or repeat_counter < closed_max_repeat_count }}" | |
| then: | |
| - repeat: | |
| for_each: "{{ closed_notify_devices if closed_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ closed_notification_message }}" | |
| title: "{{ closed_notification_title }}" | |
| data: | |
| clickAction: "{{ closed_notification_click_url }}" | |
| url: "{{ closed_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ closed_notification_color }}" | |
| notification_icon: "mdi:{{ closed_notification_icon }}" | |
| push: | |
| interruption-level: "{{ closed_notification_interruption }}" | |
| persistent: "{{ closed_notification_persistent }}" | |
| sticky: "{{ closed_notification_persistent }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ closed_custom_action is defined and closed_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input closed_custom_action | |
| - variables: | |
| repeat_counter: "{{ repeat_counter + 1 }}" | |
| # Handle lighting control for CLOSED state | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ lighting_turn_off_on_close }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_schedule_enabled %} | |
| {% set lighting_schedule_days = lighting_schedule_days if lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if lighting_schedule_start_time <= lighting_schedule_end_time %} | |
| {{ not (current_time >= lighting_schedule_start_time and current_time <= lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= lighting_schedule_start_time or current_time <= lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for lighting control | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'lighting' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - CLOSED Lighting Control" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| β Action: Turning lights OFF | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Turn lights off (with optional delay) | |
| - if: | |
| - condition: template | |
| value_template: "{{ light_entities is defined and light_entities | length > 0 }}" | |
| then: | |
| - variables: | |
| close_delay_seconds: > | |
| {% set d = lighting_turn_off_on_close_delay if lighting_turn_off_on_close_delay is defined else {} %} | |
| {{ d.hours|default(0) * 3600 + d.minutes|default(0) * 60 + d.seconds|default(0) }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ close_delay_seconds > 0 }}" | |
| then: | |
| - delay: | |
| seconds: "{{ close_delay_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| # Execute custom lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ lighting_custom_action is defined and lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input lighting_custom_action | |
| # Handle outdoor lighting control for CLOSED state | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_outdoor_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_turn_off_on_close }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_schedule_enabled %} | |
| {% set outdoor_lighting_schedule_days = outdoor_lighting_schedule_days if outdoor_lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in outdoor_lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if outdoor_lighting_schedule_start_time <= outdoor_lighting_schedule_end_time %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time and current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time or current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Turn outdoor lights off (with optional delay) | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_light_entities is defined and outdoor_light_entities | length > 0 }}" | |
| then: | |
| - variables: | |
| outdoor_close_delay_seconds: > | |
| {% set d = outdoor_lighting_turn_off_on_close_delay if outdoor_lighting_turn_off_on_close_delay is defined else {} %} | |
| {{ d.hours|default(0) * 3600 + d.minutes|default(0) * 60 + d.seconds|default(0) }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_close_delay_seconds > 0 }}" | |
| then: | |
| - delay: | |
| seconds: "{{ outdoor_close_delay_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| # Execute custom outdoor lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_custom_action is defined and outdoor_lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input outdoor_lighting_custom_action | |
| # Handle CLOSING trigger | |
| - conditions: | |
| - condition: trigger | |
| id: trigger_closing | |
| sequence: | |
| # Capture trigger time at the beginning of the sequence | |
| - variables: | |
| trigger_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| # Debug notification | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - CLOSING Triggered" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Start: {{ action_time }} | |
| πͺ Door Entity: {{ garage_door_entity }} | |
| π Door State: {{ states(garage_door_entity) if states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| {% if debug_include_variables %} | |
| π Variables: | |
| - enable_closing_notification: {{ enable_closing_notification }} | |
| - closing_friendly_name: {{ closing_friendly_name }} | |
| {% endif %} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - variables: | |
| friendly_name: "{{ closing_friendly_name }}" | |
| notification_tag: "garage-closing-{{ garage_door_entity }}" | |
| current_day: "{{ now().strftime('%a').lower() }}" | |
| current_time: "{{ now().strftime('%H:%M:%S') }}" | |
| # Check if closing notifications are enabled and conditions met | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_closing_notification }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closing' }}" | |
| - condition: template | |
| value_template: > | |
| {% set closing_bypass_entities = closing_bypass_entities if closing_bypass_entities is defined else [] %} | |
| {% if closing_bypass_entities | length > 0 %} | |
| {{ not (closing_bypass_entities | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0) }} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for sending closing notifications | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Sending CLOSING Notifications" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Notification Time: {{ action_time }} | |
| πͺ Door: {{ friendly_name }} | |
| π± Devices: {{ closing_notify_devices | length }} device(s) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # CLOSING - Send notifications to all selected devices | |
| - repeat: | |
| for_each: "{{ closing_notify_devices if closing_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ closing_notification_message }}" | |
| title: "{{ closing_notification_title }}" | |
| data: | |
| clickAction: "{{ closing_notification_click_url }}" | |
| url: "{{ closing_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ closing_notification_color }}" | |
| notification_icon: "mdi:{{ closing_notification_icon }}" | |
| push: | |
| interruption-level: "{{ closing_notification_interruption }}" | |
| persistent: "{{ closing_notification_persistent }}" | |
| sticky: "{{ closing_notification_persistent }}" | |
| # Execute custom action | |
| - if: | |
| - condition: template | |
| value_template: "{{ closing_custom_action is defined and closing_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input closing_custom_action | |
| # Handle repeat notifications if enabled | |
| - if: | |
| - condition: template | |
| value_template: "{{ closing_repeat_notification }}" | |
| then: | |
| - variables: | |
| repeat_counter: 0 | |
| - repeat: | |
| while: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closing' }}" | |
| - condition: template | |
| value_template: "{{ closing_max_repeat_count == 0 or repeat_counter < closing_max_repeat_count }}" | |
| sequence: | |
| - delay: "{{ closing_time_between_repeats }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closing' }}" | |
| - condition: template | |
| value_template: "{{ closing_max_repeat_count == 0 or repeat_counter < closing_max_repeat_count }}" | |
| then: | |
| - repeat: | |
| for_each: "{{ closing_notify_devices if closing_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ closing_notification_message }}" | |
| title: "{{ closing_notification_title }}" | |
| data: | |
| clickAction: "{{ closing_notification_click_url }}" | |
| url: "{{ closing_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ closing_notification_color }}" | |
| notification_icon: "mdi:{{ closing_notification_icon }}" | |
| push: | |
| interruption-level: "{{ closing_notification_interruption }}" | |
| persistent: "{{ closing_notification_persistent }}" | |
| sticky: "{{ closing_notification_persistent }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ closing_custom_action is defined and closing_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input closing_custom_action | |
| - variables: | |
| repeat_counter: "{{ repeat_counter + 1 }}" | |
| # Handle lighting control for CLOSING state | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ 'closing' in lighting_triggers }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_schedule_enabled %} | |
| {% set lighting_schedule_days = lighting_schedule_days if lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if lighting_schedule_start_time <= lighting_schedule_end_time %} | |
| {{ not (current_time >= lighting_schedule_start_time and current_time <= lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= lighting_schedule_start_time or current_time <= lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for lighting control | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'lighting' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - CLOSING Lighting Control" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| π Brightness: {{ light_brightness }}% | |
| π¨ Color Temp: {{ light_color_temp }}K | |
| β±οΈ Off Timer: {{ light_off_timer }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ light_entities is defined and light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| data: | |
| brightness_pct: "{{ light_brightness }}" | |
| color_temp_kelvin: "{{ light_color_temp }}" | |
| # Execute custom lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ lighting_custom_action is defined and lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input lighting_custom_action | |
| # Light Off Timer - inline so mode:restart resets it on every new trigger | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = light_off_timer if light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_bypass_timer_entity is defined and lighting_bypass_timer_entity %} | |
| {{ lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Light Off Timer BYPASSED (CLOSING)" | |
| message: | | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Lights OFF Timer Expired (CLOSING)" | |
| message: | | |
| β±οΈ Timer expired with no new trigger - lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle outdoor lighting control for CLOSING state | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_outdoor_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ 'closing' in outdoor_lighting_triggers }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_schedule_enabled %} | |
| {% set outdoor_lighting_schedule_days = outdoor_lighting_schedule_days if outdoor_lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in outdoor_lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if outdoor_lighting_schedule_start_time <= outdoor_lighting_schedule_end_time %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time and current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time or current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_light_entities is defined and outdoor_light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| data: | |
| brightness_pct: "{{ outdoor_light_brightness }}" | |
| color_temp_kelvin: "{{ outdoor_light_color_temp }}" | |
| # Execute custom outdoor lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_custom_action is defined and outdoor_lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input outdoor_lighting_custom_action | |
| # Outdoor Light Off Timer - inline so mode:restart resets it on every new trigger | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = outdoor_light_off_timer if outdoor_light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_bypass_timer_entity is defined and outdoor_lighting_bypass_timer_entity %} | |
| {{ outdoor_lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Light Off Timer BYPASSED (CLOSING)" | |
| message: | | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Lights OFF Timer Expired (CLOSING)" | |
| message: | | |
| β±οΈ Timer expired with no new trigger - outdoor lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle STOPPED trigger | |
| - conditions: | |
| - condition: trigger | |
| id: trigger_stopped | |
| sequence: | |
| # Capture trigger time at the beginning of the sequence | |
| - variables: | |
| trigger_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| # Debug notification | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Garage Door STOPPED Triggered" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Start: {{ action_time }} | |
| πͺ Door Entity: {{ garage_door_entity }} | |
| π Door State: {{ states(garage_door_entity) if states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| π Position: {{ state_attr(garage_door_entity, 'current_position') | default('N/A') }} | |
| {% if debug_include_variables %} | |
| π Variables: | |
| - enable_stopped_notification: {{ enable_stopped_notification }} | |
| - stopped_friendly_name: {{ stopped_friendly_name }} | |
| - stopped_duration_before_alert: {{ stopped_duration_before_alert }} | |
| {% endif %} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - variables: | |
| friendly_name: "{{ stopped_friendly_name }}" | |
| notification_tag: "garage-stopped-{{ garage_door_entity }}" | |
| current_day: "{{ now().strftime('%a').lower() }}" | |
| current_time: "{{ now().strftime('%H:%M:%S') }}" | |
| # Check if stopped notifications are enabled and conditions met | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_stopped_notification }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) not in ['open', 'opening', 'closed', 'closing'] }}" | |
| - condition: template | |
| value_template: > | |
| {% set stopped_bypass_entities = stopped_bypass_entities if stopped_bypass_entities is defined else [] %} | |
| {% if stopped_bypass_entities | length > 0 %} | |
| {{ not (stopped_bypass_entities | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0) }} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for sending stopped notifications | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'door_states' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Sending STOPPED Notifications" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Notification Time: {{ action_time }} | |
| πͺ Door: {{ friendly_name }} | |
| π± Devices: {{ stopped_notify_devices | length }} device(s) | |
| π Repeat Enabled: {{ stopped_repeat_notification }} | |
| π’ Max Repeats: {{ stopped_max_repeat_count }} | |
| β³ Time Between: {{ stopped_time_between_repeats }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # STOPPED - Send notifications to all selected devices | |
| - repeat: | |
| for_each: "{{ stopped_notify_devices if stopped_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ stopped_notification_message }}" | |
| title: "{{ stopped_notification_title }}" | |
| data: | |
| clickAction: "{{ stopped_notification_click_url }}" | |
| url: "{{ stopped_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ stopped_notification_color }}" | |
| notification_icon: "mdi:{{ stopped_notification_icon }}" | |
| push: | |
| interruption-level: "{{ stopped_notification_interruption }}" | |
| persistent: "{{ stopped_notification_persistent }}" | |
| sticky: "{{ stopped_notification_persistent }}" | |
| # Execute custom action | |
| - if: | |
| - condition: template | |
| value_template: "{{ stopped_custom_action is defined and stopped_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input stopped_custom_action | |
| # Handle repeat notifications if enabled | |
| - if: | |
| - condition: template | |
| value_template: "{{ stopped_repeat_notification }}" | |
| then: | |
| - variables: | |
| repeat_counter: 0 | |
| - repeat: | |
| while: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) not in ['open', 'opening', 'closed', 'closing'] }}" | |
| - condition: template | |
| value_template: "{{ stopped_max_repeat_count == 0 or repeat_counter < stopped_max_repeat_count }}" | |
| sequence: | |
| - delay: "{{ stopped_time_between_repeats }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) not in ['open', 'opening', 'closed', 'closing'] }}" | |
| - condition: template | |
| value_template: "{{ stopped_max_repeat_count == 0 or repeat_counter < stopped_max_repeat_count }}" | |
| then: | |
| - repeat: | |
| for_each: "{{ stopped_notify_devices if stopped_notify_devices is defined else [] }}" | |
| sequence: | |
| - service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
| data: | |
| message: "{{ stopped_notification_message }}" | |
| title: "{{ stopped_notification_title }}" | |
| data: | |
| clickAction: "{{ stopped_notification_click_url }}" | |
| url: "{{ stopped_notification_click_url }}" | |
| tag: "{{ notification_tag }}" | |
| color: "{{ stopped_notification_color }}" | |
| notification_icon: "mdi:{{ stopped_notification_icon }}" | |
| push: | |
| interruption-level: "{{ stopped_notification_interruption }}" | |
| persistent: "{{ stopped_notification_persistent }}" | |
| sticky: "{{ stopped_notification_persistent }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ stopped_custom_action is defined and stopped_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input stopped_custom_action | |
| - variables: | |
| repeat_counter: "{{ repeat_counter + 1 }}" | |
| # Handle lighting control for STOPPED state | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ 'stopped' in lighting_triggers }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_schedule_enabled %} | |
| {% set lighting_schedule_days = lighting_schedule_days if lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if lighting_schedule_start_time <= lighting_schedule_end_time %} | |
| {{ not (current_time >= lighting_schedule_start_time and current_time <= lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= lighting_schedule_start_time or current_time <= lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| # Debug notification for lighting control | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'lighting' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - STOPPED Lighting Control" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| π Brightness: {{ light_brightness }}% | |
| π¨ Color Temp: {{ light_color_temp }}K | |
| β±οΈ Off Timer: {{ light_off_timer }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ light_entities is defined and light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| data: | |
| brightness_pct: "{{ light_brightness }}" | |
| color_temp_kelvin: "{{ light_color_temp }}" | |
| # Execute custom lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ lighting_custom_action is defined and lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input lighting_custom_action | |
| # Light Off Timer - inline so mode:restart resets it on every new trigger | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = light_off_timer if light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_bypass_timer_entity is defined and lighting_bypass_timer_entity %} | |
| {{ lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Light Off Timer BYPASSED (STOPPED)" | |
| message: | | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Lights OFF Timer Expired (STOPPED)" | |
| message: | | |
| β±οΈ Timer expired with no new trigger - lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle outdoor lighting control for STOPPED state | |
| - if: | |
| - condition: template | |
| value_template: "{{ enable_outdoor_lighting_control }}" | |
| - condition: template | |
| value_template: "{{ 'stopped' in outdoor_lighting_triggers }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_schedule_enabled %} | |
| {% set outdoor_lighting_schedule_days = outdoor_lighting_schedule_days if outdoor_lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in outdoor_lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if outdoor_lighting_schedule_start_time <= outdoor_lighting_schedule_end_time %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time and current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time or current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| then: | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_light_entities is defined and outdoor_light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| data: | |
| brightness_pct: "{{ outdoor_light_brightness }}" | |
| color_temp_kelvin: "{{ outdoor_light_color_temp }}" | |
| # Execute custom outdoor lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_custom_action is defined and outdoor_lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input outdoor_lighting_custom_action | |
| # Outdoor Light Off Timer - inline so mode:restart resets it on every new trigger | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = outdoor_light_off_timer if outdoor_light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_bypass_timer_entity is defined and outdoor_lighting_bypass_timer_entity %} | |
| {{ outdoor_lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Light Off Timer BYPASSED (STOPPED)" | |
| message: | | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Lights OFF Timer Expired (STOPPED)" | |
| message: | | |
| β±οΈ Timer expired with no new trigger - outdoor lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle AUTO-CLOSE trigger (dedicated trigger for auto-close) | |
| - conditions: | |
| - condition: trigger | |
| id: trigger_autoclose | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ autoclose_default_enabled }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| then: | |
| - service: cover.close_cover | |
| target: | |
| entity_id: !input garage_door_entity | |
| # Handle LIGHTING trigger entities | |
| - conditions: | |
| - condition: trigger | |
| id: trigger_lighting_entities | |
| sequence: | |
| # Capture trigger time at the beginning of the sequence | |
| - variables: | |
| trigger_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| # Debug notification | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'lighting' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Lighting Entity Triggered" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Start: {{ action_time }} | |
| β‘ Trigger Entity: {{ trigger.entity_id }} | |
| π Trigger State: {{ trigger.to_state.state if trigger.to_state.state not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| {% if debug_include_variables %} | |
| π Variables: | |
| - enable_lighting_control: {{ enable_lighting_control }} | |
| - light_entities count: {{ light_entities | length }} | |
| {% endif %} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Check if the trigger entity changed to an active state | |
| - variables: | |
| trigger_entity: "{{ trigger.entity_id }}" | |
| trigger_state: "{{ trigger.to_state.state }}" | |
| current_day: "{{ now().strftime('%a').lower() }}" | |
| current_time: "{{ now().strftime('%H:%M:%S') }}" | |
| # Shared schedule condition used by both active and inactive branches | |
| - variables: | |
| schedule_allows_lighting: > | |
| {% if lighting_schedule_enabled %} | |
| {% set lighting_schedule_days = lighting_schedule_days if lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if lighting_schedule_start_time <= lighting_schedule_end_time %} | |
| {{ not (current_time >= lighting_schedule_start_time and current_time <= lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= lighting_schedule_start_time or current_time <= lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| # Shared timer logic extracted as a sub-sequence via choose | |
| # Branch A: trigger went ACTIVE (on/open/unlocked) β turn lights ON then start timer | |
| # Branch B: trigger went INACTIVE (off/closed/locked) β skip turn-on, only start timer | |
| - choose: | |
| # ββ Branch A: Active state β turn lights on + start timer ββ | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ enable_lighting_control }}" | |
| - condition: template | |
| value_template: > | |
| {% set active_states = ['on', 'open', 'unlocked'] %} | |
| {{ trigger_state in active_states }} | |
| - condition: template | |
| value_template: "{{ trigger.to_state.context.parent_id is none }}" | |
| - condition: template | |
| value_template: > | |
| {% set is_light_entity = trigger.entity_id in (light_entities if light_entities is iterable else [light_entities]) %} | |
| {{ not is_light_entity or lighting_manual_control_timer }} | |
| - condition: template | |
| value_template: "{{ schedule_allows_lighting }}" | |
| sequence: | |
| # Debug notification for lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'lighting' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Triggering Lights ON" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| β‘ Trigger Entity: {{ trigger_entity }} | |
| π Trigger State: {{ trigger_state }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| π Brightness: {{ light_brightness }}% | |
| π¨ Color Temp: {{ light_color_temp }}K | |
| β±οΈ Off Timer: {{ light_off_timer }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Turn lights on | |
| - if: | |
| - condition: template | |
| value_template: "{{ light_entities is defined and light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| data: | |
| brightness_pct: "{{ light_brightness }}" | |
| color_temp_kelvin: "{{ light_color_temp }}" | |
| # Execute custom lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ lighting_custom_action is defined and lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input lighting_custom_action | |
| # Light Off Timer | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = light_off_timer if light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_bypass_timer_entity is defined and lighting_bypass_timer_entity %} | |
| {{ lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Light Off Timer BYPASSED" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Light Off Timer Started (Active)" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| β±οΈ Timer Duration: {{ light_off_timer }} ({{ timer_seconds }}s) | |
| βΉοΈ mode:restart means any new trigger resets this timer | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Lights Turned OFF (Timer Expired)" | |
| message: | | |
| β‘ Original Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| β±οΈ Timer expired after active trigger - lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # ββ Branch B: Inactive state (e.g. motion cleared) β timer only, no turn-on ββ | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ enable_lighting_control }}" | |
| - condition: template | |
| value_template: > | |
| {% set inactive_states = ['off', 'closed', 'locked'] %} | |
| {{ trigger_state in inactive_states }} | |
| - condition: template | |
| value_template: "{{ trigger.to_state.context.parent_id is none }}" | |
| - condition: template | |
| value_template: "{{ schedule_allows_lighting }}" | |
| - condition: template | |
| value_template: > | |
| {# Only start the timer if at least one of the controlled lights is currently on #} | |
| {{ light_entities | select('is_state', 'on') | list | count > 0 }} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'lighting' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Trigger Inactive, Starting Off Timer" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| β‘ Trigger Entity: {{ trigger_entity }} | |
| π Trigger State: {{ trigger_state }} (inactive β timer only, no turn-on) | |
| π‘ Lights on: {{ light_entities | select('is_state', 'on') | list | count }} | |
| β±οΈ Off Timer: {{ light_off_timer }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Timer only β lights are already on, just start the countdown | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = light_off_timer if light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if lighting_bypass_timer_entity is defined and lighting_bypass_timer_entity %} | |
| {{ lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Light Off Timer BYPASSED (Inactive)" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Light Off Timer Started (Inactive)" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| β±οΈ Timer Duration: {{ light_off_timer }} ({{ timer_seconds }}s) | |
| βΉοΈ Trigger went inactive β countdown started, lights will turn off if no new activity | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Lights Turned OFF (Inactive Timer Expired)" | |
| message: | | |
| β‘ Original Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ light_entities | length }} light(s) | |
| β±οΈ Timer expired after inactive trigger - lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle OUTDOOR LIGHTING trigger entities | |
| - conditions: | |
| - condition: trigger | |
| id: trigger_outdoor_lighting_entities | |
| sequence: | |
| - variables: | |
| trigger_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| trigger_entity: "{{ trigger.entity_id }}" | |
| trigger_state: "{{ trigger.to_state.state }}" | |
| current_day: "{{ now().strftime('%a').lower() }}" | |
| current_time: "{{ now().strftime('%H:%M:%S') }}" | |
| # Shared schedule condition for outdoor | |
| - variables: | |
| outdoor_schedule_allows_lighting: > | |
| {% if outdoor_lighting_schedule_enabled %} | |
| {% set outdoor_lighting_schedule_days = outdoor_lighting_schedule_days if outdoor_lighting_schedule_days is defined else [] %} | |
| {% set day_match = current_day in outdoor_lighting_schedule_days %} | |
| {% if day_match %} | |
| {% if outdoor_lighting_schedule_start_time <= outdoor_lighting_schedule_end_time %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time and current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% else %} | |
| {{ not (current_time >= outdoor_lighting_schedule_start_time or current_time <= outdoor_lighting_schedule_end_time) }} | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| {% else %} | |
| true | |
| {% endif %} | |
| - choose: | |
| # ββ Branch A: Active state β turn outdoor lights on + start timer ββ | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ enable_outdoor_lighting_control }}" | |
| - condition: template | |
| value_template: > | |
| {% set active_states = ['on', 'open', 'unlocked'] %} | |
| {{ trigger_state in active_states }} | |
| - condition: template | |
| value_template: "{{ trigger.to_state.context.parent_id is none }}" | |
| - condition: template | |
| value_template: > | |
| {% set is_outdoor_light_entity = trigger.entity_id in (outdoor_light_entities if outdoor_light_entities is iterable else [outdoor_light_entities]) %} | |
| {{ not is_outdoor_light_entity or outdoor_lighting_manual_control_timer }} | |
| - condition: template | |
| value_template: "{{ outdoor_schedule_allows_lighting }}" | |
| sequence: | |
| # Turn outdoor lights on | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_light_entities is defined and outdoor_light_entities | length > 0 }}" | |
| then: | |
| - service: light.turn_on | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| data: | |
| brightness_pct: "{{ outdoor_light_brightness }}" | |
| color_temp_kelvin: "{{ outdoor_light_color_temp }}" | |
| # Execute custom outdoor lighting action | |
| - if: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_custom_action is defined and outdoor_lighting_custom_action | length > 0 }}" | |
| then: | |
| - choose: [] | |
| default: !input outdoor_lighting_custom_action | |
| # Outdoor Light Off Timer | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = outdoor_light_off_timer if outdoor_light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_bypass_timer_entity is defined and outdoor_lighting_bypass_timer_entity %} | |
| {{ outdoor_lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Light Off Timer BYPASSED" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ outdoor_light_entities | length }} light(s) | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Light Off Timer Started (Active)" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ outdoor_light_entities | length }} light(s) | |
| β±οΈ Timer Duration: {{ outdoor_light_off_timer }} ({{ timer_seconds }}s) | |
| βΉοΈ mode:restart means any new trigger resets this timer | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Lights Turned OFF (Timer Expired)" | |
| message: | | |
| β‘ Original Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ outdoor_light_entities | length }} light(s) | |
| β±οΈ Timer expired after active trigger - outdoor lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # ββ Branch B: Inactive state β timer only, no turn-on ββ | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ enable_outdoor_lighting_control }}" | |
| - condition: template | |
| value_template: > | |
| {% set inactive_states = ['off', 'closed', 'locked'] %} | |
| {{ trigger_state in inactive_states }} | |
| - condition: template | |
| value_template: "{{ trigger.to_state.context.parent_id is none }}" | |
| - condition: template | |
| value_template: "{{ outdoor_schedule_allows_lighting }}" | |
| - condition: template | |
| value_template: > | |
| {{ outdoor_light_entities | select('is_state', 'on') | list | count > 0 }} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'lighting' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Trigger Inactive, Starting Off Timer" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| β‘ Trigger Entity: {{ trigger_entity }} | |
| π Trigger State: {{ trigger_state }} (inactive β timer only, no turn-on) | |
| π‘ Outdoor lights on: {{ outdoor_light_entities | select('is_state', 'on') | list | count }} | |
| β±οΈ Off Timer: {{ outdoor_light_off_timer }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - variables: | |
| timer_seconds: > | |
| {% set timer = outdoor_light_off_timer if outdoor_light_off_timer is defined else {} %} | |
| {{ timer.hours|default(0) * 3600 + timer.minutes|default(0) * 60 + timer.seconds|default(0) + timer.days|default(0) * 86400 }} | |
| - if: | |
| - condition: template | |
| value_template: "{{ timer_seconds > 0 }}" | |
| then: | |
| - choose: | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ outdoor_lighting_bypass_timer_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if outdoor_lighting_bypass_timer_entity is defined and outdoor_lighting_bypass_timer_entity %} | |
| {{ outdoor_lighting_bypass_timer_entity | selectattr('state', 'defined') | selectattr('state', 'eq', 'on') | list | count > 0 }} | |
| {% else %} | |
| false | |
| {% endif %} | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Light Off Timer BYPASSED (Inactive)" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| β±οΈ Timer Bypassed: Yes (bypass condition is true) | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| default: | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Light Off Timer Started (Inactive)" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ outdoor_light_entities | length }} light(s) | |
| β±οΈ Timer Duration: {{ outdoor_light_off_timer }} ({{ timer_seconds }}s) | |
| βΉοΈ Trigger went inactive β countdown started, outdoor lights off if no new activity | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - delay: | |
| seconds: "{{ timer_seconds }}" | |
| - service: light.turn_off | |
| target: | |
| entity_id: "{{ outdoor_light_entities }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| then: | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Outdoor Lights Turned OFF (Inactive Timer Expired)" | |
| message: | | |
| β‘ Original Trigger: {{ trigger_time }} | |
| π‘ Lights: {{ outdoor_light_entities | length }} light(s) | |
| β±οΈ Timer expired after inactive trigger - outdoor lights off | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle door schedule checks (hourly) | |
| - conditions: | |
| - condition: trigger | |
| id: check_door_schedules | |
| sequence: | |
| # Capture trigger time at the beginning of the sequence | |
| - variables: | |
| trigger_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| # Debug notification | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule Check Triggered" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Start: {{ action_time }} | |
| π Current Day: {{ now().strftime('%a').lower() }} | |
| π Current Time: {{ now().strftime('%H:%M:%S') }} | |
| πͺ Door State: {{ states(garage_door_entity) if states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| {% if debug_include_variables %} | |
| π Schedule Status: | |
| - Schedule 1: {{ schedule1_enabled }} ({{ schedule1_action }}) | |
| - Schedule 2: {{ schedule2_enabled }} ({{ schedule2_action }}) | |
| - Schedule 3: {{ schedule3_enabled }} ({{ schedule3_action }}) | |
| {% endif %} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - variables: | |
| current_day: "{{ now().strftime('%a').lower() }}" | |
| current_time: "{{ now().strftime('%H:%M:%S') }}" | |
| # Check Schedule 1 | |
| - if: | |
| - condition: template | |
| value_template: "{{ schedule1_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% set schedule1_days = schedule1_days if schedule1_days is defined else [] %} | |
| {{ current_day in schedule1_days }} | |
| - condition: template | |
| value_template: > | |
| {% if schedule1_start_time < schedule1_end_time %} | |
| {{ current_time >= schedule1_start_time and current_time <= schedule1_end_time }} | |
| {% else %} | |
| {{ current_time >= schedule1_start_time or current_time <= schedule1_end_time }} | |
| {% endif %} | |
| then: | |
| # Debug notification for Schedule 1 check | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule 1 Active" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Check Time: {{ action_time }} | |
| π Schedule 1 Active | |
| βοΈ Action: {{ schedule1_action }} | |
| β±οΈ Delay: {{ schedule1_delay }} | |
| πͺ Door State: {{ states(garage_door_entity) if states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle OPEN action for Schedule 1 | |
| - if: | |
| - condition: template | |
| value_template: "{{ schedule1_action == 'open' }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closed' }}" | |
| then: | |
| - delay: "{{ schedule1_delay }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closed' }}" | |
| - condition: template | |
| value_template: > | |
| {% if schedule1_start_time < schedule1_end_time %} | |
| {{ current_time >= schedule1_start_time and current_time <= schedule1_end_time }} | |
| {% else %} | |
| {{ current_time >= schedule1_start_time or current_time <= schedule1_end_time }} | |
| {% endif %} | |
| then: | |
| # Debug notification for Schedule 1 open action | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule 1 Opening Door" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π Schedule 1 Executing | |
| βοΈ Action: OPEN door | |
| πͺ Door State Before: {{ states(garage_door_entity) }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - service: cover.open_cover | |
| target: | |
| entity_id: !input garage_door_entity | |
| # Handle CLOSE action for Schedule 1 (when door is open) | |
| - if: | |
| - condition: template | |
| value_template: "{{ schedule1_action == 'close' }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| then: | |
| - delay: "{{ schedule1_delay }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| - condition: template | |
| value_template: > | |
| {% if schedule1_start_time < schedule1_end_time %} | |
| {{ current_time >= schedule1_start_time and current_time <= schedule1_end_time }} | |
| {% else %} | |
| {{ current_time >= schedule1_start_time or current_time <= schedule1_end_time }} | |
| {% endif %} | |
| then: | |
| # Debug notification for Schedule 1 close action | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule 1 Closing Door" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π Schedule 1 Executing | |
| βοΈ Action: CLOSE door | |
| πͺ Door State Before: {{ states(garage_door_entity) }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - service: cover.close_cover | |
| target: | |
| entity_id: !input garage_door_entity | |
| # Check Schedule 2 | |
| - if: | |
| - condition: template | |
| value_template: "{{ schedule2_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% set schedule2_days = schedule2_days if schedule2_days is defined else [] %} | |
| {{ current_day in schedule2_days }} | |
| - condition: template | |
| value_template: > | |
| {% if schedule2_start_time < schedule2_end_time %} | |
| {{ current_time >= schedule2_start_time and current_time <= schedule2_end_time }} | |
| {% else %} | |
| {{ current_time >= schedule2_start_time or current_time <= schedule2_end_time }} | |
| {% endif %} | |
| then: | |
| # Debug notification for Schedule 2 check | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule 2 Active" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Check Time: {{ action_time }} | |
| π Schedule 2 Active | |
| βοΈ Action: {{ schedule2_action }} | |
| β±οΈ Delay: {{ schedule2_delay }} | |
| πͺ Door State: {{ states(garage_door_entity) if states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle OPEN action for Schedule 2 | |
| - if: | |
| - condition: template | |
| value_template: "{{ schedule2_action == 'open' }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closed' }}" | |
| then: | |
| - delay: "{{ schedule2_delay }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closed' }}" | |
| - condition: template | |
| value_template: > | |
| {% if schedule2_start_time < schedule2_end_time %} | |
| {{ current_time >= schedule2_start_time and current_time <= schedule2_end_time }} | |
| {% else %} | |
| {{ current_time >= schedule2_start_time or current_time <= schedule2_end_time }} | |
| {% endif %} | |
| then: | |
| # Debug notification for Schedule 2 open action | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule 2 Opening Door" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π Schedule 2 Executing | |
| βοΈ Action: OPEN door | |
| πͺ Door State Before: {{ states(garage_door_entity) }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - service: cover.open_cover | |
| target: | |
| entity_id: !input garage_door_entity | |
| # Handle CLOSE action for Schedule 2 | |
| - if: | |
| - condition: template | |
| value_template: "{{ schedule2_action == 'close' }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| then: | |
| - delay: "{{ schedule2_delay }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| - condition: template | |
| value_template: > | |
| {% if schedule2_start_time < schedule2_end_time %} | |
| {{ current_time >= schedule2_start_time and current_time <= schedule2_end_time }} | |
| {% else %} | |
| {{ current_time >= schedule2_start_time or current_time <= schedule2_end_time }} | |
| {% endif %} | |
| then: | |
| # Debug notification for Schedule 2 close action | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule 2 Closing Door" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π Schedule 2 Executing | |
| βοΈ Action: CLOSE door | |
| πͺ Door State Before: {{ states(garage_door_entity) }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - service: cover.close_cover | |
| target: | |
| entity_id: !input garage_door_entity | |
| # Check Schedule 3 | |
| - if: | |
| - condition: template | |
| value_template: "{{ schedule3_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% set schedule3_days = schedule3_days if schedule3_days is defined else [] %} | |
| {{ current_day in schedule3_days }} | |
| - condition: template | |
| value_template: > | |
| {% if schedule3_start_time < schedule3_end_time %} | |
| {{ current_time >= schedule3_start_time and current_time <= schedule3_end_time }} | |
| {% else %} | |
| {{ current_time >= schedule3_start_time or current_time <= schedule3_end_time }} | |
| {% endif %} | |
| then: | |
| # Debug notification for Schedule 3 check | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule 3 Active" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Check Time: {{ action_time }} | |
| π Schedule 3 Active | |
| βοΈ Action: {{ schedule3_action }} | |
| β±οΈ Delay: {{ schedule3_delay }} | |
| πͺ Door State: {{ states(garage_door_entity) if states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] else 'unavailable' }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| # Handle OPEN action for Schedule 3 | |
| - if: | |
| - condition: template | |
| value_template: "{{ schedule3_action == 'open' }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closed' }}" | |
| then: | |
| - delay: "{{ schedule3_delay }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'closed' }}" | |
| - condition: template | |
| value_template: > | |
| {% if schedule3_start_time < schedule3_end_time %} | |
| {{ current_time >= schedule3_start_time and current_time <= schedule3_end_time }} | |
| {% else %} | |
| {{ current_time >= schedule3_start_time or current_time <= schedule3_end_time }} | |
| {% endif %} | |
| then: | |
| # Debug notification for Schedule 3 open action | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule 3 Opening Door" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π Schedule 3 Executing | |
| βοΈ Action: OPEN door | |
| πͺ Door State Before: {{ states(garage_door_entity) }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - service: cover.open_cover | |
| target: | |
| entity_id: !input garage_door_entity | |
| # Handle CLOSE action for Schedule 3 | |
| - if: | |
| - condition: template | |
| value_template: "{{ schedule3_action == 'close' }}" | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| then: | |
| - delay: "{{ schedule3_delay }}" | |
| - if: | |
| - condition: template | |
| value_template: "{{ states(garage_door_entity) not in ['unavailable', 'unknown', 'none'] and states(garage_door_entity) == 'open' }}" | |
| - condition: template | |
| value_template: > | |
| {% if schedule3_start_time < schedule3_end_time %} | |
| {{ current_time >= schedule3_start_time and current_time <= schedule3_end_time }} | |
| {% else %} | |
| {{ current_time >= schedule3_start_time or current_time <= schedule3_end_time }} | |
| {% endif %} | |
| then: | |
| # Debug notification for Schedule 3 close action | |
| - if: | |
| - condition: template | |
| value_template: "{{ debug_enabled }}" | |
| - condition: template | |
| value_template: > | |
| {% if 'all' in debug_trigger_types %} | |
| true | |
| {% else %} | |
| {{ 'schedules' in debug_trigger_types }} | |
| {% endif %} | |
| then: | |
| - variables: | |
| action_time: "{{ now().strftime('%H:%M:%S.%f')[:-3] }}" | |
| - service: persistent_notification.create | |
| data: | |
| title: "π {{ automation_friendly_name }} - Schedule 3 Closing Door" | |
| message: | | |
| β‘ Trigger: {{ trigger_time }} | |
| π Action Time: {{ action_time }} | |
| π Schedule 3 Executing | |
| βοΈ Action: CLOSE door | |
| πͺ Door State Before: {{ states(garage_door_entity) }} | |
| notification_id: "{{ debug_notification_id }}_{{ now().strftime('%Y%m%d_%H%M%S%f')[:-3] }}" | |
| - service: cover.close_cover | |
| target: | |
| entity_id: !input garage_door_entity |
Comments are disabled for this gist.