From c370c87da36bc256cfbc59bb2b0b9ffa1d457168 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 1 Dec 2020 23:20:31 +0100 Subject: shack/glados: utilize mergeable home-assistant config --- .../shack/glados/automation/hass-restart.nix | 39 +++-- .../shack/glados/automation/party-time.nix | 45 ++--- .../shack/glados/automation/shack-startup.nix | 165 ++++++++++--------- krebs/2configs/shack/glados/default.nix | 65 +++----- krebs/2configs/shack/glados/multi/rollos.nix | 77 ++++----- .../2configs/shack/glados/multi/schlechte_luft.nix | 181 +++++++++++---------- krebs/2configs/shack/glados/multi/shackopen.nix | 45 ++--- krebs/2configs/shack/glados/multi/wasser.nix | 181 +++++++++++---------- krebs/2configs/shack/glados/sensors/darksky.nix | 43 ++--- krebs/2configs/shack/glados/sensors/mate.nix | 20 ++- krebs/2configs/shack/glados/sensors/power.nix | 5 +- krebs/2configs/shack/glados/sensors/sensemap.nix | 15 +- krebs/2configs/shack/glados/sensors/spaceapi.nix | 107 ++++++------ krebs/2configs/shack/glados/switch/power.nix | 42 +++-- 14 files changed, 533 insertions(+), 497 deletions(-) (limited to 'krebs/2configs') diff --git a/krebs/2configs/shack/glados/automation/hass-restart.nix b/krebs/2configs/shack/glados/automation/hass-restart.nix index 1b380204..5f61e19f 100644 --- a/krebs/2configs/shack/glados/automation/hass-restart.nix +++ b/krebs/2configs/shack/glados/automation/hass-restart.nix @@ -1,21 +1,24 @@ # needs: # light.fablab_led -[ - { alias = "State on HA start-up"; - trigger = { - platform = "homeassistant"; - event = "start"; - }; - # trigger good/bad air - action = [ - { service = "light.turn_on"; - data = { - entity_id = "light.fablab_led"; - effect = "Rainbow"; - color_name = "purple"; - }; - } - ]; - } -] +{ + services.home-assistant.config.automation = + [ + { alias = "State on HA start-up"; + trigger = { + platform = "homeassistant"; + event = "start"; + }; + # trigger good/bad air + action = [ + { service = "light.turn_on"; + data = { + entity_id = "light.fablab_led"; + effect = "Rainbow"; + color_name = "purple"; + }; + } + ]; + } + ]; +} diff --git a/krebs/2configs/shack/glados/automation/party-time.nix b/krebs/2configs/shack/glados/automation/party-time.nix index dfa42d05..9e7fe24c 100644 --- a/krebs/2configs/shack/glados/automation/party-time.nix +++ b/krebs/2configs/shack/glados/automation/party-time.nix @@ -6,24 +6,27 @@ let disko_schalter = "switch.lounge_diskoschalter_relay"; player = "media_player.lounge"; in -[ - { alias = "Party um 21 Uhr"; - trigger = { - platform = "sun"; - event = "sunset"; - }; - action = - ( glados.say.kiosk "Die Sonne geht unter. Und jetzt geht die Party im shack erst richtig los. Partybeleuchtung, aktiviert!" ) - ++ - [ - { - service = "homeassistant.turn_on"; - entity_id = disko_schalter; - } - { - service = "media_player.turn_on"; - data.entity_id = player; - } # TODO: also start playlist if nothing is running? - ]; - } -] +{ + services.home-assistant.config.automation = + [ + { alias = "Party um 21 Uhr"; + trigger = { + platform = "sun"; + event = "sunset"; + }; + action = + ( glados.say.kiosk "Die Sonne geht unter. Und jetzt geht die Party im shack erst richtig los. Partybeleuchtung, aktiviert!" ) + ++ + [ + { + service = "homeassistant.turn_on"; + entity_id = disko_schalter; + } + { + service = "media_player.turn_on"; + data.entity_id = player; + } # TODO: also start playlist if nothing is running? + ]; + } + ]; +} diff --git a/krebs/2configs/shack/glados/automation/shack-startup.nix b/krebs/2configs/shack/glados/automation/shack-startup.nix index ac7dd4f1..471d817a 100644 --- a/krebs/2configs/shack/glados/automation/shack-startup.nix +++ b/krebs/2configs/shack/glados/automation/shack-startup.nix @@ -13,85 +13,88 @@ let glados = import ../lib; in -[ - { - alias = "Bedanken bei Übernahme von Key"; - initial_state = true; - trigger = { - platform = "state"; - entity_id = "sensor.keyholder"; - }; - condition = { - condition = "template"; - value_template = "{{ (trigger.from_state.state != 'No Keyholder') and (trigger.from_state.state != 'No Keyholder') }}"; - }; - action = glados.say.kiosk "Danke {{ trigger.to_state.state }} für das Übernehmen des Keys von {{ trigger.from_state.state }}"; - } - { - alias = "Keyholder Begrüßen wenn MPD hoch fährt"; - initial_state = true; - trigger = { - platform = "state"; - from = "unavailable"; - entity_id = "media_player.kiosk"; - }; - action = glados.say.kiosk (builtins.readFile ./announcement.j2); - } - { - alias = "Start Music on portal lock on"; - trigger = { - platform = "state"; - entity_id = "binary_sensor.portal_lock"; - to = "on"; - for.seconds = 30; - }; - condition = { - condition = "and"; - conditions = - [ - { # only start if a keyholder opened the door and if the lounge mpd is currently not playing anything - condition = "template"; - value_template = "{{ state('sensor.keyholder') != 'No Keyholder' }}"; - } - { - condition = "state"; - entity_id = "media_player.lounge"; - state = "idle"; - } - ]; - }; - action = [ - { - service = "media_player.volume_set"; - data = { +{ + services.home-assistant.config.automation = + [ + { + alias = "Bedanken bei Übernahme von Key"; + initial_state = true; + trigger = { + platform = "state"; + entity_id = "sensor.keyholder"; + }; + condition = { + condition = "template"; + value_template = "{{ (trigger.from_state.state != 'No Keyholder') and (trigger.from_state.state != 'No Keyholder') }}"; + }; + action = glados.say.kiosk "Danke {{ trigger.to_state.state }} für das Übernehmen des Keys von {{ trigger.from_state.state }}"; + } + { + alias = "Keyholder Begrüßen wenn MPD hoch fährt"; + initial_state = true; + trigger = { + platform = "state"; + from = "unavailable"; + entity_id = "media_player.kiosk"; + }; + action = glados.say.kiosk (builtins.readFile ./announcement.j2); + } + { + alias = "Start Music on portal lock on"; + trigger = { + platform = "state"; + entity_id = "binary_sensor.portal_lock"; + to = "on"; + for.seconds = 30; + }; + condition = { + condition = "and"; + conditions = + [ + { # only start if a keyholder opened the door and if the lounge mpd is currently not playing anything + condition = "template"; + value_template = "{{ state('sensor.keyholder') != 'No Keyholder' }}"; + } + { + condition = "state"; entity_id = "media_player.lounge"; - volume_level = 1.0; - }; - } - { - service = "media_player.play_media"; - data = { - entity_id = "media_player.lounge"; - media_content_type = "playlist"; - media_content_id = "ansage"; - }; - } - { delay.seconds = 8.5; } - { - service = "media_player.volume_set"; - data = { - entity_id = "media_player.lounge"; - volume_level = 0.6; - }; - } - { - service = "media_player.play_media"; - data = { - entity_id = "media_player.lounge"; - media_content_type = "playlist"; - media_content_id = "lassulus"; - }; - } - ]; - } -] + state = "idle"; + } + ]; + }; + action = [ + { + service = "media_player.volume_set"; + data = { + entity_id = "media_player.lounge"; + volume_level = 1.0; + }; + } + { + service = "media_player.play_media"; + data = { + entity_id = "media_player.lounge"; + media_content_type = "playlist"; + media_content_id = "ansage"; + }; + } + { delay.seconds = 8.5; } + { + service = "media_player.volume_set"; + data = { + entity_id = "media_player.lounge"; + volume_level = 0.6; + }; + } + { + service = "media_player.play_media"; + data = { + entity_id = "media_player.lounge"; + media_content_type = "playlist"; + media_content_id = "lassulus"; + }; + } + ]; + } + ]; +} diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index 04843cb2..d546564c 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -1,9 +1,5 @@ { config, pkgs, lib, ... }: let - shackopen = import ./multi/shackopen.nix; - wasser = import ./multi/wasser.nix; - badair = import ./multi/schlechte_luft.nix; - rollos = import ./multi/rollos.nix; in { services.nginx.virtualHosts."hass.shack" = { serverAliases = [ "glados.shack" ]; @@ -21,14 +17,28 @@ in { ''; }; }; + imports = [ + ./multi/shackopen.nix + ./multi/wasser.nix + ./multi/schlechte_luft.nix + ./multi/rollos.nix + + ./switch/power.nix + + ./sensors/power.nix + ./sensors/mate.nix + ./sensors/darksky.nix + ./sensors/spaceapi.nix + ./sensors/sensemap.nix + + ./automation/shack-startup.nix + ./automation/party-time.nix + ./automation/hass-restart.nix + + ]; services.home-assistant = { enable = true; - package = pkgs.home-assistant.override { - extraPackages = ps: with ps; [ - python-forecastio jsonrpc-async jsonrpc-websocket mpd2 pkgs.picotts - ]; - }; autoExtraComponents = true; config = { homeassistant = { @@ -85,9 +95,6 @@ in { retain = true; }; }; - switch = - (import ./switch/power.nix) - ; light = []; media_player = [ { platform = "mpd"; @@ -100,34 +107,23 @@ in { } ]; - sensor = - (import ./sensors/power.nix) - ++ (import ./sensors/mate.nix) - ++ (import ./sensors/darksky.nix { inherit lib;}) - ++ shackopen.sensor - ++ wasser.sensor - ; - air_quality = (import ./sensors/sensemap.nix ); - - binary_sensor = - shackopen.binary_sensor - ++ (import ./sensors/spaceapi.nix) - ; - camera = []; - frontend = { }; config = { }; + sun = {}; http = { base_url = "http://hass.shack"; use_x_forwarded_for = true; trusted_proxies = "127.0.0.1"; }; #conversation = {}; - # history = {}; - #logbook = {}; - logger.default = "info"; + + history = {}; + logbook = {}; #recorder = {}; + + logger.default = "info"; + tts = [ { platform = "google_translate"; service_name = "say"; @@ -136,15 +132,6 @@ in { time_memory = 57600; } ]; - sun = {}; - - automation = wasser.automation - ++ badair.automation - ++ rollos.automation - ++ (import ./automation/shack-startup.nix) - ++ (import ./automation/party-time.nix) - ++ (import ./automation/hass-restart.nix); - device_tracker = []; }; }; diff --git a/krebs/2configs/shack/glados/multi/rollos.nix b/krebs/2configs/shack/glados/multi/rollos.nix index 4e649493..29525ad8 100644 --- a/krebs/2configs/shack/glados/multi/rollos.nix +++ b/krebs/2configs/shack/glados/multi/rollos.nix @@ -11,46 +11,49 @@ let ]; in { - automation = - [ - { alias = "Rollos fahren Runter"; - trigger = [ - { - platform = "numeric_state"; - entity_id = tempsensor; - above = 25; - for = "00:30:00"; - } - ]; - condition = - [ + services.home-assistant.config = + { + automation = + [ + { alias = "Rollos fahren Runter"; + trigger = [ { - condition = "state"; - entity_id = "sun.sun"; - state = "above_horizon"; - } - ]; - action = - [ - { service = "cover.close_cover"; - entity_id = all_covers; + platform = "numeric_state"; + entity_id = tempsensor; + above = 25; + for = "00:30:00"; } ]; - } - { alias = "Rollos fahren Hoch"; - trigger = [ - { - platform = "sun"; - event = "sunset"; - } - ]; - condition = [ ]; - action = - [ - { service = "cover.open_cover"; - entity_id = all_covers; + condition = + [ + { + condition = "state"; + entity_id = "sun.sun"; + state = "above_horizon"; + } + ]; + action = + [ + { service = "cover.close_cover"; + entity_id = all_covers; + } + ]; + } + { alias = "Rollos fahren Hoch"; + trigger = [ + { + platform = "sun"; + event = "sunset"; } ]; - } - ]; + condition = [ ]; + action = + [ + { service = "cover.open_cover"; + entity_id = all_covers; + } + ]; + } + ]; + }; } diff --git a/krebs/2configs/shack/glados/multi/schlechte_luft.nix b/krebs/2configs/shack/glados/multi/schlechte_luft.nix index 31373d7b..c1890361 100644 --- a/krebs/2configs/shack/glados/multi/schlechte_luft.nix +++ b/krebs/2configs/shack/glados/multi/schlechte_luft.nix @@ -4,103 +4,106 @@ let ledring = "light.fablab_led_ring"; in { - automation = - [ - { alias = "Gute Luft Fablab"; - trigger = [ - { - platform = "numeric_state"; - entity_id = feinstaub_sensor; - below = 3; - } - ]; - action = - [ - { service = "light.turn_on"; - data = { - entity_id = ledring; - effect = "Twinkle"; - color_name = "green"; - }; + services.home-assistant.config = + { + automation = + [ + { alias = "Gute Luft Fablab"; + trigger = [ + { + platform = "numeric_state"; + entity_id = feinstaub_sensor; + below = 3; } ]; - } - { alias = "mäßige Luft Fablab"; - trigger = [ - { - platform = "numeric_state"; - above = 3; - below = 10; - entity_id = feinstaub_sensor; - } - ]; - action = - [ - { service = "light.turn_on"; - data = { - entity_id = ledring; - effect = "Twinkle"; - color_name = "yellow"; - }; + action = + [ + { service = "light.turn_on"; + data = { + entity_id = ledring; + effect = "Twinkle"; + color_name = "green"; + }; + } + ]; + } + { alias = "mäßige Luft Fablab"; + trigger = [ + { + platform = "numeric_state"; + above = 3; + below = 10; + entity_id = feinstaub_sensor; } ]; - } - { alias = "schlechte Luft Fablab"; - trigger = [ - { - platform = "numeric_state"; - above = 10; - entity_id = feinstaub_sensor; - } - ]; - action = - [ - { service = "light.turn_on"; - data = { - entity_id = ledring; - effect = "Fireworks"; - color_name = "red"; - }; + action = + [ + { service = "light.turn_on"; + data = { + entity_id = ledring; + effect = "Twinkle"; + color_name = "yellow"; + }; + } + ]; + } + { alias = "schlechte Luft Fablab"; + trigger = [ + { + platform = "numeric_state"; + above = 10; + entity_id = feinstaub_sensor; } ]; - } - { alias = "Luft Sensor nicht verfügbar"; - trigger = [ - { - platform = "state"; - to = "unavailable"; - entity_id = feinstaub_sensor; - } - ]; - action = - [ - { service = "light.turn_on"; - data = { - entity_id = ledring; - effect = "Rainbow"; - color_name = "blue"; - }; + action = + [ + { service = "light.turn_on"; + data = { + entity_id = ledring; + effect = "Fireworks"; + color_name = "red"; + }; + } + ]; + } + { alias = "Luft Sensor nicht verfügbar"; + trigger = [ + { + platform = "state"; + to = "unavailable"; + entity_id = feinstaub_sensor; } ]; - } - { alias = "Fablab Licht Reboot"; - trigger = [ - { - platform = "state"; - from = "unavailable"; - entity_id = ledring; - } - ]; - action = - [ - { service = "light.turn_on"; - data = { - entity_id = ledring; - effect = "Rainbow"; - color_name = "orange"; - }; + action = + [ + { service = "light.turn_on"; + data = { + entity_id = ledring; + effect = "Rainbow"; + color_name = "blue"; + }; + } + ]; + } + { alias = "Fablab Licht Reboot"; + trigger = [ + { + platform = "state"; + from = "unavailable"; + entity_id = ledring; } ]; - } - ]; + action = + [ + { service = "light.turn_on"; + data = { + entity_id = ledring; + effect = "Rainbow"; + color_name = "orange"; + }; + } + ]; + } + ]; + }; } diff --git a/krebs/2configs/shack/glados/multi/shackopen.nix b/krebs/2configs/shack/glados/multi/shackopen.nix index 354405d0..d9be9adf 100644 --- a/krebs/2configs/shack/glados/multi/shackopen.nix +++ b/krebs/2configs/shack/glados/multi/shackopen.nix @@ -1,23 +1,26 @@ { - binary_sensor = [ - { platform = "mqtt"; - name = "Portal Lock"; - device_class = "door"; - state_topic = "portal/gateway/status"; - availability_topic = "portal/gateway/lwt"; - payload_on = "open"; - payload_off = "closed"; - payload_available = "online"; - payload_not_available = "offline"; - } - ]; - sensor = [ - { platform = "mqtt"; - name = "Keyholder"; - state_topic = "portal/gateway/keyholder"; - availability_topic = "portal/gateway/lwt"; - payload_available = "online"; - payload_not_available = "offline"; - } - ]; + services.home-assistant.config = + { + binary_sensor = [ + { platform = "mqtt"; + name = "Portal Lock"; + device_class = "door"; + state_topic = "portal/gateway/status"; + availability_topic = "portal/gateway/lwt"; + payload_on = "open"; + payload_off = "closed"; + payload_available = "online"; + payload_not_available = "offline"; + } + ]; + sensor = [ + { platform = "mqtt"; + name = "Keyholder"; + state_topic = "portal/gateway/keyholder"; + availability_topic = "portal/gateway/lwt"; + payload_available = "online"; + payload_not_available = "offline"; + } + ]; + }; } diff --git a/krebs/2configs/shack/glados/multi/wasser.nix b/krebs/2configs/shack/glados/multi/wasser.nix index bd8252e1..9ca5e450 100644 --- a/krebs/2configs/shack/glados/multi/wasser.nix +++ b/krebs/2configs/shack/glados/multi/wasser.nix @@ -11,100 +11,103 @@ let }; in { - sensor = map ( entity_id: { - platform = "statistics"; - name = "Statistics for ${entity_id}"; - inherit entity_id; - max_age.minutes = "60"; - sampling_size = 1000; - }) ["sensor.crafting_brotbox_soil_moisture"]; + services.home-assistant.config = + { + sensor = map ( entity_id: { + platform = "statistics"; + name = "Statistics for ${entity_id}"; + inherit entity_id; + max_age.minutes = "60"; + sampling_size = 1000; + }) ["sensor.crafting_brotbox_soil_moisture"]; - automation = - [ - ### Brotbox ##### - #{ alias = "Brotbox: water for ${toString brotbox.minutes} minutes every hour"; - # trigger = - # { # Trigger once every hour at :42 - # platform = "time_pattern"; - # minutes = 42; - # }; - # condition = { - # condition = "numeric_state"; - # entity_id = brotbox.sensor; - # value_template = "{{ state_attr('${brotbox.sensor}', 'median') }}"; - # below = 75; - # }; - # action = - # [ - # { - # service = "homeassistant.turn_on"; - # entity_id = brotbox.pump; - # } - # { delay.minutes = brotbox.minutes; } - # { - # service = "homeassistant.turn_off"; - # entity_id = brotbox.pump ; - # } - # ]; - #} - { alias = "Brotbox: Always turn off water after ${toString (brotbox.minutes * 2)} minutes"; - trigger = - { - platform = "state"; - entity_id = brotbox.pump; - to = "on"; - for.minutes = brotbox.minutes*2; - }; - action = - { - service = "homeassistant.turn_off"; - entity_id = brotbox.pump; - }; - } - - ##### Kaffeemaschine - { alias = "Water the plant for ${toString seconds} seconds"; - trigger = [ - { # trigger at 20:00 no matter what - # TODO: retry or run only if switch.wasser is available - platform = "time"; - at = "20:00:00"; - } - ]; - action = - [ - { - service = "homeassistant.turn_on"; - entity_id = [ - wasser - ]; - } - { delay.seconds = seconds; } - { - service = "homeassistant.turn_off"; - entity_id = [ - wasser - ]; - } - ]; - } - { alias = "Always turn off water after ${toString (seconds * 2)}seconds"; - trigger = [ + automation = + [ + ### Brotbox ##### + #{ alias = "Brotbox: water for ${toString brotbox.minutes} minutes every hour"; + # trigger = + # { # Trigger once every hour at :42 + # platform = "time_pattern"; + # minutes = 42; + # }; + # condition = { + # condition = "numeric_state"; + # entity_id = brotbox.sensor; + # value_template = "{{ state_attr('${brotbox.sensor}', 'median') }}"; + # below = 75; + # }; + # action = + # [ + # { + # service = "homeassistant.turn_on"; + # entity_id = brotbox.pump; + # } + # { delay.minutes = brotbox.minutes; } + # { + # service = "homeassistant.turn_off"; + # entity_id = brotbox.pump ; + # } + # ]; + #} + { alias = "Brotbox: Always turn off water after ${toString (brotbox.minutes * 2)} minutes"; + trigger = { platform = "state"; - entity_id = wasser; + entity_id = brotbox.pump; to = "on"; - for.seconds = seconds*2; - } - ]; - action = - [ + for.minutes = brotbox.minutes*2; + }; + action = { service = "homeassistant.turn_off"; - entity_id = [ wasser ]; - } - ]; - } - ]; + entity_id = brotbox.pump; + }; + } + + ##### Kaffeemaschine + { alias = "Water the plant for ${toString seconds} seconds"; + trigger = [ + { # trigger at 20:00 no matter what + # TODO: retry or run only if switch.wasser is available + platform = "time"; + at = "20:00:00"; + } + ]; + action = + [ + { + service = "homeassistant.turn_on"; + entity_id = [ + wasser + ]; + } + { delay.seconds = seconds; } + { + service = "homeassistant.turn_off"; + entity_id = [ + wasser + ]; + } + ]; + } + { alias = "Always turn off water after ${toString (seconds * 2)}seconds"; + trigger = [ + { + platform = "state"; + entity_id = wasser; + to = "on"; + for.seconds = seconds*2; + } + ]; + action = + [ + { + service = "homeassistant.turn_off"; + entity_id = [ wasser ]; + } + ]; + } + ]; + }; } diff --git a/krebs/2configs/shack/glados/sensors/darksky.nix b/krebs/2configs/shack/glados/sensors/darksky.nix index c8725b86..12b33804 100644 --- a/krebs/2configs/shack/glados/sensors/darksky.nix +++ b/krebs/2configs/shack/glados/sensors/darksky.nix @@ -1,21 +1,24 @@ {lib,...}: -[ - { platform = "darksky"; - api_key = lib.removeSuffix "\n" - (builtins.readFile ); - language = "de"; - monitored_conditions = [ - "summary" "icon" - "nearest_storm_distance" "precip_probability" - "precip_intensity" - "temperature" # "temperature_high" "temperature_low" - "apparent_temperature" - "hourly_summary" # next 24 hours text - "humidity" - "pressure" - "uv_index" - ]; - units = "si" ; - scan_interval = "00:15:00"; - } -] +{ + services.home-assistant.config.sensor = + [ + { platform = "darksky"; + api_key = lib.removeSuffix "\n" + (builtins.readFile ); + language = "de"; + monitored_conditions = [ + "summary" "icon" + "nearest_storm_distance" "precip_probability" + "precip_intensity" + "temperature" # "temperature_high" "temperature_low" + "apparent_temperature" + "hourly_summary" # next 24 hours text + "humidity" + "pressure" + "uv_index" + ]; + units = "si" ; + scan_interval = "00:15:00"; + } + ]; +} diff --git a/krebs/2configs/shack/glados/sensors/mate.nix b/krebs/2configs/shack/glados/sensors/mate.nix index 1bb0e71e..75185666 100644 --- a/krebs/2configs/shack/glados/sensors/mate.nix +++ b/krebs/2configs/shack/glados/sensors/mate.nix @@ -6,11 +6,15 @@ let name = "Füllstand ${name}"; value_template = "{{ value_json.fuellstand }}"; }; -in [ - (fuellstand "Wasser" 1) - (fuellstand "Mate Cola" 2) - (fuellstand "Apfelschorle" 3) - (fuellstand "Zitronensprudel" 4) - (fuellstand "Mate 1" 26) - (fuellstand "Mate 2" 27) -] +in +{ + services.home-assistant.config.sensor = + [ + (fuellstand "Wasser" 1) + (fuellstand "Mate Cola" 2) + (fuellstand "Apfelschorle" 3) + (fuellstand "Zitronensprudel" 4) + (fuellstand "Mate 1" 26) + (fuellstand "Mate 2" 27) + ]; +} diff --git a/krebs/2configs/shack/glados/sensors/power.nix b/krebs/2configs/shack/glados/sensors/power.nix index b168f2be..d9b5c7c6 100644 --- a/krebs/2configs/shack/glados/sensors/power.nix +++ b/krebs/2configs/shack/glados/sensors/power.nix @@ -20,7 +20,10 @@ let power_watt = (power_x "Power") ; power_curr = power_x "Current"; in +{ + services.home-assistant.config.sensor = (map power_volt [ "L1" "L2" "L3" ]) ++ (map (x: ((power_watt x) // { device_class = "power"; })) [ "L1" "L2" "L3" ]) ++ (map power_curr [ "L1" "L2" "L3" ]) -++ [ power_consumed ] +++ [ power_consumed ]; +} diff --git a/krebs/2configs/shack/glados/sensors/sensemap.nix b/krebs/2configs/shack/glados/sensors/sensemap.nix index dff29c3c..c261a28e 100644 --- a/krebs/2configs/shack/glados/sensors/sensemap.nix +++ b/krebs/2configs/shack/glados/sensors/sensemap.nix @@ -1,6 +1,9 @@ -[ - { - platform = "opensensemap"; - station_id = "56a0de932cb6e1e41040a68b"; - } -] +{ + services.home-assistant.config.air_quality = + [ + { + platform = "opensensemap"; + station_id = "56a0de932cb6e1e41040a68b"; + } + ]; +} diff --git a/krebs/2configs/shack/glados/sensors/spaceapi.nix b/krebs/2configs/shack/glados/sensors/spaceapi.nix index 11cab11c..ea20ad29 100644 --- a/krebs/2configs/shack/glados/sensors/spaceapi.nix +++ b/krebs/2configs/shack/glados/sensors/spaceapi.nix @@ -1,52 +1,55 @@ -[ - { - platform = "rest"; - resource = "https://spaceapi.afra-berlin.de/v1/status.json"; - method = "GET"; - name = "Door AFRA Berlin"; - device_class = "door"; - value_template = "{{ value_json.open }}"; - } - { - platform = "rest"; - resource = "http://club.entropia.de/spaceapi"; - method = "GET"; - name = "Door Entropia"; - device_class = "door"; - value_template = "{{ value_json.open }}"; - } - { - platform = "rest"; - resource = "http://www.c-base.org/status.json"; - method = "GET"; - name = "Door C-Base Berlin"; - device_class = "door"; - value_template = "{{ value_json.open }}"; - } - { - platform = "rest"; - resource = "https://status.raumzeitlabor.de/api/full.json"; - method = "GET"; - name = "Door RZL"; - device_class = "door"; - value_template = "{{ value_json.status }}"; - } - { - platform = "rest"; - resource = "https://datenobservatorium.de/"; - method = "GET"; - name = "Door Datenobservatorium"; - device_class = "door"; - value_template = "false"; - scan_interval = 2592000; - } - { - platform = "rest"; - resource = "https://infuanfu.de/"; - method = "GET"; - name = "Door Infuanfu"; - device_class = "door"; - value_template = "false"; - scan_interval = 2592000; - } -] +{ + services.home-assistant.config.binary_sensor = + [ + { + platform = "rest"; + resource = "https://spaceapi.afra-berlin.de/v1/status.json"; + method = "GET"; + name = "Door AFRA Berlin"; + device_class = "door"; + value_template = "{{ value_json.open }}"; + } + { + platform = "rest"; + resource = "http://club.entropia.de/spaceapi"; + method = "GET"; + name = "Door Entropia"; + device_class = "door"; + value_template = "{{ value_json.open }}"; + } + { + platform = "rest"; + resource = "http://www.c-base.org/status.json"; + method = "GET"; + name = "Door C-Base Berlin"; + device_class = "door"; + value_template = "{{ value_json.open }}"; + } + { + platform = "rest"; + resource = "https://status.raumzeitlabor.de/api/full.json"; + method = "GET"; + name = "Door RZL"; + device_class = "door"; + value_template = "{{ value_json.status }}"; + } + { + platform = "rest"; + resource = "https://datenobservatorium.de/"; + method = "GET"; + name = "Door Datenobservatorium"; + device_class = "door"; + value_template = "false"; + scan_interval = 2592000; + } + { + platform = "rest"; + resource = "https://infuanfu.de/"; + method = "GET"; + name = "Door Infuanfu"; + device_class = "door"; + value_template = "false"; + scan_interval = 2592000; + } + ]; +} diff --git a/krebs/2configs/shack/glados/switch/power.nix b/krebs/2configs/shack/glados/switch/power.nix index 4e9a45c2..9ec115fa 100644 --- a/krebs/2configs/shack/glados/switch/power.nix +++ b/krebs/2configs/shack/glados/switch/power.nix @@ -15,18 +15,30 @@ let power = nodelight "power"; light = ident: name: { icon = "mdi:lightbulb";} // nodelight "light" ident name; in -[ - (power 1 "Hauptschalter") - (power 2 "Dusche") - (power 3 "Warmwasser") - (power 4 "Optionsräume") - (power 5 "Küche") - (light 1 "Decke Lounge 1") - (light 2 "Decke Lounge 2") - (light 3 "Decke Lounge 3") - (light 4 "Decke Lounge 4") - (light 5 "Decke Lounge 5") - (light 6 "Decke Lounge 6") - (light 7 "Decke Lounge 7") - (light 8 "Decke Lounge 8") -] +{ + services.home-assistant.config.switch = + [ + # These commands we see with a shutdown: + # power/143/state on + # power/142/state on + # power/141/state on + # power/142/state off + # power/141/state off + # power/10/state off + # power/main/state off + + (power "10" "Hauptschalter") + (power 1 "Dusche") # ??? + (power 2 "Warmwasser") # ??? + (power 3 "Optionsräume") # ??? + (power 4 "Küche") # ??? + (light 1 "Decke Lounge 1") + (light 2 "Decke Lounge 2") + (light 3 "Decke Lounge 3") + (light 4 "Decke Lounge 4") + (light 5 "Decke Lounge 5") + (light 6 "Decke Lounge 6") + (light 7 "Decke Lounge 7") + (light 8 "Decke Lounge 8") + ]; +} -- cgit v1.2.3