From 77d5d0b6ed031091cf19895628fe2ddaa3869fbb Mon Sep 17 00:00:00 2001 From: Joe Mou Date: Tue, 23 Apr 2024 20:45:24 -0400 Subject: Panel light and thermostat HA automations --- hostnix/elmo/home-assistant.nix | 332 +++++++++++++++++----------------------- 1 file changed, 137 insertions(+), 195 deletions(-) (limited to 'hostnix/elmo') diff --git a/hostnix/elmo/home-assistant.nix b/hostnix/elmo/home-assistant.nix index d7e3bbb..a392dfc 100644 --- a/hostnix/elmo/home-assistant.nix +++ b/hostnix/elmo/home-assistant.nix @@ -14,15 +14,10 @@ enable = true; extraPackages = ps: with ps; [ psycopg2 ]; extraComponents = [ - "androidtv_remote" - "apple_tv" - "cast" - "homekit_controller" - "hue" - "spotify" "esphome" "met" - "radio_browser" + "roku" + "vesync" ]; # https://nathan.gs/2023/12/28/home-assistant-add-a-custom-component-in-nixos-revisited/ customComponents = [ @@ -83,44 +78,6 @@ recorder.db_url = "postgresql://@/hass"; auth_header = { }; -# panel_custom: -# - name: ha_system -# sidebar_title: System -# sidebar_icon: mdi:cog-transfer -# js_url: /api/hassio/app/entrypoint.js -# url_path: config/system -# embed_iframe: true -# require_admin: true -# config: -# ingress: core_configurator -# - name: ha_integ -# sidebar_title: Integrations -# sidebar_icon: mdi:chip -# js_url: /api/hassio/app/entrypoint.js -# url_path: 'config/integrations' -# embed_iframe: true -# require_admin: true -# config: -# ingress: core_configurator -# - name: ha_auto -# sidebar_title: Automations -# sidebar_icon: mdi:cog-outline -# js_url: /api/hassio/app/entrypoint.js -# url_path: 'config/automation' -# embed_iframe: true -# require_admin: true -# config: -# ingress: core_configurator -# - name: ha_helpers -# sidebar_title: Helpers -# sidebar_icon: mdi:toggle-switch -# js_url: /api/hassio/app/entrypoint.js -# url_path: 'config/helpers' -# embed_iframe: true -# require_admin: true -# config: -# ingress: core_configurator - #binary_sensor: # - platform: template # sensors: @@ -166,6 +123,13 @@ # data: # entity_id: climate.sensi + input_number.target_panel_brightness = { + name = "Target panel brightness"; + min = 0; + max = 100; + icon = "mdi:lightbulb-on-outline"; + }; + climate = [ { platform = "generic_thermostat"; @@ -286,68 +250,6 @@ # entity_id: light.nodemcu_led # service: light.turn_off # id: ba3266d2ebfe4b4cabbc5ef36a63412d -# - id: 5e305118cd194415ad92d20c3d43bd02 -# alias: Sunrise -# description: '' -# trigger: -# - platform: sun -# event: sunrise -# offset: 0 -# enabled: false -# - platform: time -# at: '11:00:00' -# enabled: true -# condition: [] -# action: -# - service: switch.turn_on -# data: {} -# target: -# entity_id: switch.dot -# enabled: false -# - service: input_number.set_value -# data: -# value: 15 -# target: -# entity_id: input_number.target_panel_brightness -# mode: single -# - id: 6741dba471544def9d07b04159eed53c -# alias: Sunset before -# description: '' -# trigger: -# - platform: sun -# event: sunset -# offset: '-1:00:00' -# condition: [] -# action: -# - service: input_number.set_value -# data: -# value: 15 -# target: -# entity_id: input_number.target_panel_brightness -# mode: single -# - id: 28d9fc5eaa004511b7b7a2a9b8067685 -# alias: Panel update -# description: '' -# 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 -# data: -# brightness_pct: '{{ states(''input_number.target_panel_brightness'') | float -# * 0.9 + 10 }}' -# target: -# entity_id: light.panel_light -# mode: single # - alias: Windows webhook # description: '' # trigger: @@ -428,44 +330,6 @@ # target: # entity_id: switch.dot # mode: single -# - id: 7b22ab12248c4664b00416a8ee9dd892 -# alias: Sunrise after -# description: '' -# trigger: -# - platform: sun -# event: sunrise -# offset: '1:00:00' -# enabled: false -# - platform: time -# at: '11:45:00' -# enabled: true -# condition: [] -# action: -# - service: input_number.set_value -# data: -# value: 100 -# target: -# entity_id: input_number.target_panel_brightness -# mode: single -# - id: 41a2a1b3a57e4d179e253808a6b2ab3b -# alias: Sunset -# description: '' -# trigger: -# - platform: sun -# event: sunset -# condition: [] -# action: -# - service: switch.turn_off -# data: {} -# target: -# entity_id: switch.dot -# enabled: false -# - service: input_number.set_value -# data: -# value: 0 -# target: -# entity_id: input_number.target_panel_brightness -# mode: single # - alias: Barrier webhook # description: '' # trigger: @@ -557,21 +421,6 @@ # target: # entity_id: switch.dot # mode: single -# - id: '1675140468263' -# alias: Bedroom toggle panel light -# description: '' -# trigger: -# - platform: state -# entity_id: -# - binary_sensor.bedroom_button_2 -# to: 'on' -# condition: [] -# action: -# - service: light.toggle -# data: {} -# target: -# entity_id: light.panel_light -# mode: single # - id: '1675140647798' # alias: Panel light reinitialize # description: '' @@ -602,34 +451,6 @@ # target: # entity_id: switch.wakko # mode: single -# - id: '1677230545794' -# alias: Thermostat night -# description: '' -# trigger: -# - platform: time -# at: '23:00:00' -# condition: [] -# action: -# - service: climate.set_temperature -# data: -# temperature: 69 -# target: -# entity_id: climate.bedroom -# mode: single -# - id: '1677230614940' -# alias: Thermostat morning -# description: '' -# trigger: -# - platform: time -# at: 06:00:00 -# condition: [] -# action: -# - service: climate.set_temperature -# data: -# temperature: 71 -# target: -# entity_id: climate.bedroom -# mode: single # - id: '1678928586230' # alias: Spotify WIP # description: '' @@ -721,20 +542,141 @@ automation = [ { - alias = "Morning Light"; + 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 = "Sunrise"; trigger = { - platform = "time"; - at = "8:00"; + platform = "sun"; + event = "sunrise"; }; action = [ { - # TODO target_panel_brightness - service = "light.turn_on"; + service = "input_number.set_value"; + target.entity_id = "input_number.target_panel_brightness"; + data.value = 15; + } + # { + # service = "switch.turn_on"; + # target.entity_id = "switch.dot"; + # } + ]; + } + { + 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; + } + ]; + } + { + alias = "Sunset before"; + trigger = { + platform = "sun"; + event = "sunset"; + offset = "-1:00"; + }; + action = [ + { + service = "input_number.set_value"; + target.entity_id = "input_number.target_panel_brightness"; + data.value = 15; + } + ]; + } + { + 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 = "switch.turn_off"; + # target.entity_id = "switch.dot"; + # } + ]; + } + + { + alias = "Bedroom toggle panel light"; + trigger = { + platform = "state"; + entity_id = "binary_sensor.bedroom_button_2"; + to = "on"; + }; + action = [ + { + service = "light.toggle"; target.entity_id = "light.panel_light"; } + ]; + } + + { + 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 = "switch.turn_on"; - target.entity_id = "switch.dot"; + service = "climate.set_temperature"; + target.entity_id = "climate.bedroom"; + data.temperature = 69; } ]; } -- cgit v1.3.1