diff --git a/ha-smart-thermostat-control.yaml b/ha-smart-thermostat-control.yaml index b11ea39..47f29da 100644 --- a/ha-smart-thermostat-control.yaml +++ b/ha-smart-thermostat-control.yaml @@ -1,7 +1,12 @@ blueprint: name: "Smart Thermostat Controller" author: Andreas Gammelgaard Damsbo - description: "Advanced thermostat automation with window/door sensors, presence detection, time schedules, and holiday calendar integration" + description: | + Advanced thermostat automation with window/door sensors, presence detection, time schedules, and holiday calendar integration. + + SETUP REQUIRED: + 1. Create an input_boolean helper (Settings > Devices & Services > Helpers > Toggle) for manual override tracking + 2. Create a timer helper (Settings > Devices & Services > Helpers > Timer) for override duration domain: automation source_url: https://gdamsbo.dk/forgejo/andreas/ha-smart-thermostat-control/raw/branch/main/ha-smart-thermostat-control.yaml input: @@ -21,9 +26,17 @@ blueprint: domain: - input_boolean multiple: false + override_timer: + name: Override Timer + description: Select a timer helper to manage override duration. Create one in Settings > Devices & Services > Helpers > Timer. + selector: + entity: + domain: + - timer + multiple: false override_duration: name: Manual Override Duration - description: 'How long manual temperature changes should override the schedule before returning to automatic control. (Default = 120 minutes)' + description: 'How long manual temperature changes should override the schedule. This sets the timer duration. (Default = 120 minutes)' default: 120 selector: number: @@ -169,6 +182,10 @@ trigger: entity_id: !input manual_override_helper to: 'off' id: override_expired + - platform: state + entity_id: !input override_timer + to: 'idle' + id: timer_finished - platform: calendar event: end entity_id: !input away_calendar @@ -222,8 +239,8 @@ action: - service: logbook.log data: name: Smart Thermostat - message: 'Manual Override: Temperature set to {{ new_temperature }}° by {{ triggered_thermostat }}' - # Sync temperature to all other thermostats FIRST + message: 'Manual Override: {{ triggered_thermostat }} changed to {{ new_temperature }}°, syncing others' + # Sync temperature to all other thermostats - repeat: for_each: "{{ thermostat_entities | reject('eq', triggered_thermostat) | list }}" sequence: @@ -232,21 +249,29 @@ action: entity_id: "{{ repeat.item }}" data: temperature: "{{ new_temperature }}" - # Enable manual override mode AFTER syncing + # Enable manual override mode - service: input_boolean.turn_on target: entity_id: !input manual_override_helper - # Simple delay timer - will complete even if automation is triggered again - - delay: - minutes: !input override_duration - # Disable override after timeout + # Start timer + - service: timer.start + target: + entity_id: !input override_timer + data: + duration: "{{ (input_override_duration * 60) | int }}" + + # Priority 0b: Timer Finished - Disable override and resume schedule + - conditions: + - condition: trigger + id: timer_finished + sequence: - service: input_boolean.turn_off target: entity_id: !input manual_override_helper - service: logbook.log data: name: Smart Thermostat - message: 'Manual Override: Expired after {{ input_override_duration }} minutes' + message: 'Manual Override: Timer expired, resuming schedule' # Priority 1: Windows/Doors Open - Turn OFF heating (overrides manual) - conditions: @@ -261,6 +286,9 @@ action: - service: input_boolean.turn_off target: entity_id: !input manual_override_helper + - service: timer.cancel + target: + entity_id: !input override_timer - service: logbook.log data: name: Smart Thermostat @@ -278,6 +306,9 @@ action: - service: input_boolean.turn_off target: entity_id: !input manual_override_helper + - service: timer.cancel + target: + entity_id: !input override_timer - service: logbook.log data: name: Smart Thermostat @@ -382,6 +413,5 @@ action: name: Smart Thermostat message: 'Heating OFF: No active heating conditions met' -mode: queued -max: 5 +mode: single max_exceeded: silent \ No newline at end of file