diff options
| author | Joe Mou <dev@mou.fo> | 2024-07-04 11:18:54 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2024-10-18 09:50:08 -0400 |
| commit | aa88710cfef541579e8a3b16e08a8133897b8249 (patch) | |
| tree | 1f379ca8ef87d75b9c1805cc558cbbb252a09d86 /hostnix/elmo | |
| parent | 26479ad1b9e441bd45642cf70a47e92f11cd6b32 (diff) | |
Summer thermostat schedule
Fixes /api to skip oauth2-proxy
Not thoroughly tested; there are probably some issues.
Diffstat (limited to 'hostnix/elmo')
| -rw-r--r-- | hostnix/elmo/home-assistant.nix | 147 |
1 files changed, 107 insertions, 40 deletions
diff --git a/hostnix/elmo/home-assistant.nix b/hostnix/elmo/home-assistant.nix index db270dd..9e39d8c 100644 --- a/hostnix/elmo/home-assistant.nix +++ b/hostnix/elmo/home-assistant.nix @@ -21,7 +21,6 @@ "spotify" "vesync" ]; - # https://nathan.gs/2023/12/28/home-assistant-add-a-custom-component-in-nixos-revisited/ customComponents = with pkgs.home-assistant-custom-components; [ adaptive_lighting auth-header @@ -122,6 +121,11 @@ # Remember HVAC mode and periodically explicitly sync heater. # initial_hvac_mode = "off" keep_alive.minutes = 5; + # Note: winter schedule has been removed. + # (setTemperatureAt "06:00" 71) + # (setTemperatureAt "12:00" 70) + # (setTemperatureAt "19:00" 71) + # (setTemperatureAt "22:00" 69) } { platform = "generic_thermostat"; @@ -159,24 +163,6 @@ # - entity_id: switch.wakko # service: switch.turn_on # id: ce759a29adb74a6090dcb0d1c1ef704c -# - alias: Homebound -# description: '' -# trigger: -# - event_data: -# actionName: Homebound -# event_type: ios.action_fired -# platform: event -# condition: [] -# action: -# - data: -# temperature: 72 -# entity_id: climate.bedroom -# service: climate.set_temperature -# - data: -# hvac_mode: heat -# entity_id: climate.bedroom -# service: climate.set_hvac_mode -# id: f039799e56cc48509e2855974c69a3e5 # - alias: Bedroom thermostat off # description: '' # trigger: @@ -448,18 +434,6 @@ }; }; - setTemperatureAt = time: temperature: { - alias = "Thermostat ${time}"; - trigger = [ (ha.trigger.at time) ]; - action = [ - { - service = "climate.set_temperature"; - target.entity_id = "climate.bedroom"; - data.temperature = temperature; - } - ]; - }; - in [ { @@ -473,6 +447,7 @@ action = [ (ha.action.off "light.panel_light") (ha.action.off "climate.bedroom_cool") + (ha.action.off "climate.air_conditioner_1") ]; } @@ -502,12 +477,102 @@ ]; } + # TODO doesn't trigger? + { + alias = "Summer thermostat"; + trigger = [ + (ha.trigger.at "08:00") + (ha.trigger.at "22:00") + { + platform = "zone"; + entity_id = "person.joe"; + zone = "zone.home"; + event = "enter"; + } + { + platform = "event"; + event_type = "ios.action_fired"; + event_data.actionName = "Homebound"; + } + # TODO maybe trigger if home and over 78? + ]; + condition = [ + { + condition = "template"; + value_template = "is_state('person.joe', 'home') || trigger.platform == 'event'"; + } + ]; + action = [ + # Turn off bedroom_cool if we're controlling air_conditioner_1. + { + "if" = [ + { + condition = "time"; + after = "08:00"; + before = "22:00"; + } + { + condition = "template"; + value_template = "{{ not is_state('climate.bedroom_cool', 'off') }}"; + } + ]; + "then" = [ + (ha.action.off "climate.bedroom_cool") + { delay = 5; } # allow effect on air_conditioner_1 to settle + ]; + } + + { + service = "climate.set_temperature"; + target.entity_id = '' + {% if 8 < now().hour < 22 %} + climate.air_conditioner_1 + {% else %} + climate.bedroom_cool + {% endif %} + ''; + # TODO Can Homebound burst to 72 for an hour? + data_template = { + hvac_mode = "auto"; + # hvac_mode = '' + # {% if 8 < now().hour < 22 %} + # auto + # {% else %} + # cool + # {% endif %} + # ''; + temperature = '' + {% if 8 < now().hour < 22 %} + 75 + {% else %} + 73 + {% endif %} + ''; + }; + } + ]; + } + + # TODO remove? + { + alias = "Pre-wake"; + trigger = [ (ha.trigger.at "07:00") ]; + action = [ + (ha.action.off "climate.bedroom_cool") + ]; + } { alias = "Grow light morning"; - trigger = [ (ha.trigger.at "08:00") ]; + # TODO make configurable (snooze) + trigger = [ (ha.trigger.at "09:00") ]; action = [ (ha.action.on "light.grow_light") (ha.action.on "switch.wakko") + { + service = "fan.set_percentage"; + target.entity_id = "fan.core_200s"; + data.percentage = 100; + } ]; } { @@ -516,15 +581,16 @@ action = [ (ha.action.off "switch.wakko") ]; } - (button "binary_sensor.bedroom_button_1" - (ha.action.toggle "switch.wakko")) + (button "binary_sensor.bedroom_button_1" [ + (ha.action.toggle "light.panel_light") + { + service = "fan.set_percentage"; + target.entity_id = "fan.core_200s"; + data.percentage = 66; + } + ]) (button "binary_sensor.bedroom_button_2" - (ha.action.toggle "light.panel_light")) - - (setTemperatureAt "06:00" 71) - (setTemperatureAt "12:00" 70) - (setTemperatureAt "19:00" 71) - (setTemperatureAt "22:00" 69) + (ha.action.toggle "switch.wakko")) ]; }; }; @@ -551,6 +617,7 @@ proxyWebsockets = true; extraConfig = '' proxy_buffering off; + auth_request off; ''; }; # Disable service worker caching that works improperly with reverse proxy. |
