From 0bc287a042c742c4dd24b9b24fd5e9aeb2523113 Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Wed, 12 Jun 2024 18:26:43 -0400 Subject: HA: adaptive_lighting custom component to follow daylight --- hostnix/elmo/home-assistant.nix | 123 ++++++++-------------------------------- 1 file changed, 25 insertions(+), 98 deletions(-) diff --git a/hostnix/elmo/home-assistant.nix b/hostnix/elmo/home-assistant.nix index 35f0e70..7facdd4 100644 --- a/hostnix/elmo/home-assistant.nix +++ b/hostnix/elmo/home-assistant.nix @@ -23,9 +23,11 @@ ]; # 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 tuya_local ]; + config = { default_config = { }; http = { @@ -44,11 +46,12 @@ # value_template: "{{ state_attr('weather.knyc_daynight', 'forecast')[1]['precipitation_probability']|float > 0 or state_attr('weather.knyc_daynight', 'forecast')[2]['precipitation_probability']|float > 0 }}" # #value_template: "{{ states('sensor.dark_sky_precip_probability_0d')|float > 5 }}" - input_number.target_panel_brightness = { - name = "Target panel brightness"; - min = 0; - max = 100; - icon = "mdi:lightbulb-on-outline"; + adaptive_lighting = { + lights = [ + "light.grow_light" + "light.panel_light" + ]; + max_color_temp = 3500; }; climate = [ @@ -401,52 +404,6 @@ in [ - { - alias = "Panel update"; - trigger = [ - { - platform = "state"; - entity_id = "input_number.target_panel_brightness"; - } - { - platform = "zone"; - entity_id = "person.joe"; - zone = "zone.home"; - event = "enter"; - } - ]; - condition = [ - { - condition = "zone"; - entity_id = "person.joe"; - zone = "zone.home"; - } - ]; - action = [ - { - service = "light.turn_on"; - target.entity_id = "light.panel_light"; - data.brightness_pct = "{{ states('input_number.target_panel_brightness')|float * 0.9 + 10 }}"; - } - ]; - } - { - alias = "Grow light update"; - trigger = [ - { - platform = "state"; - entity_id = "input_number.target_panel_brightness"; - } - ]; - action = [ - { - service = "light.turn_on"; - target.entity_id = "light.grow_light"; - data.brightness_pct = "{{ states('input_number.target_panel_brightness') }}"; - } - ]; - } - { alias = "Depart"; trigger = { @@ -461,61 +418,28 @@ } { - alias = "Sunrise"; - trigger = { - platform = "sun"; - event = "sunrise"; - }; - action = [ + alias = "Arrive/Sunrise"; + trigger = [ { - service = "input_number.set_value"; - target.entity_id = "input_number.target_panel_brightness"; - data.value = 15; + platform = "sun"; + event = "sunrise"; } - ]; - } - { - alias = "Sunrise after"; - trigger = { - platform = "sun"; - event = "sunrise"; - offset = "1:00"; - }; - action = [ { - service = "input_number.set_value"; - target.entity_id = "input_number.target_panel_brightness"; - data.value = 100; + platform = "zone"; + entity_id = "person.joe"; + zone = "zone.home"; + event = "enter"; } ]; - } - { - alias = "Sunset before"; - trigger = { - platform = "sun"; - event = "sunset"; - offset = "-1:00"; - }; - action = [ + condition = [ { - service = "input_number.set_value"; - target.entity_id = "input_number.target_panel_brightness"; - data.value = 15; + condition = "zone"; + entity_id = "person.joe"; + zone = "zone.home"; } ]; - } - { - alias = "Sunset"; - trigger = { - platform = "sun"; - event = "sunset"; - }; action = [ - { - service = "input_number.set_value"; - target.entity_id = "input_number.target_panel_brightness"; - data.value = 0; - } + (service "light.turn_on" "light.panel_light") ]; } @@ -525,7 +449,10 @@ platform = "time"; at = "08:00"; }; - action = [ (service "switch.turn_on" "switch.wakko") ]; + action = [ + (service "switch.turn_on" "light.grow_light") + (service "switch.turn_on" "switch.wakko") + ]; } { alias = "Grow light night"; -- cgit v1.3.1