diff options
Diffstat (limited to 'krebs/2configs')
-rw-r--r-- | krebs/2configs/shack/glados/automation/hass-restart.nix | 3 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/automation/shack-startup.nix | 82 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/default.nix | 47 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/lib/default.nix | 119 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/multi/rollos.nix | 13 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/multi/schlechte_luft.nix | 14 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/darksky.nix | 21 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/hass.nix | 5 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/mate.nix | 16 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/power.nix | 7 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/sensemap.nix | 6 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/spaceapi.nix | 52 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/unifi.nix | 6 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/switch/power.nix | 32 | ||||
-rw-r--r-- | krebs/2configs/shack/muellshack.nix | 5 | ||||
-rw-r--r-- | krebs/2configs/shack/node-light.nix | 6 |
16 files changed, 313 insertions, 121 deletions
diff --git a/krebs/2configs/shack/glados/automation/hass-restart.nix b/krebs/2configs/shack/glados/automation/hass-restart.nix index e87354978..1b380204d 100644 --- a/krebs/2configs/shack/glados/automation/hass-restart.nix +++ b/krebs/2configs/shack/glados/automation/hass-restart.nix @@ -6,12 +6,13 @@ platform = "homeassistant"; event = "start"; }; + # trigger good/bad air action = [ { service = "light.turn_on"; data = { entity_id = "light.fablab_led"; effect = "Rainbow"; - color_name = "yellow"; + color_name = "purple"; }; } ]; diff --git a/krebs/2configs/shack/glados/automation/shack-startup.nix b/krebs/2configs/shack/glados/automation/shack-startup.nix new file mode 100644 index 000000000..35314923b --- /dev/null +++ b/krebs/2configs/shack/glados/automation/shack-startup.nix @@ -0,0 +1,82 @@ +# needs: +# binary_sensor.portal_lock +# sensor.keyholder +# media_player.lounge +let + glados = import ../lib; +in +[ + { + alias = "Greet new keyholder for key exchange"; + initial_state = true; + trigger = { + platform = "state"; + entity_id = "sensor.keyholder"; + }; + condition = { + condition = "template"; + value_template = "{{ 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}}"; + # action = []; + } + + { + alias = "Start Music on portal lock on"; + # TODO: use "power" trigger + 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 = { + 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; } + { + 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 superradio"; + }; + } + ]; + } +] diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index e48a54551..920f2ed2f 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -39,7 +39,7 @@ in { ''; })).override { extraPackages = ps: with ps; [ - python-forecastio jsonrpc-async jsonrpc-websocket mpd2 + python-forecastio jsonrpc-async jsonrpc-websocket mpd2 pkgs.picotts ]; }; autoExtraComponents = true; @@ -76,6 +76,8 @@ in { client_id = "home-assistant"; keepalive = 60; protocol = 3.1; + discovery = true; #enable esphome discovery + discovery_prefix = "homeassistant"; birth_message = { topic = "glados/hass/status/LWT"; payload = "Online"; @@ -89,21 +91,34 @@ in { retain = true; }; }; - switch = wasser.switch; - light = badair.light; + switch = + wasser.switch + ++ (import ./switch/power.nix) + ; + light = []; media_player = [ { platform = "mpd"; + name = "lounge"; host = "lounge.mpd.shack"; } + { platform = "mpd"; + name = "kiosk"; + host = "lounge.kiosk.shack"; + } ]; sensor = - (import ./sensors/hass.nix) - ++ (import ./sensors/power.nix) + (import ./sensors/power.nix) + ++ (import ./sensors/mate.nix) + ++ (import ./sensors/darksky.nix { inherit lib;}) ++ shackopen.sensor - ++ badair.sensor; + ; + air_quality = (import ./sensors/sensemap.nix ); - binary_sensor = shackopen.binary_sensor; + binary_sensor = + shackopen.binary_sensor + ++ (import ./sensors/spaceapi.nix) + ; camera = []; @@ -117,19 +132,27 @@ in { #conversation = {}; history = {}; logbook = {}; + logger = { + default = "info"; + }; recorder = {}; tts = [ { platform = "google_translate"; + service_name = "say"; language = "de"; + cache = true; + time_memory = 57600; + } + { platform = "picotts"; + language = "de-DE"; + service_name = "pico"; } - #{ platform = "picotts"; - # language = "de-DE"; - #} ]; sun = {}; - automation = wasser.automation - ++ badair.automation + automation = wasser.automation + ++ badair.automation + ++ (import ./automation/shack-startup.nix) ++ (import ./automation/hass-restart.nix); device_tracker = []; diff --git a/krebs/2configs/shack/glados/lib/default.nix b/krebs/2configs/shack/glados/lib/default.nix index 6737af842..6d2b7749b 100644 --- a/krebs/2configs/shack/glados/lib/default.nix +++ b/krebs/2configs/shack/glados/lib/default.nix @@ -2,89 +2,48 @@ let prefix = "glados"; in { - esphome = + + say = let + # returns a list of actions to be performed on an mpd to say something + tts = { message, entity }: + [ + { + service = "media_player.turn_on"; + data.entity_id = "media_player.${entity}"; + } + { service = "media_player.play_media"; + data = { + entity_id = "media_player.${entity}"; + media_content_type = "playlist"; + media_content_id = "ansage"; + }; + } + { + service = "media_player.turn_on"; + data.entity_id = "media_player.${entity}"; + } + { delay.seconds = 8; } + { service = "tts.say"; + entity_id = "media_player.${entity}"; + data_template = { + inherit message; + language = "de"; + }; + } + ]; + in { - temp = {host, topic ? "temperature" }: - { - platform = "mqtt"; - name = "${host} Temperature"; - device_class = "temperature"; - unit_of_measurement = "°C"; - icon = "mdi:thermometer"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - }; - hum = {host, topic ? "humidity" }: - { - platform = "mqtt"; - unit_of_measurement = "%"; - icon = "mdi:water-percent"; - device_class = "humidity"; - name = "${host} Humidity"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; + lounge = message: tts { + inherit message; + entity = "lounge"; }; - # copied from "homeassistant/light/fablab_led/led_ring/config" - led = {host, topic ? "led", name ? host}: - { # name: fablab_led - # topic: led_ring - platform = "mqtt"; - inherit name; - schema = "json"; - brightness = true; - rgb = true; - effect = true; - effect_list = [ # TODO: may be different - "Random" - "Strobe" - "Rainbow" - "Color Wipe" - "Scan" - "Twinkle" - "Fireworks" - "Addressable Flicker" - "None" - ]; - state_topic = "${prefix}/${host}/light/${topic}/state"; - command_topic = "${prefix}/${host}/light/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - payload_available = "online"; - payload_not_available = "offline"; - qos = 1; + herrenklo = message: tts { + inherit message; + entity = "herrenklo"; }; - # Feinstaub - dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }: - { - platform = "mqtt"; - unit_of_measurement = "µg/m³"; - icon = "mdi:chemical-weapon"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - dust_100m = {host, name ? "${host} < 10µm", topic ? "particulate_matter_100m_concentration" }: - { - platform = "mqtt"; - unit_of_measurement = "µg/m³"; - icon = "mdi:chemical-weapon"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - switch = {host, name ? "${host} Button", topic ? "btn" }: - # host: ampel - # name: Button 1 - # topic: btn1 - { - inherit name; - platform = "mqtt"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - command_topic = "${prefix}/${host}/switch/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; + kiosk = message: tts { + inherit message; + entity = "kiosk"; }; }; tasmota = diff --git a/krebs/2configs/shack/glados/multi/rollos.nix b/krebs/2configs/shack/glados/multi/rollos.nix new file mode 100644 index 000000000..1febad525 --- /dev/null +++ b/krebs/2configs/shack/glados/multi/rollos.nix @@ -0,0 +1,13 @@ +let + glados = import ../lib; +in +{ + # LED + light = [ + ]; + sensor = [ + ]; + automation = + [ + ]; +} diff --git a/krebs/2configs/shack/glados/multi/schlechte_luft.nix b/krebs/2configs/shack/glados/multi/schlechte_luft.nix index 9cd2c56f4..529454a41 100644 --- a/krebs/2configs/shack/glados/multi/schlechte_luft.nix +++ b/krebs/2configs/shack/glados/multi/schlechte_luft.nix @@ -2,20 +2,6 @@ let glados = import ../lib; in { - # LED - light = [ - (glados.esphome.led { name = "Fablab LED"; host = "fablab_led"; topic = "led_ring"; }) - - (glados.esphome.led { name = "Fablab LED Part A"; host = "fablab_led"; topic = "A";}) - (glados.esphome.led { name = "Fablab LED Part B"; host = "fablab_led"; topic = "B";}) - (glados.esphome.led { name = "Fablab LED Part C"; host = "fablab_led"; topic = "C";}) - (glados.esphome.led { name = "Fablab LED Part D"; host = "fablab_led"; topic = "D";}) - ]; - sensor = [ - (glados.esphome.temp { host = "fablab_feinstaub";}) - (glados.esphome.dust_25m { host = "fablab_feinstaub";}) - (glados.esphome.dust_100m { host = "fablab_feinstaub";}) - ]; automation = [ { alias = "Gute Luft Fablab"; diff --git a/krebs/2configs/shack/glados/sensors/darksky.nix b/krebs/2configs/shack/glados/sensors/darksky.nix new file mode 100644 index 000000000..c8725b868 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/darksky.nix @@ -0,0 +1,21 @@ +{lib,...}: +[ + { platform = "darksky"; + api_key = lib.removeSuffix "\n" + (builtins.readFile <secrets/hass/darksky.apikey>); + 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/hass.nix b/krebs/2configs/shack/glados/sensors/hass.nix deleted file mode 100644 index 8de0ef391..000000000 --- a/krebs/2configs/shack/glados/sensors/hass.nix +++ /dev/null @@ -1,5 +0,0 @@ -let - glados = import ../lib; -in - (map (host: glados.esphome.temp {inherit host;}) [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ]) - ++ (map (host: glados.esphome.hum {inherit host;}) [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ]) diff --git a/krebs/2configs/shack/glados/sensors/mate.nix b/krebs/2configs/shack/glados/sensors/mate.nix new file mode 100644 index 000000000..1bb0e71eb --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/mate.nix @@ -0,0 +1,16 @@ +let + fuellstand = name: id: { + platform = "rest"; + resource = "https://ora5.tutschonwieder.net/ords/lick_prod/v1/get/fuellstand/1/${toString id}"; + method = "GET"; + 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) +] diff --git a/krebs/2configs/shack/glados/sensors/power.nix b/krebs/2configs/shack/glados/sensors/power.nix index 1aa250a19..b168f2beb 100644 --- a/krebs/2configs/shack/glados/sensors/power.nix +++ b/krebs/2configs/shack/glados/sensors/power.nix @@ -2,7 +2,6 @@ let power_x = name: phase: { platform = "mqtt"; name = "${phase} ${name}"; - # device_class = "power"; state_topic = "/power/total/${phase}/${name}"; availability_topic = "/power/lwt"; payload_available = "Online"; @@ -11,17 +10,17 @@ let power_consumed = { platform = "mqtt"; name = "Power Consumed"; - #device_class = "power"; + device_class = "power"; state_topic = "/power/total/consumed"; availability_topic = "/power/lwt"; payload_available = "Online"; payload_not_available = "Offline"; }; power_volt = power_x "Voltage"; - power_watt = power_x "Power"; + power_watt = (power_x "Power") ; power_curr = power_x "Current"; in (map power_volt [ "L1" "L2" "L3" ]) -++ (map power_watt [ "L1" "L2" "L3" ]) +++ (map (x: ((power_watt x) // { device_class = "power"; })) [ "L1" "L2" "L3" ]) ++ (map power_curr [ "L1" "L2" "L3" ]) ++ [ power_consumed ] diff --git a/krebs/2configs/shack/glados/sensors/sensemap.nix b/krebs/2configs/shack/glados/sensors/sensemap.nix new file mode 100644 index 000000000..dff29c3c4 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/sensemap.nix @@ -0,0 +1,6 @@ +[ + { + platform = "opensensemap"; + station_id = "56a0de932cb6e1e41040a68b"; + } +] diff --git a/krebs/2configs/shack/glados/sensors/spaceapi.nix b/krebs/2configs/shack/glados/sensors/spaceapi.nix new file mode 100644 index 000000000..11cab11c9 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/spaceapi.nix @@ -0,0 +1,52 @@ +[ + { + 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/sensors/unifi.nix b/krebs/2configs/shack/glados/sensors/unifi.nix new file mode 100644 index 000000000..f64e3feb6 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/unifi.nix @@ -0,0 +1,6 @@ +{ + controllers = { + host = "unifi.shack"; + site = "shackspace"; + }; +} diff --git a/krebs/2configs/shack/glados/switch/power.nix b/krebs/2configs/shack/glados/switch/power.nix new file mode 100644 index 000000000..4e9a45c28 --- /dev/null +++ b/krebs/2configs/shack/glados/switch/power.nix @@ -0,0 +1,32 @@ +# 1 - haupt +# 2 - dusche +# 3 - warmwasser +# 4 - or +# 5 - kueche +let + nodelight = type: ident: name: { + platform = "mqtt"; + name = "${type} ${name}"; + command_topic = "${type}/${toString ident}/command"; + state_topic = "${type}/${toString ident}/state"; + payload_on = "on"; + payload_off = "off"; + }; + 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") +] diff --git a/krebs/2configs/shack/muellshack.nix b/krebs/2configs/shack/muellshack.nix index c67d8f523..e894b9394 100644 --- a/krebs/2configs/shack/muellshack.nix +++ b/krebs/2configs/shack/muellshack.nix @@ -4,8 +4,9 @@ let pkg = pkgs.callPackage ( pkgs.fetchgit { url = "https://git.shackspace.de/rz/muellshack"; - rev = "c3d1f70325e5b90f280c5be60110e14f4de653ae"; - sha256 = "1dd4kqwdr4v413rmkvmyjzzvw8id9747nifp96pg0c2cy6bhzj24"; + rev = "dc80cf1edaa3d86ec2bebae8596ad1d4c4e3650a"; + sha256 = "1yipr66zhrg5m20pf3rzvgvvl78an6ddkq6zc45rxb2r0i7ipkyh"; + }) { mkYarnPackage = pkgs.yarn2nix-moretea.mkYarnPackage; }; home = "/var/lib/muellshack"; port = "8081"; diff --git a/krebs/2configs/shack/node-light.nix b/krebs/2configs/shack/node-light.nix index 9e3828463..b471f2af5 100644 --- a/krebs/2configs/shack/node-light.nix +++ b/krebs/2configs/shack/node-light.nix @@ -4,9 +4,9 @@ let pkg = pkgs.callPackage ( pkgs.fetchgit { url = "https://git.shackspace.de/rz/node-light.git"; - rev = "9c3fe451897cf170fb192a2643180fdfe22388e8"; - sha256 = "1zsc38idg452r8wpcna5m3yqx0ri11bd1bw60bl0kpz96dqqnyba"; - }) { mkYarnPackage = pkgs.yarn2nix-moretea.mkYarnPackage; }; + rev = "90a9347b73af3a9960bd992e6293b357226ef6a0"; + sha256 = "1av9w3w8aknlra25jw6gqxzbb01i9kdlfziy29lwz7mnryjayvwk"; + }) { }; home = "/var/lib/node-light"; port = "8082"; in { |