Skip to content

Commit

Permalink
Add a master switch to control climate scheduling
Browse files Browse the repository at this point in the history
Also improve resiliency of manual climate mode reversal.
  • Loading branch information
Chris-V committed Aug 11, 2024
1 parent c276466 commit 75d275d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
10 changes: 8 additions & 2 deletions blueprints/automation/reset_input_select.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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') %}
Expand Down
3 changes: 2 additions & 1 deletion packages/climate/mode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
44 changes: 40 additions & 4 deletions packages/climate/scheduling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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 }}."

0 comments on commit 75d275d

Please sign in to comment.