From d5a9e13b1e0aceb2d5345df1edd98da5d8273ade Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Mon, 6 May 2024 23:31:56 -0400 Subject: HA: improve panel light and thermostat automations Also fixes missing component errors. --- hostnix/elmo/home-assistant.nix | 110 +++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 58 deletions(-) (limited to 'hostnix/elmo/home-assistant.nix') diff --git a/hostnix/elmo/home-assistant.nix b/hostnix/elmo/home-assistant.nix index 5b29a10..e4fa35d 100644 --- a/hostnix/elmo/home-assistant.nix +++ b/hostnix/elmo/home-assistant.nix @@ -14,9 +14,11 @@ enable = true; extraPackages = ps: with ps; [ psycopg2 ]; extraComponents = [ + "apple_tv" "esphome" "met" "roku" + "spotify" "vesync" ]; # https://nathan.gs/2023/12/28/home-assistant-add-a-custom-component-in-nixos-revisited/ @@ -143,22 +145,6 @@ } ]; -# - id: b43fdad4b27046b0a8688742daf89ba2 -# alias: Departure -# description: '' -# trigger: -# - platform: zone -# entity_id: person.joe -# zone: zone.home -# event: leave -# condition: [] -# action: -# - service: light.turn_off -# data: {} -# target: -# entity_id: -# - light.panel_light -# mode: single # - alias: Sound machine switch # description: '' # trigger: @@ -540,7 +526,23 @@ # - stop: 'Release Radar (updates Fridays): 37i9dQZEVXbgyUT3Ewvdog' # mode: single - automation = [ + automation = let + setTemperatureAt = at: temperature: { + alias = "Thermostat ${at}"; + trigger = { + inherit at; + platform = "time"; + }; + action = [ + { + service = "climate.set_temperature"; + target.entity_id = "climate.bedroom"; + data.temperature = temperature; + } + ]; + }; + in + [ { alias = "Panel update"; trigger = [ @@ -548,20 +550,20 @@ platform = "state"; entity_id = "input_number.target_panel_brightness"; } - # { - # platform = "zone"; - # entity_id = "person.joe"; - # zone: "zone.home"; - # event: "enter"; - # } + { + platform = "zone"; + entity_id = "person.joe"; + zone = "zone.home"; + event = "enter"; + } + ]; + condition = [ + { + condition = "zone"; + entity_id = "person.joe"; + zone = "zone.home"; + } ]; - # condition = [ - # { - # condition = "zone"; - # entity_id = "person.joe"; - # zone: "zone.home"; - # } - # ]; action = [ { service = "light.turn_on"; @@ -570,6 +572,22 @@ } ]; } + { + alias = "Panel off"; + trigger = { + platform = "zone"; + entity_id = "person.joe"; + zone = "zone.home"; + event = "leave"; + }; + action = [ + { + service = "light.turn_off"; + target.entity_id = "light.panel_light"; + } + ]; + } + { alias = "Sunrise"; trigger = { @@ -652,34 +670,10 @@ ]; } - { - alias = "Thermostat morning"; - trigger = { - platform = "time"; - at = "06:00"; - }; - action = [ - { - service = "climate.set_temperature"; - target.entity_id = "climate.bedroom"; - data.temperature = 71; - } - ]; - } - { - alias = "Thermostat night"; - trigger = { - platform = "time"; - at = "23:00"; - }; - action = [ - { - service = "climate.set_temperature"; - target.entity_id = "climate.bedroom"; - data.temperature = 69; - } - ]; - } + (setTemperatureAt "06:00" 71) + (setTemperatureAt "12:00" 70) + (setTemperatureAt "19:00" 71) + (setTemperatureAt "22:00" 69) ]; }; }; -- cgit v1.3.1