From 75d275d9f3378981252d72d3ebc60910ce63d186 Mon Sep 17 00:00:00 2001 From: Christopher Viel Date: Sun, 11 Aug 2024 15:51:09 -0400 Subject: [PATCH] Add a master switch to control climate scheduling Also improve resiliency of manual climate mode reversal. --- blueprints/automation/reset_input_select.yaml | 10 ++++- packages/climate/mode.yaml | 3 +- packages/climate/scheduling.yaml | 44 +++++++++++++++++-- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/blueprints/automation/reset_input_select.yaml b/blueprints/automation/reset_input_select.yaml index 1af53184..5715e14f 100644 --- a/blueprints/automation/reset_input_select.yaml +++ b/blueprints/automation/reset_input_select.yaml @@ -23,7 +23,13 @@ blueprint: description: The input_select entity to manage. selector: entity: - domain: input_select + filter: + - domain: input_select + unless: + name: Unless + description: Do not reset entity_id if this condition evaluates to true. + selector: + condition: { } initial_state: true mode: "single" @@ -34,7 +40,7 @@ trigger: for: !input delay variables: - entity_id: "{{ trigger.to_state.entity_id }}" + entity_id: !input entity_id optional_default_option: !input default_option default_option: >- {% set options = state_attr(entity_id, 'options') %} diff --git a/packages/climate/mode.yaml b/packages/climate/mode.yaml index 444ac69f..a81999e4 100644 --- a/packages/climate/mode.yaml +++ b/packages/climate/mode.yaml @@ -91,7 +91,8 @@ template: script: restore_climate_auto_mode: - alias: "Restore auto mode on all climate entities" + alias: "restore_climate_auto_mode" + description: "Restore auto mode on all climate entities" icon: "mdi:thermometer-alert" mode: "queued" max_exceeded: "silent" diff --git a/packages/climate/scheduling.yaml b/packages/climate/scheduling.yaml index 7a90bebc..075ca39c 100644 --- a/packages/climate/scheduling.yaml +++ b/packages/climate/scheduling.yaml @@ -3,6 +3,11 @@ homeassistant: sensor.scheduled_climate_preset: friendly_name: "Scheduled climate preset" +input_boolean: + climate_scheduling_enabled: + name: "Enable climate scheduling" + icon: "mdi:thermometer-auto" + template: - sensor: - unique_id: "sensor.scheduled_climate_preset" @@ -45,7 +50,8 @@ template: script: assign_climate_auto_mode: - alias: "Assign auto climate mode" + alias: "assign_climate_auto_mode" + description: "" mode: "restart" fields: mode: @@ -68,7 +74,8 @@ script: {{ "{{\n{}\n}}".format(ns.entries | join(',\n')) | from_json }} apply_scheduled_climate_preset: - alias: "Set auto climate modes based on schedule" + alias: "apply_scheduled_climate_preset" + description: "Set auto climate modes based on the pre-configured schedule" icon: "mdi:thermometer-lines" mode: "restart" variables: @@ -145,8 +152,37 @@ automation: initial_state: true mode: "restart" trigger: - - platform: state + - platform: "state" entity_id: "sensor.scheduled_climate_preset" to: ~ + # - platform: "state" + # entity_id: "input_boolean.climate_scheduling_enabled" + # to: "on" + condition: + # - condition: "state" + # entity_id: "input_boolean.climate_scheduling_enabled" + # state: "on" + - "{{ trigger.to_state.state not in ['unknown', 'unavailable'] }}" action: - - service: script.apply_scheduled_climate_preset + - service: "script.apply_scheduled_climate_preset" + + + - id: "3b9b08a2-abf8-474b-9417-554c86f55b4e" + alias: "trigger_for_restart_test" + trigger: + - platform: state + entity_id: input_boolean.climate_scheduling_enabled + from: ["on", "off"] + to: ["on", "off"] + for: 60 + - platform: homeassistant + event: start + condition: + - condition: state + entity_id: input_boolean.climate_scheduling_enabled + state: ["on", "off"] + for: 60 + action: + - service: persistent_notification.create + data: + message: "Test triggered from {{ trigger.from_state.state }} to {{ trigger.to_state.state }}."