diff options
author | lassulus <lassulus@lassul.us> | 2020-03-23 10:15:42 +0100 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2020-03-23 10:15:42 +0100 |
commit | 8c27f12f86096f06e56333125eb6c713aece34ed (patch) | |
tree | 83d29ab23719468ff6e8d31f29963dd449edbef2 | |
parent | cab3be8a19d445d3292454099dbc1ca97bca60c5 (diff) | |
parent | 8e3cd9fcffc473706a3ebafa5cb80f7a75c29aa5 (diff) |
Merge remote-tracking branch 'gum/master'
84 files changed, 1634 insertions, 692 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3ff991aa4..4a7a4e605 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ before_script: # prepare git fetching of secrets - echo "$gitlab_deploy_privkey" > ~/.ssh/gitlab_deploy.key - chmod 600 ~/.ssh/gitlab_deploy.key - - ssh-keyscan -H 'ssh.git.shackspace.de' >> ~/.ssh/known_hosts + - echo "$ssh_git_shackspace_serverkey" >> ~/.ssh/known_hosts # import secret key for secrets - echo "$secrets_gpg_key" | gpg --import deployment test: diff --git a/krebs/0tests/data/secrets/hass/darksky.apikey b/krebs/0tests/data/secrets/hass/darksky.apikey new file mode 100644 index 000000000..4932cd639 --- /dev/null +++ b/krebs/0tests/data/secrets/hass/darksky.apikey @@ -0,0 +1 @@ +LOL 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; + |