From 8b78d1e194162bb453200713bd0c5d21998aea09 Mon Sep 17 00:00:00 2001 From: makefu <github@syntax-fehler.de> Date: Wed, 12 Jul 2023 23:40:20 +0200 Subject: [PATCH] bam/home-assistant: remove in favor of docker --- 2configs/bam/automation/bureau-shutdown.nix | 87 -------- 2configs/bam/automation/daily-news.nix | 20 -- 2configs/bam/automation/hass-restart.nix | 34 --- 2configs/bam/automation/nachtlicht.nix | 38 ---- .../bam/automation/philosophische-tuer.nix | 100 --------- 2configs/bam/automation/quotes.nix | 4 - 2configs/bam/automation/schlechteluft.nix | 75 ------- 2configs/bam/camera/comic.nix | 13 -- 2configs/bam/camera/stuttgart.nix | 30 --- 2configs/bam/camera/verkehrskamera.nix | 17 -- 2configs/bam/deps/aresponses.nix | 38 ---- 2configs/bam/deps/openwrt-luci-rpc.nix | 34 --- 2configs/bam/device_tracker/openwrt.nix | 18 -- 2configs/bam/devices/users.nix | 17 -- 2configs/bam/light/buzzer.nix | 30 --- 2configs/bam/light/statuslight.nix | 58 ----- 2configs/bam/multi/10h_timers.nix | 210 ------------------ 2configs/bam/multi/aramark.nix | 27 --- 2configs/bam/multi/daily-standup.nix | 57 ----- 2configs/bam/multi/frosch.nix | 103 --------- 2configs/bam/multi/matrix.nix | 69 ------ 2configs/bam/multi/mittagessen.nix | 92 -------- 2configs/bam/script/multi_blink.nix | 60 ----- 23 files changed, 1231 deletions(-) delete mode 100644 2configs/bam/automation/bureau-shutdown.nix delete mode 100644 2configs/bam/automation/daily-news.nix delete mode 100644 2configs/bam/automation/hass-restart.nix delete mode 100644 2configs/bam/automation/nachtlicht.nix delete mode 100644 2configs/bam/automation/philosophische-tuer.nix delete mode 100644 2configs/bam/automation/quotes.nix delete mode 100644 2configs/bam/automation/schlechteluft.nix delete mode 100644 2configs/bam/camera/comic.nix delete mode 100644 2configs/bam/camera/stuttgart.nix delete mode 100644 2configs/bam/camera/verkehrskamera.nix delete mode 100644 2configs/bam/deps/aresponses.nix delete mode 100644 2configs/bam/deps/openwrt-luci-rpc.nix delete mode 100644 2configs/bam/device_tracker/openwrt.nix delete mode 100644 2configs/bam/devices/users.nix delete mode 100644 2configs/bam/light/buzzer.nix delete mode 100644 2configs/bam/light/statuslight.nix delete mode 100644 2configs/bam/multi/10h_timers.nix delete mode 100644 2configs/bam/multi/aramark.nix delete mode 100644 2configs/bam/multi/daily-standup.nix delete mode 100644 2configs/bam/multi/frosch.nix delete mode 100644 2configs/bam/multi/matrix.nix delete mode 100644 2configs/bam/multi/mittagessen.nix delete mode 100644 2configs/bam/script/multi_blink.nix diff --git a/2configs/bam/automation/bureau-shutdown.nix b/2configs/bam/automation/bureau-shutdown.nix deleted file mode 100644 index f4c10ad..0000000 --- a/2configs/bam/automation/bureau-shutdown.nix +++ /dev/null @@ -1,87 +0,0 @@ -{ - services.home-assistant.config.automation = - [ - { alias = "Turn on Fernseher on group home"; - trigger = { - platform = "state"; - entity_id = "group.team"; - from = "not_home"; - to = "home"; - for.seconds = 30; - }; - action = [ - { - service = "homeassistant.turn_on"; - entity_id = [ - "switch.fernseher" - "switch.feuer" - ]; - } - { - service = "media_player.kodi_call_method"; - data = { - entity_id = "media_player.kodi"; - method = "Player.Open"; - item.partymode = "music"; - }; - } - { - service = "notify.telegrambot"; - data = { - title = "Bureau Startup"; - message = "Das Büro wurde eröffnet"; - }; - } - ]; - } - { alias = "Turn off Fernseher after last in group left"; - trigger = [ - { # trigger when movement was detected at the time - platform = "state"; - entity_id = "group.team"; - from = "home"; - to = "not_home"; - } - { # trigger at 18:00 no matter what - # to avoid 'everybody left before 18:00:00' - platform = "time"; - at = "18:00:00"; - } - ]; - action = [ - { - service = "homeassistant.turn_off"; - entity_id = [ - "switch.fernseher" - "switch.feuer" - "light.status_felix" - "light.status_daniel" - ]; - } - { - service = "notify.telegrambot"; - data_template = { - title = "Bureau Shutdown"; - message = "All devices are turned off due to {{ trigger.platform }}"; - }; - } - ]; - condition = - { condition = "and"; - conditions = [ - { - condition = "time"; - before = "06:30:00"; #only turn off between 6:30 and 18:00 - after = "18:00:00"; - # weekday = [ "mon" "tue" "wed" "thu" "fri" ]; - } - { # if anybody is still there - condition = "state"; - entity_id = "group.team"; - state = "not_home"; - } - ]; - }; - } - ]; -} diff --git a/2configs/bam/automation/daily-news.nix b/2configs/bam/automation/daily-news.nix deleted file mode 100644 index 2bafe47..0000000 --- a/2configs/bam/automation/daily-news.nix +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - alias = "Daily news for Felix"; - trigger = { - platform = "time"; - at = "07:35:00"; - }; - action = - [ - { - service = "notify.telegrambot"; - data_template = { - title = "Daily News"; - # TODO - message = ""; - }; - } - ]; - } -] diff --git a/2configs/bam/automation/hass-restart.nix b/2configs/bam/automation/hass-restart.nix deleted file mode 100644 index 3b3ce05..0000000 --- a/2configs/bam/automation/hass-restart.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - services.home-assistant.config.automation = - [ - { alias = "State on HA start-up"; - trigger = { - platform = "homeassistant"; - event = "start"; - }; - action = [ - # Startup State - { service = "mqtt.publish"; - data = { - topic = "/bam/sonoffs/cmnd/state"; - payload = ""; - }; - } - # Firmware Version - { service = "mqtt.publish"; - data = { - topic = "/bam/sonoffs/cmnd/status"; - payload = "2"; - }; - } - # Will trigger restart of all devices! - #{ service = "mqtt.publish"; - # data = { - # topic = "sonoffs/cmnd/SetOption59"; # configure sending state on power change - # payload = "1"; - # }; - #} - ]; - } - ]; -} diff --git a/2configs/bam/automation/nachtlicht.nix b/2configs/bam/automation/nachtlicht.nix deleted file mode 100644 index ade8941..0000000 --- a/2configs/bam/automation/nachtlicht.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ - services.home-assistant.config.automation = - [ - # TODO: trigger if it is before dusk and somebody arives but nachtlichter are - # off from last day - # TODO: do not have nachtlicht turned on at night - { - alias = "Turn on Nachtlicht at dusk"; # when it gets dim - trigger = - { platform = "numeric_state"; - entity_id = "sun.sun"; - value_template = "{{ state.attributes.elevation }}"; - below = 10; - - }; - action = - { service = "homeassistant.turn_on"; - entity_id = [ "group.nachtlicht" ]; - }; - } - { - alias = "Turn off Nachtlicht at dawn"; - trigger = - { platform = "sun"; - event = "sunrise"; - offset = "01:30:00"; # on dawn - }; - # TODO: when somebody is still in the buero - # condition = - #{ - #}; - action = - { service = "homeassistant.turn_off"; - entity_id = [ "group.nachtlicht" ]; - }; - } - ]; -} diff --git a/2configs/bam/automation/philosophische-tuer.nix b/2configs/bam/automation/philosophische-tuer.nix deleted file mode 100644 index 9586d9a..0000000 --- a/2configs/bam/automation/philosophische-tuer.nix +++ /dev/null @@ -1,100 +0,0 @@ -{ config, pkgs, lib, ... }: - -let - short_threshold = 30; #seconds - long_threshold = 30; #minutes - sensor = "binary_sensor.buerotuer_contact"; - - # get the list of all - name = "tueraudio"; - prefix = "http://localhost:8123/local/${name}"; - audiodir = "${config.services.home-assistant.configDir}/www/${name}"; - recordrepo = pkgs.fetchFromGitHub { - owner = "makefu"; - repo = "philosophische_tuer"; - rev = "607eff7"; - sha256 = "1qlyqmc65yfb42q4fzd92vinx4i191w431skmcp7xjncb45lfp8j"; - }; - samples = user: lib.mapAttrsToList - (file: _: ''"${prefix}/${user}/${file}"'') - (builtins.readDir (toString ( recordrepo+ "/recordings/${user}"))); - random_tuerspruch = ''{{['' + (lib.concatStringsSep "," ( - (samples "Felix") ++ (samples "Sofia") ++ (samples "Markus") - )) + ''] | random}}''; # TODO read from derivation -in -{ - systemd.services.copy-philosophische-tuersounds = { - description = "copy philosophische tuer"; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - Type = "oneshot"; - ExecStart = pkgs.writeDash "update-samples" '' - rm -rf "${audiodir}" - cp -vr "${recordrepo}/recordings" "${audiodir}" - ''; - }; - }; - services.home-assistant.config = { - media_extractor = { }; - script."philosophische_tuer" = { - alias = "Durchsage der philosophischen Tür"; - sequence = [ - { service = "media_player.play_media"; - data = { - entity_id = "media_player.mpd"; - media_content_type = "playlist"; - media_content_id = "ansage"; - }; - } - { delay.seconds = 5; } - { service = "media_extractor.play_media"; - entity_id = "media_player.mpd"; - data_template = { - media_content_id = random_tuerspruch; - media_content_type = "MUSIC"; - }; - } - ]; - }; - automation = - [ - { - alias = "Tür offen seit ${toString short_threshold} sekunden"; - trigger = - { platform = "state"; - entity_id = sensor; - to = "on"; - for.seconds = 60; - }; - action = [ - { service = "homeassistant.turn_on"; - entity_id = "script.philosophische_tuer"; - } - ]; - } - { - alias = "Tür offen seit ${toString long_threshold} minuten"; - trigger = - { platform = "state"; - entity_id = sensor; - to = "on"; - for.minutes = long_threshold; - }; - - action = [ - { service = "homeassistant.turn_on"; - entity_id = "script.philosophische_tuer" ; - } - { service = "tts.google_say"; - entity_id = "media_player.mpd"; - data_template = { - message = "BEEP BOOP - Die Tür ist schon seit ${toString long_threshold} Minuten offen! Student Nummer {{ range(1,500) | random }}, bitte schliesse die Tür"; - language = "de"; - }; - } - ]; - } - ]; - }; - -} diff --git a/2configs/bam/automation/quotes.nix b/2configs/bam/automation/quotes.nix deleted file mode 100644 index c4625ae..0000000 --- a/2configs/bam/automation/quotes.nix +++ /dev/null @@ -1,4 +0,0 @@ -# heiss -Lieber Freund, was für ein Sommer! Ich denke Sie mir im Zimmer sitzend, mehr Omelette als Mensch. -Sommer ist die Zeit, in der es zu heiß ist, um das zu tun, wozu es im Winter zu kalt war. - diff --git a/2configs/bam/automation/schlechteluft.nix b/2configs/bam/automation/schlechteluft.nix deleted file mode 100644 index ea1d445..0000000 --- a/2configs/bam/automation/schlechteluft.nix +++ /dev/null @@ -1,75 +0,0 @@ -let - long_threshold = 30; -in -{ - services.home-assistant.config.automation = - [ - { - alias = "Bad Air Alarm 60 seconds"; - trigger = - { platform = "numeric_state"; - entity_id = "sensor.air_quality"; - above = 1523; - for.seconds = 60; - }; - condition = { - condition = "and"; - conditions = [ - { condition = "state"; - entity_id = "group.team"; - state = "home"; - } - { condition = "time"; - after = "06:00:00"; - before = "20:00:00"; - } - ]; - }; - - action = [ - { service = "homeassistant.turn_on"; - entity_id = [ - "script.schlechteluft" - ]; - } - ]; - } - { - alias = "Bad Air Alarm ${toString long_threshold} Minutes"; - trigger = - { platform = "numeric_state"; - entity_id = "sensor.air_quality"; - above = 1523; - for.minutes = long_threshold; - }; - condition = { - condition = "and"; - conditions = [ - { condition = "state"; - entity_id = "group.team"; - state = "home"; - } - { condition = "time"; - after = "06:00:00"; - before = "20:00:00"; - } - ]; - }; - - action = [ - { service = "homeassistant.turn_on"; - entity_id = [ - "script.schlechteluft" - ]; - } - { service = "tts.google_say"; - entity_id = "media_player.mpd"; - data_template = { - message = "BEEP BEEP - Die luft ist schon ${toString long_threshold} Minuten schlecht! Student Nummer {{ range(1,500) | random }}, öffne ein Fenster."; - language = "de"; - }; - } - ]; - } - ]; -} diff --git a/2configs/bam/camera/comic.nix b/2configs/bam/camera/comic.nix deleted file mode 100644 index ae24760..0000000 --- a/2configs/bam/camera/comic.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - services.home-assistant.config.camera = - [ - { name = "Poorly Drawn Lines"; - platform = "generic"; - still_image_url = http://127.0.0.1:8123/local/lines.png ; - } - { name = "XKCD"; - platform = "generic"; - still_image_url = http://127.0.0.1:8123/local/xkcd.png ; - } - ]; -} diff --git a/2configs/bam/camera/stuttgart.nix b/2configs/bam/camera/stuttgart.nix deleted file mode 100644 index 0badcb2..0000000 --- a/2configs/bam/camera/stuttgart.nix +++ /dev/null @@ -1,30 +0,0 @@ - -let - cam = name: still_image_url: - { - inherit name still_image_url; - platform = "generic"; - }; -in -{ - services.home-assistant.config.camera = - [ - ( cam "Max-Eyth-See" https://www.wav-stuttgart.de/webcam/_/webcam1.jpg ) - ( cam "Wilhelma" http://webcam.wilhelma.de/webcam02/webcam02.jpg ) - ( cam "Marktplatz" https://webcam.stuttgart.de/wcam007/current.jpg ) - ( cam "Schoch Areal" https://webcam.stuttgart.de/wcam004/current.jpg ) - ( cam "Leuze" https://webcam.stuttgart.de/wcam005/current.jpg ) - ( cam "Straße Wilhelma" https://webcam.stuttgart.de/wcam006/current.jpg ) - ( cam "Fernsehturm 1" http://webcam.fernsehturmstuttgart.com/current.jpg ) - ( cam "Fernsehturm 2" http://webcam.fernsehturmstuttgart.com/current2.jpg ) - ( cam "Feuerbach Lemberg" http://www.regio7.de/handy/current.jpg ) - ( cam "Flughafen Stuttgart 1" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam2.jpg ) - ( cam "Flughafen Stuttgart 2" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam5.jpg ) - ( cam "Flughafen Stuttgart 3" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam7.jpg ) - ( cam "S21 1" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-03/s21-turm03.jpg ) - ( cam "S21 2" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-02/s21-turm-02.jpg ) - ( cam "S21 3" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-01/s21-turm-01.jpg ) - ( cam "S21 4" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Jaegerstrasse-Nordkopf/s21-jaegerstrassse-nordkopf.jpg ) - ( cam "S21 5" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Bahndirektion-Nord/S21-Bundesbahndirektion-Nord.jpg ) - ]; -} diff --git a/2configs/bam/camera/verkehrskamera.nix b/2configs/bam/camera/verkehrskamera.nix deleted file mode 100644 index f09dc94..0000000 --- a/2configs/bam/camera/verkehrskamera.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - services.home-assistant.config.camera = - [ - { name = "Baumarkt"; - platform = "generic"; - still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt - } - { name = "Autobahn Heilbronn"; - platform = "generic"; - still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K10 ; - } - { name = "Autobahn Singen"; - platform = "generic"; - still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ; - } - ]; -} diff --git a/2configs/bam/deps/aresponses.nix b/2configs/bam/deps/aresponses.nix deleted file mode 100644 index 9e64d2f..0000000 --- a/2configs/bam/deps/aresponses.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ lib -, buildPythonPackage -, fetchPypi -# propagatedBuildInputs -, aiohttp -# buildInputs -, pytest -, pytest-asyncio -}: - -buildPythonPackage rec { - pname = "aresponses"; - version = "1.1.1"; - - src = fetchPypi { - inherit pname version; - sha256 = "d1d6ef52b9a97142d106688cf9b112602ef3dc66f6368de8f91f47241d8cfc9c"; - }; - - propagatedBuildInputs = [ - aiohttp - ]; - - buildInputs = [ - pytest - pytest-asyncio - ]; - - # tests only distributed via git repository, not pypi - doCheck = false; - - meta = with lib; { - description = "Asyncio testing server"; - homepage = "https://github.com/circleup/aresponses"; - license = licenses.mit; - maintainers = [ maintainers.makefu ]; - }; -} diff --git a/2configs/bam/deps/openwrt-luci-rpc.nix b/2configs/bam/deps/openwrt-luci-rpc.nix deleted file mode 100644 index 4eceeb1..0000000 --- a/2configs/bam/deps/openwrt-luci-rpc.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ lib -, buildPythonPackage -, fetchPypi -, click -, requests -, packaging -}: - -buildPythonPackage rec { - pname = "openwrt-luci-rpc"; - version = "1.1.2"; - - src = fetchPypi { - inherit pname version; - sha256 = "174a1f6c0bb2a2ed76e5299d14e2be05c612e8bcd4c15b9a9aedee1ef8e18b90"; - }; - - patchPhase = '' - sed -i -e "s/requests==2.21.0/requests/" -e "s/packaging==19.1/packaging/" setup.py - ''; - - propagatedBuildInputs = [ - click - requests - packaging - ]; - - meta = with lib; { - description = "Module for interacting with OpenWrt Luci RPC interface"; - homepage = https://github.com/fbradyirl/openwrt-luci-rpc; - license = licenses.asl20; - maintainers = [ maintainers.makefu ]; - }; -} diff --git a/2configs/bam/device_tracker/openwrt.nix b/2configs/bam/device_tracker/openwrt.nix deleted file mode 100644 index b597548..0000000 --- a/2configs/bam/device_tracker/openwrt.nix +++ /dev/null @@ -1,18 +0,0 @@ -# requires `opkg install luci-mod-rpc` on router -# see https://www.home-assistant.io/components/luci/ - -{ - services.home-assistant.config.device_tracker = - [ - { platform = "luci"; - host = "192.168.8.1"; - username = "root"; - password = import <secrets/hass/router.nix>; - interval_seconds = 30; # instead of 12seconds - consider_home = 300; # 5 minutes timeout - new_device_defaults = { - track_new_devices = true; - }; - } - ]; -} diff --git a/2configs/bam/devices/users.nix b/2configs/bam/devices/users.nix deleted file mode 100644 index 305c0ca..0000000 --- a/2configs/bam/devices/users.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - thorsten-phone = { - name = "Thorsten"; - mac = "8c:f5:a3:bc:83:a0"; - track = true; - hide_if_away = true; - }; - felix-laptop = { - name = "Felix"; - mac = "6c:88:14:b4:43:9c"; - track = true; - hide_if_away = true; - }; - # b0:e5:ed:52:ee:43 - honor8 - # 38:94:96:b0:13:c7 - android-4ef03e4f4a14b6b9 - # ac:5f:3e:cc:b8:5e - Galaxy S7 -} diff --git a/2configs/bam/light/buzzer.nix b/2configs/bam/light/buzzer.nix deleted file mode 100644 index 4851dbd..0000000 --- a/2configs/bam/light/buzzer.nix +++ /dev/null @@ -1,30 +0,0 @@ -let - tasmota_pwm = name: topic: pwmid: max: - let - id = "PWM${toString pwmid}"; - in { platform = "mqtt"; - inherit name; - state_topic = "/bam/${topic}/stat/RESULT"; - state_value_template = ''{%- if value_json["PWM"]["${id}"]| int > 0 -%} ${toString max} {%- else -%} 0 {%- endif -%}''; - - command_topic = "/bam/${topic}/cmnd/${id}"; - on_command_type = "brightness"; - brightness_command_topic = "/bam/${topic}/cmnd/${id}"; - brightness_value_template = ''{{value_json["PWM"]["${id}"]}}''; - brightness_scale = max; - payload_on = "${toString max}"; - payload_off = "0"; - availability_topic = "/bam/${topic}/tele/LWT"; - payload_available= "Online"; - payload_not_available= "Offline"; - retain = true; - optimistic = false; - qos = 0; - }; -in { - services.home-assistant.config.light = - [ - # (tasmota_pwm "RedButton LED" "redbutton" 1 1023) #LED PWM1 - # (tasmota_pwm "RedButton Buzzer" "redbutton" 2 512) #buzzer PWM2 - ]; -} diff --git a/2configs/bam/light/statuslight.nix b/2configs/bam/light/statuslight.nix deleted file mode 100644 index de65a23..0000000 --- a/2configs/bam/light/statuslight.nix +++ /dev/null @@ -1,58 +0,0 @@ -let - tasmota_rgb = name: topic: -# LED WS2812b -# effect_state_topic: "stat/led/Scheme" -# effect_command_topic: "cmnd/led/Scheme" -# effect_value_template: "{{ value_json.Scheme }}" - { platform = "mqtt"; - inherit name; - retain = false; - qos = 1; - #optimistic = true; - # state - command_topic = "/bam/${topic}/cmnd/POWER"; - state_topic = "/bam/${topic}/tele/STATE"; - value_template = "{{ value_json.POWER }}"; - availability_topic = "/bam/${topic}/tele/LWT"; - payload_on = "ON"; - payload_off = "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - # brightness - brightness_state_topic = "/bam/${topic}/tele/STATE"; - brightness_value_template = "{{value_json.Dimmer|default(100)}}"; - brightness_command_topic = "/bam/${topic}/cmnd/Dimmer"; - brightness_scale = 100; - # color - rgb_state_topic = "/bam/${topic}/stat/RESULT"; - rgb_command_topic = "/bam/${topic}/cmnd/Color2"; - rgb_value_template = "{{(value_json.Channel[0]*2.55)|int}},{{(value_json.Channel[1]*2.55)|int}},{{(value_json.Channel[2]*2.55)|int}}"; - - # effects - effect_state_topic = "/bam/${topic}/tele/STATE"; - effect_value_template = "{{value_json.Scheme|default(0)}}"; - effect_command_topic = "/bam/${topic}/cmnd/Scheme"; - effect_list = [ - 0 # single color for LED light - 1 # start wake up sequence (same as Wakeup) - 2 # cycle up through colors using Speed option - 3 # cycle down through colors using Speed option - 4 # random cycle through colors using Speed and Fade - 5 # clock mode (example) - 6 # candlelight pattern - 7 # RGB pattern - 8 # Christmas pattern - 9 # Hannukah pattern - 10 # Kwanzaa pattern - 11 # rainbow pattern - 12 # fire pattern - ]; - }; -in { - services.home-assistant.config.light = - [ - (tasmota_rgb "Status Felix" "status1") - (tasmota_rgb "Status Daniel" "status2") - (tasmota_rgb "Buslicht" "buslicht") - ]; -} diff --git a/2configs/bam/multi/10h_timers.nix b/2configs/bam/multi/10h_timers.nix deleted file mode 100644 index 6edcde4..0000000 --- a/2configs/bam/multi/10h_timers.nix +++ /dev/null @@ -1,210 +0,0 @@ -{lib, ... }: -let - persons = [ "frank" "daniel" "thorsten" "carsten" "ecki" "felix" - "thierry" # tjeri - "emeka" - "tancrede" - ]; - random_zu_lange = name: ''{{ [ - "Du musst jetzt endlich nach Hause gehen ${name}!", - "${name} - 10 Stunden sind rum, bald schenkst du den Franzosen deine Lebenszeit", - "Nur eine Minute über 10 Stunden kann zu einer Stunde Arbeit für Thorsten werden, ${name}.", - "In 10 Minuten kommt dich der Security Mann holen, ${name}", - "Das Sandmännchen ist schon vorbei, gleich fallen dir die Augen zu ${name}.", - "Wenn ${name} sofort los geht, dann ist er noch rechtzeitig für den Tatort zu Hause.", - "${name} muss jetzt gehen, sonst verpasst er die Tagesschau!", - "Es ist spät ${name}. Ausstempeln hilft zwar kurzfristig, kann aber zu langfristigen Problemen führen.", - "${name}, wenn du nach zehn Stunden nach Hause gehst, muss dir dein Vorgesetzter ein Taxi bestellen", - "${name}, wenn du nach zehn Stunden nach Hause gehst, bist du auf dem Rückweg nicht mehr versichert!", - "Zu lange, ${name}!" ] | random }}'' ; - - - random_announce = name: ''{{ [ - "${name} is in da House", - "Ahoi ${name}", - "Hallöchen Popöchen ${name}", - "Moinsen ${name}", - "Moin Moin ${name}", - "Palim, Palim ${name}", - "Vorwärts Genosse ${name}", - "Gemeinsame Grüße, Genosse ${name}", - "Sozialistische Grüße, Genosse ${name}", - "Konzentrierte Grüße, Genosse ${name}", - "Ach, der ${name} ist auch wieder da...", - "Nicht ${name} schon wieder", - "Tri tra tralala, der ${name} ist wieder da.", - "Na sieh mal einer an, ${name} hat es auch her geschafft", - "Wer ist im Büro eingetroffen? ${name} ist es!", - "Willkommen in deinem Lieblingsbüro, ${name}.", - "Klopf, Klopf, wer ist da? ${name} ist da!", - "Messer, Gabel, Schere, Licht sind für kleinen ${name} nicht.", - "Ich kenne ein Geheimnis, ${name} ist angekommen", - "Wir sind ${name}. Sie werden assimiliert werden", - "Achtung, es erfolgt eine Durchsage. ${name} ist eingetroffen", - "Die Scanner haben eine dem System bekannte Lebensform mit dem Namen ${name} detektiert", - "Das Büro sieht dich, ${name}", - "Das Büro riecht dich, ${name}", - "Im Kalender von ${name} sind heute acht Meetings eingeplant, von denen zwei bereits verpasst wurden", - "Das Postfach von ${name} beinhaltet einhundertachtundzwanzig ungelesene E-Mails.", - "Nachricht von Serge: ${name}, bitte melden Sie sich Umgehend bei mir im Büro!", - "Luftqualität hat sich durch das Eintreffen von ${name} um zweihundert Punkte verschlechtert, bitte alle Fenster öffnen.", - "Die Tür geht auf, wer mag das sein? Schon schreitet hier der ${name} ein. Das Volk, es jubelt, Dirnen schmachten. Fürs Festmahl beginnt man schon zu schlachten. Er wird nur nach dem besten streben! Der ${name}, er soll lange leben!", - "${name} arbeitet gern für seinen Konzern", - "${name} ist nur froh im Großraumbüro", - "Für ${name} ist die schönste Zeit ... die Arbeit", - "Ein Fleißbienchen für ${name} zum rechtzeitigen Erscheinen im Büro", - "${name} ist heute wohl doch nicht im Office Home", - "${name} ist bereit für einen Tag voller Meetings", - "Und es startet für ${name} wieder ein Tag im Paradies", - "Lieber ${name}, Markus Keck hat dich bereits drei mal Versucht anzurufen!", - "Trotz schwerer Männergrippe ist ${name} heute im Büro erschienen.", - "${name} kennt keine Parteien mehr, ${name} kennt nur noch Arbeitsplätze", - "${name}, Frage nicht, was dein Arbeitsplatz für dich tun kann. Frage, was du für deinen Arbeitsplatz tun kannst", - "${name} läuft bis in den Jemen - für sein Unternehmen. ${name} schwimmt bis nach Birma - für seine Firma", - "Der Cyberian ${name} ist gekommen um die Bahnwelt vor Cyber-Angriffen zu schützen", - "Alles paletto im Ghetto, ${name}?", - "Hach, ${name}, wenn du hier rein kommst fühlt es sich gleich wieder an wie Montag.", - "Oh nein, nicht schon wieder ${name}", - "Wer wohnt in der Ananas ganz tief im Meer? ${name} Schwammkopf!", - "Arbeit ist Freizeit! Wachstum ist Fortschritt! Sicherheit ist Freiheit! Eine kleine Erinnerung für ${name}"] | random }}'' ; - tmr_10h = name: { - "${name}_10h" = { - name = "${name} 10h Timer"; - duration = "10:00:00"; - }; - }; - - zu_lange_user = name: - { "zu_lange_${name}" = { - alias = "Random Zu Lange ${name}"; - - sequence = [ - { service = "media_player.play_media"; - data = { - entity_id = "media_player.mpd"; - media_content_type = "playlist"; - media_content_id = "ansage"; - }; - } - { delay.seconds = 5; } - { service = "tts.google_say"; - entity_id = "media_player.mpd"; - data_template = { - message = random_zu_lange name; - language = "de"; - }; - } - ]; - }; - }; - announce_user = name: - { "announce_${name}" = { - alias = "Random Announce ${name}"; - sequence = [ - { delay.seconds = 7; } - { service = "media_player.play_media"; - data = { - entity_id = "media_player.mpd"; - media_content_type = "playlist"; - media_content_id = "ansage"; - }; - } - { delay.seconds = 4; } - { service = "tts.google_say"; - entity_id = "media_player.mpd"; - data_template = { - message = random_announce name; - language = "de"; - }; - } - ]; - }; - }; - automation_10h = name: [ - { alias = "start ${name} 10h"; - trigger = { - platform = "state"; - entity_id = [ "person.${name}"]; - from = "not_home"; - to = "home"; - }; - condition = { - condition = "and"; - conditions = [ - { condition = "state"; - entity_id = "timer.${name}_10h"; - state = "idle"; - } - { condition = "time"; - after = "06:00:00"; - before = "12:00:00"; - } - ]; - }; - action = [ - { service = "timer.start"; - entity_id = [ "timer.${name}_10h" ] ; - } - { service = "homeassistant.turn_on"; - entity_id = - [ "switch.fernseher" - "script.blitz_10s" - "script.announce_${name}" - ]; - } - ]; - } - - { alias = "pommes announce ${name}"; - trigger = - { platform = "event"; - event_type = "timer.started"; - event_data.entity_id = "timer.${name}_10h"; - }; - - condition = - { condition = "state"; - entity_id = "binary_sensor.pommes"; - state = "on"; - }; - - action = - { service = "homeassistant.turn_on"; - entity_id = "script.blasen_10s" ; - }; - } - - { alias = "Zu lange ${name}!"; - trigger = - { platform = "event"; - event_type = "timer.finished"; - event_data.entity_id = "timer.${name}_10h"; - }; - - condition = - { condition = "state"; - entity_id = "person.${name}"; - state = "home"; - }; - - action = - { service = "homeassistant.turn_on"; - entity_id = [ - "script.blitz_10s" - "script.zu_lange_${name}" - ]; - }; - } - ]; -in -{ - services.home-assistant.config = { - timer =lib.fold lib.recursiveUpdate {} - (map tmr_10h persons); - automation = (lib.flatten (map automation_10h persons)); - script = lib.fold lib.recursiveUpdate {} ( - (map announce_user persons) ++ - (map zu_lange_user persons) - ); - }; -} diff --git a/2configs/bam/multi/aramark.nix b/2configs/bam/multi/aramark.nix deleted file mode 100644 index 45fadb0..0000000 --- a/2configs/bam/multi/aramark.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ lib, ... }: -let - aramark = topic: name: - { platform = "mqtt"; - inherit name; - state_topic = "/aramark/thales-deutschland/${topic}"; - }; - aramark_menue = menue: - [ - (aramark "${menue}/title" menue) - (aramark "${menue}/description" "${menue} Text") - ((aramark "${menue}/price" "${menue} Preis") // { unit_of_measurement = "€"; }) - ]; -in - { - services.home-assistant.config = - { - sensor = (aramark_menue "Menü 1") - ++ (aramark_menue "Menü 2") - ++ (aramark_menue "Mercato") - ++ (aramark_menue "Aktion"); - binary_sensor = - [ - ((aramark "pommes" "Pommes" ) // { payload_on = "True"; payload_off = "False"; }) - ]; - }; -} diff --git a/2configs/bam/multi/daily-standup.nix b/2configs/bam/multi/daily-standup.nix deleted file mode 100644 index 063def1..0000000 --- a/2configs/bam/multi/daily-standup.nix +++ /dev/null @@ -1,57 +0,0 @@ -{lib, ... }: -let - random_daily_text = ''{{ [ - "Es ist so weit, es ist Standup Zeit!", - "Zehn Uhr Fünfunddreissig ist genau die richtige Zeit für ein Standup!", - "Hat jeder seine zum Standup seine Hausaufgaben gemacht. Bitte einmal aufstehen und den Zettel nach rechts geben", - "Aufstehen zum Appell, es wird die Anwesenheit kontrolliert!", - "Hallo Kinder, wisst ihr welche Zeit es ist ... Genau ... Standup Zeit!", - "Morgens, halb elf in Deutschland - das Standupchen" ] | random }}''; - -in { - services.home-assistant.config = - { - script = - { "random_daily" = { - alias = "Random Daily Introduction"; - - sequence = [ - { service = "media_player.play_media"; - data = { - entity_id = "media_player.mpd"; - media_content_type = "playlist"; - media_content_id = "ansage"; - }; - } - { delay.seconds = 5; } - { service = "tts.google_say"; - entity_id = "media_player.mpd"; - data_template = { - message = random_daily_text; - language = "de"; - }; - } - ]; - }; - }; - automation = [ - { - alias = "Daily Standup"; - trigger = { - platform = "time"; - at = "10:35:00"; - }; - action = - [ - { service = "homeassistant.turn_on"; - entity_id = [ - "script.blitz_10s" - "script.random_daily" - ]; - } - ]; - - } - ]; - }; -} diff --git a/2configs/bam/multi/frosch.nix b/2configs/bam/multi/frosch.nix deleted file mode 100644 index 61606d4..0000000 --- a/2configs/bam/multi/frosch.nix +++ /dev/null @@ -1,103 +0,0 @@ -{lib, ... }: -# needs: binary_sensor.pommes -# notify.matrix_notify -let - random_pommes = '' {{ [ - "Nur ein Pommes Tag ist ein guter Tag", - "Schaut wie schön sie fliegen, die Pommes Seifenblasen", - "zwo ... eins ... Pommes Zeit", - "I cannot believe it is not Pommes", - "Naja, wenn es sonst schon nichts anderes gibt, kann man jetzt auch pommes nehmen", - "Wenn Aramark was kann, dann ist es frittieren", - "Einmal das Hauptgericht mit Pommes, ohne Hauptgericht", - "Rieche ich da etwa Pommes? JA!", - "Pommes ist auch nur Gemüse,also keine Reue und schlag zu!", - "Mit nur fünf Portionen Pommes kann man schon satt werden.", - "Heute für Sie, 15 Pommes von hand abgezählt", - "Der Weltmarktpreis von Pommes ist durch verschiedene Weltkrisen leider so hoch, dass Aramark den Verkaufspreis verdoppeln musste.", - "Vorfreude, schönste Freude, Freude bei Aramark. Pommes in die Schale rein, alle Kunden werden glücklich sein.", - "In 15 Minuten ist es wieder so weit, es ist Pommes Zeit!"] | random }}''; -in -{ - services.home-assistant.config = - { - sensor = [ - { platform = "mqtt"; - name = "frosch brightness"; - device_class = "illuminance"; - state_topic = "/bam/frosch/sensor/brightness/state"; - availability_topic = "/bam/frosch/status"; - payload_available = "online"; - payload_not_available = "offline"; - } - ]; - binary_sensor = [ - { platform = "mqtt"; - name = "frosch auge"; - state_topic = "/bam/frosch/binary_sensor/froschauge/state"; - availability_topic = "/bam/frosch/status"; - payload_available = "online"; - payload_not_available = "offline"; - } - ]; - switch = [ - { platform = "mqtt"; - name = "frosch blasen"; - state_topic = "/bam/frosch/switch/blasen/state"; - command_topic = "/bam/frosch/switch/blasen/command"; - availability_topic = "/bam/frosch/status"; - payload_available = "online"; - payload_not_available = "offline"; - } - ]; - light = []; - automation = [ - { alias = "Pommeszeit"; - trigger = { - platform = "time"; - at = "11:00:00"; - }; - condition = { - condition = "state"; - entity_id = "binary_sensor.pommes"; # from multi/aramark.nix - state = "on"; - }; - action = [ - { service = "homeassistant.turn_on"; - entity_id = [ - "script.pommes_announce" - "script.seifenblasen_30s" # from script/multi_blink.nix - ]; - } - ]; - } - ]; - script = { - pommes_announce = { - alias = "Random Pommes announce"; - sequence = [ - { - service = "media_player.play_media"; - data = { - entity_id = "media_player.mpd"; - media_content_type = "playlist"; - media_content_id = "ansage"; - }; - } - { delay.seconds = 5; } - { - service = "tts.google_say"; - entity_id = "media_player.mpd"; - data_template = { - message = random_pommes; - language = "de"; - }; - } - { service = "notify.matrix_notify"; - data_template.message = random_pommes; - } - ]; - }; - }; - }; -} diff --git a/2configs/bam/multi/matrix.nix b/2configs/bam/multi/matrix.nix deleted file mode 100644 index b9b8fc4..0000000 --- a/2configs/bam/multi/matrix.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ lib, ... }: -#matrix: -# password: supersecurepassword -# rooms: -# - "#hasstest:matrix.org" -# commands: -# - word: my_command -# name: my_command -let - mom_room = "!kTQjvTQvfVsvfEtmth:thales.citadel.team"; -in -{ - services.home-assistant.config = - { - matrix = - { - # secrets: - # homeserver, username, password - homeserver = "https://ext01.citadel.team"; - rooms = [ - mom_room - ]; - commands = [ - { - # alternative: expression for regexp - word = "version"; - name = "version"; - } - { - word = "luftqualität"; - name = "luftqualitaet"; - } - ]; - } // (builtins.fromJSON (builtins.readFile - <secrets/hass/citadel-bot.json>)); - automation = [ - { - alias = "React to !version"; - trigger = { - platform = "event"; - event_type = "matrix_command"; - event_data.command = "version"; - }; - action = { - service = "notify.matrix_notify"; - data_template.message = "Running home-assistant {{states.sensor.current_version.state}}"; - }; - } - { - alias = "React to !luftqualität"; - trigger = { - platform = "event"; - event_type = "matrix_command"; - event_data.command = "luftqualitaet"; - }; - action = { - service = "notify.matrix_notify"; - data_template.message = ''Temp: {{states.sensor.notizen_temperature.state_with_unit | replace (" ","")}}, Hum:{{states.sensor.notizen_humidity.state_with_unit | replace (" ","")}}, airquality:{{states.sensor.air_quality.state_with_unit}}''; - }; - } - - ]; - notify = [{ - name = "matrix_notify"; - platform = "matrix"; - default_room = mom_room; - }]; - }; -} diff --git a/2configs/bam/multi/mittagessen.nix b/2configs/bam/multi/mittagessen.nix deleted file mode 100644 index 52ec99a..0000000 --- a/2configs/bam/multi/mittagessen.nix +++ /dev/null @@ -1,92 +0,0 @@ -{ lib, ... }: -let - # TODO: remove redundant code (from multi_blink) via lib - flash_entity = { entity, delay ? 500, count ? 4, alias ? "${entity}_blink_${toString count}_${toString delay}" }: - { - inherit alias; - sequence = lib.flatten (builtins.genList (i: [ - { service = "homeassistant.turn_on"; - data.entity_id = entity; - } - { delay.milliseconds = delay; } - { service = "homeassistant.turn_off"; - data.entity_id = entity; - } - { delay.milliseconds = delay; } - ] - ) count); - }; - # TODO: use influxdb and check if pommes - random_mittagessen = '' {{ [ - "Es ist 12 uhr 30. Der Aramark Gourmettempel hat, wie jeden Tag, wieder die feinsten Köstlichkeiten für euch Vorbereitet", - "Heute bei Aramark: Rezepte aus Ländern, von denen Ihr noch nie gehört habt, Deutsch zubereitet", - "Heute bei Aramark im Angebot: Scheiss mit Reis oder Reste von Freitag", - "MHHHH es ist wieder mal so weit, lecker Bayerisch Kraut mit asiatischen Nudeln", - "Es ist 12 Uhr 30 und Heute gibt es nur Pommes, wenn der Pommesfrosch Blasen gespuckt hat.", - "Heute gibt es Pommes leider nicht einzeln zu verkaufen, da die Schälchen alle sind", - "Heute gibt es Pommes, verarscht! Natürlich gibt es nur salzlosen Reis, oder salzlose Nudeln.", - "Heute auf dem Speiseplan: Sushi vom Vortag", - "Aramark Kantinenessen: Der Hunger treibt es rein, der Geiz hält es drin.", - "Das Essen in der Snackeria sieht heute wie die bessere Alternative aus", - "Heute ist wohl wieder ein Beilagen-Tag", - "Lunch time! Good luck, you will need it!", - "Heute vielleicht lieber doch nur einen Salat?", - "Im Büro ist es eh gerade viel zu warm, also ab zur Kantine", - "Im Büro ist es eh gerade viel zu kalt, also ab zur Kantine", - "Heute scheint die Auswahl wieder sehr schwierig zu sein. Vielleicht doch lieber ein Brötchen mit Fleischkäse vom Bäcker beim Baumarkt?", - "Wer hat hier schon wieder ein Meeting auf 12 Uhr gelegt? Skandal!", - "Jetzt nur noch kurz die Mail fertig schreiben und schon kann es los gehen.", - "Es ist 13 Uhr und die Mittagspause ist bald vorbei .... Kleiner Scherz, es ist erst 12:30, aber Ihr hättet auch nicht wirklich etwas verpasst.", - "Hallo, es ist nun 12 Uhr 30! Dies entspricht der Essenszeit aller Büroinsassen. Bitte begebt euch zur Aramark Essensausgabe um euren menschlichen Bedürfnissen nachzukommen."] | random }}''; -in -{ - services.home-assistant.config = { - automation = [ - { alias = "Mittagessen"; - trigger = { - platform = "time"; - at = "12:30:00"; - }; - action = [ - { service = "homeassistant.turn_on"; - entity_id = [ - "script.mittagessen_announce" - "script.blitz_10s" - "script.mittagessenlicht" - ]; - } - ]; - } - ]; - script = { - mittagessenlicht = (flash_entity { - entity = "switch.bauarbeiterlampe"; - alias = "Bauarbeiterlampe Mittagessenlicht"; - delay = 1000; - count = 5; - }); - mittagessen_announce = { - alias = "Random Mittagessen announce"; - sequence = [ - { - service = "media_player.play_media"; - data = { - entity_id = "media_player.mpd"; - media_content_type = "playlist"; - media_content_id = "ansage"; - }; - } - { delay.seconds = 5; } - { - service = "tts.google_say"; - entity_id = "media_player.mpd"; - data_template = { - message = random_mittagessen; - language = "de"; - }; - } - ]; - }; - }; - }; -} diff --git a/2configs/bam/script/multi_blink.nix b/2configs/bam/script/multi_blink.nix deleted file mode 100644 index 753918f..0000000 --- a/2configs/bam/script/multi_blink.nix +++ /dev/null @@ -1,60 +0,0 @@ -{lib, ... }: -let - # TODO: flash with different delay - - # let an entity blink for X times with a delay of Y milliseconds - flash_entity = { entity, delay ? 500, count ? 4, alias ? "${entity}_blink_${toString count}_${toString delay}" }: - { - inherit alias; - sequence = lib.flatten (builtins.genList (i: [ - { service = "homeassistant.turn_on"; - data.entity_id = entity; - } - { delay.milliseconds = delay; } - { service = "homeassistant.turn_off"; - data.entity_id = entity; - } - { delay.milliseconds = delay; } - ] - ) count); - }; -in { - services.home-assistant.config.script = - { - buzz_red_led = (flash_entity { - entity = "light.redbutton_buzzer"; - alias = "Red Button Buzz"; - count = 4; - }); - buzz_red_led_fast = (flash_entity { - entity = "light.redbutton_buzzer"; - delay = 250; - count = 2; - alias = "Red Button Buzz fast"; - }); - blitz_10s = (flash_entity { - entity = "switch.blitzdings"; - delay = 10000; - count = 1; - alias = "blitz for 10 seconds"; - }); - blasen_10s = (flash_entity { - entity = "switch.frosch_blasen"; - delay = 10000; - count = 1; - alias = "blasen for 10 seconds"; - }); - blasen_30s = (flash_entity { - entity = "switch.frosch_blasen"; - delay = 30000; - count = 1; - alias = "blasen for 30 seconds"; - }); - schlechteluft = (flash_entity { - entity = "switch.bauarbeiterlampe"; - alias = "Schlechte Luft Lampe 5 secs"; - delay = 5000; - count = 1; - }); - }; -}