From 4e08eb5dffbfc9707633b6d30e200bb993185db2 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 3 Nov 2020 22:59:13 +0100 Subject: puyak.r,wolf.r: move all services from wolf to puyak --- makefu/2configs/urlwatch/default.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/urlwatch/default.nix b/makefu/2configs/urlwatch/default.nix index 838c26278..5b059a3b2 100644 --- a/makefu/2configs/urlwatch/default.nix +++ b/makefu/2configs/urlwatch/default.nix @@ -34,6 +34,7 @@ in { https://pypi.python.org/simple/pyserial/ https://pypi.python.org/simple/semantic_version/ # weird shit + https://www.zigbee2mqtt.io/information/supported_adapters.html http://ftp.debian.org/debian/pool/main/a/apt-cacher-ng/ https://erdgeist.org/gitweb/opentracker/info/refs?service=git-upload-pack -- cgit v1.2.3 From a23066a27e0c7c448912d71d0ece0c92420b3671 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 5 Nov 2020 10:30:05 +0100 Subject: ma minimal: keep nscd enabled --- makefu/2configs/minimal.nix | 1 - 1 file changed, 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/minimal.nix b/makefu/2configs/minimal.nix index 78a9dcfa6..445e6c577 100644 --- a/makefu/2configs/minimal.nix +++ b/makefu/2configs/minimal.nix @@ -82,5 +82,4 @@ "net.ipv6.conf.default.use_tempaddr" = 2; }; - services.nscd.enable = false; } -- cgit v1.2.3 From 94b6aea2cd6af0454577bf3ba69cfdfd130f928b Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 16 Nov 2020 21:31:17 +0100 Subject: ma bureautomation/kalauerbot: enterprise restart after 12h --- makefu/2configs/bureautomation/kalauerbot.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/bureautomation/kalauerbot.nix b/makefu/2configs/bureautomation/kalauerbot.nix index d61b8885e..ff045e2f3 100644 --- a/makefu/2configs/bureautomation/kalauerbot.nix +++ b/makefu/2configs/bureautomation/kalauerbot.nix @@ -12,6 +12,9 @@ WorkingDirectory = "/var/lib/kalauerbot"; ExecStart = "${pkgs.kalauerbot}/bin/kalauerbot"; PrivateTmp = true; + + Restart = "always"; + RuntimeMaxSec = "12h"; }; }; } -- cgit v1.2.3 From 4fb678f03f381b6bd0cda10a3c161dab8be5ed00 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 16 Nov 2020 21:31:58 +0100 Subject: ma printer: use extraconfig for magicolor, new netconfig for lan devices --- makefu/2configs/printer.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/printer.nix b/makefu/2configs/printer.nix index d297483b2..6fd1c1858 100644 --- a/makefu/2configs/printer.nix +++ b/makefu/2configs/printer.nix @@ -21,16 +21,20 @@ in { hardware.sane = { enable = true; extraBackends = [ ]; + netConf = + # drucker.lan SCX-3205W + '' + 192.168.1.6'' + # uhrenkind.shack magicolor 1690mf + + '' + 10.42.20.30''; # $ scanimage -p --format=jpg --mode=Gray --source="Automatic Document Feeder" -v --batch="lol%d.jpg" --resolution=150 # requires 'sane-extra', scan via: - #extraConfig."magicolor" = '' - # net 10.42.20.30 0x2098 - #''; # 10.42.20.30: uhrenkind.shack magicolor 1690mf - extraConfig."xerox_mfp" = '' - tcp 192.168.1.5 - ''; #home printer SCX-3205W + extraConfig."magicolor" = '' + net 10.42.20.30 0x2098 + ''; # 10.42.20.30: uhrenkind.shack magicolor 1690mf }; state = [ "/var/lib/cups" ]; } -- cgit v1.2.3 From 9323f9141ddd9824eacc8f718aa3ba49ea57b852 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 16 Nov 2020 21:32:27 +0100 Subject: ma remote-build: enable gum for arm6l cross-build --- makefu/2configs/remote-build/gum.nix | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/remote-build/gum.nix b/makefu/2configs/remote-build/gum.nix index 98e2e58b5..39e90f1b8 100644 --- a/makefu/2configs/remote-build/gum.nix +++ b/makefu/2configs/remote-build/gum.nix @@ -10,6 +10,14 @@ system = "x86_64-linux"; supportedFeatures = [ ]; } + { + hostName = "gum.krebsco.de"; + maxJobs = 8; + sshKey = toString ; + sshUser = "nixBuild"; + system = "armv6l-linux"; + supportedFeatures = [ ]; + } ]; }; } -- cgit v1.2.3 From 29c4df2d2228956b65f435cb1358d2f577119217 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 16 Nov 2020 21:33:58 +0100 Subject: ma share/omo: set workgroup and netbios name --- makefu/2configs/share/omo.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/share/omo.nix b/makefu/2configs/share/omo.nix index 732dc2036..1a488e69c 100644 --- a/makefu/2configs/share/omo.nix +++ b/makefu/2configs/share/omo.nix @@ -82,6 +82,9 @@ in { printing = bsd printcap name = /dev/null disable spoolss = yes + workgroup = WORKGROUP + server string = ${config.networking.hostName} + netbios name = ${config.networking.hostName} ''; }; } -- cgit v1.2.3 From b033dfd615db0334684f699731aa0064fcedf6e8 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 16 Nov 2020 21:35:30 +0100 Subject: ma urlwatch: watch zigbee2mqtt supported adapters --- makefu/2configs/urlwatch/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/urlwatch/default.nix b/makefu/2configs/urlwatch/default.nix index 5b059a3b2..ecd03710e 100644 --- a/makefu/2configs/urlwatch/default.nix +++ b/makefu/2configs/urlwatch/default.nix @@ -34,7 +34,9 @@ in { https://pypi.python.org/simple/pyserial/ https://pypi.python.org/simple/semantic_version/ # weird shit - https://www.zigbee2mqtt.io/information/supported_adapters.html + { url = "https://www.zigbee2mqtt.io/information/supported_adapters.html"; + filter = "html2text"; + } http://ftp.debian.org/debian/pool/main/a/apt-cacher-ng/ https://erdgeist.org/gitweb/opentracker/info/refs?service=git-upload-pack -- cgit v1.2.3 From a1ab1cde34c13cc0a1c78eee28835e22cdcc1794 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 16 Nov 2020 21:36:10 +0100 Subject: ma wireguard/server: add workaround for failing tunnel behind nat --- makefu/2configs/wireguard/server.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/wireguard/server.nix b/makefu/2configs/wireguard/server.nix index ae10f34a2..1b81cf57f 100644 --- a/makefu/2configs/wireguard/server.nix +++ b/makefu/2configs/wireguard/server.nix @@ -54,4 +54,10 @@ in { # wireguard server } ]; }; + # TODO: this issue is related to the router which connects to the host but is + # unable to re-connect once restarted + systemd.services.wireguard-wg0.serviceConfig = { + Restart = "always"; + RuntimeMaxSec = "12h"; + }; } -- cgit v1.2.3 From c743b9e53c4dfe2a39409c8bd01f373ce86b8e06 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 16 Nov 2020 21:37:03 +0100 Subject: ma pkgs.droidcam: init software + kernel module --- makefu/2configs/hw/droidcam.nix | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 makefu/2configs/hw/droidcam.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/hw/droidcam.nix b/makefu/2configs/hw/droidcam.nix new file mode 100644 index 000000000..c638123bb --- /dev/null +++ b/makefu/2configs/hw/droidcam.nix @@ -0,0 +1,7 @@ +{ pkgs, config, ... }: +{ + boot.extraModprobeConfig = "options v4l2loopback_dc width=640 height=480"; + boot.extraModulePackages = [ + (pkgs.callPackage ../../5pkgs/v4l2loopback-dc { kernel = config.boot.kernelPackages.kernel; }) + ]; +} -- cgit v1.2.3 From f911324c592ebd7809472a4100a8f6a6c83b0fe2 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 17 Nov 2020 19:45:37 +0100 Subject: ma bam: remove dwd_pollen --- makefu/2configs/bureautomation/default.nix | 26 ++---------------- makefu/2configs/bureautomation/deps/dwd_pollen.nix | 32 ---------------------- 2 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 makefu/2configs/bureautomation/deps/dwd_pollen.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/bureautomation/default.nix b/makefu/2configs/bureautomation/default.nix index 9b33595f4..cd598f0aa 100644 --- a/makefu/2configs/bureautomation/default.nix +++ b/makefu/2configs/bureautomation/default.nix @@ -15,30 +15,8 @@ in { ]; networking.firewall.allowedTCPPorts = [ 8123 ]; state = [ "/var/lib/hass/known_devices.yaml" ]; - services.home-assistant = let - dwd_pollen = pkgs.fetchFromGitHub { - owner = "marcschumacher"; - repo = "dwd_pollen"; - rev = "0.1"; - sha256 = "1af2mx99gv2hk1ad53g21fwkdfdbymqcdl3jvzd1yg7dgxlkhbj1"; - }; - in { + services.home-assistant = { enable = true; - package = (pkgs.home-assistant.overrideAttrs (old: { - # TODO: find correct python package - installCheckPhase = '' - echo LOLLLLLLLLLLLLLL - ''; - postInstall = '' - cp -r ${dwd_pollen} $out/lib/python3.7/site-packages/homeassistant/components/dwd_pollen - ''; - })).override { - extraPackages = ps: with ps; [ - pkgs.picotts - python-forecastio jsonrpc-async jsonrpc-websocket mpd2 - (callPackage ./deps/openwrt-luci-rpc.nix { }) - ]; - }; autoExtraComponents = true; config = { config = {}; @@ -139,7 +117,7 @@ in { sensor = [] ++ [{ platform = "version"; }] # pyhaversion - ++ (import ./sensor/pollen.nix) + # ++ (import ./sensor/pollen.nix) ++ (import ./sensor/espeasy.nix) ++ (import ./sensor/airquality.nix) ++ ((import ./sensor/outside.nix) {inherit lib;}) diff --git a/makefu/2configs/bureautomation/deps/dwd_pollen.nix b/makefu/2configs/bureautomation/deps/dwd_pollen.nix deleted file mode 100644 index 39d9c3069..000000000 --- a/makefu/2configs/bureautomation/deps/dwd_pollen.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ lib -, buildPythonPackage -, fetchFromGitHub -, python -, voluptuous -}: - -buildPythonPackage rec { - format = "other"; - pname = "dwd_pollen"; - version = "0.1"; - - src = fetchFromGitHub { - owner = "marcschumacher"; - repo = "dwd_pollen"; - rev = version; - sha256 = "1af2mx99gv2hk1ad53g21fwkdfdbymqcdl3jvzd1yg7dgxlkhbj1"; - }; - propagatedBuildInputs = [ - voluptuous - ]; - installPhase = '' - install -D -t $out/${python.sitePackages}/homeassistant/components/sensor/dwd_pollen * - ''; - - meta = with lib; { - description = "Home Assistant component to retrieve Pollen data from DWD (Germany)"; - homepage = https://github.com/marcschumacher/dwd_pollen; - license = licenses.mit; - maintainers = [ maintainers.makefu ]; - }; -} -- cgit v1.2.3 From 9d99500e0922c5577c32bcb77f88d9edc472ffaa Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 17 Nov 2020 20:16:19 +0100 Subject: ma hw/tp-x2x0: use utillinux instead of rfkill package --- makefu/2configs/hw/tp-x2x0.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/hw/tp-x2x0.nix b/makefu/2configs/hw/tp-x2x0.nix index f4578bf77..b997a9eec 100644 --- a/makefu/2configs/hw/tp-x2x0.nix +++ b/makefu/2configs/hw/tp-x2x0.nix @@ -54,6 +54,6 @@ powerManagement.resumeCommands = '' - ${pkgs.rfkill}/bin/rfkill unblock all + ${pkgs.utillinux}/bin/rfkill unblock all ''; } -- cgit v1.2.3 From 7750ce2befbff39121346df1a1ee4da964fe79a3 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 17 Nov 2020 21:46:06 +0100 Subject: ma owncloud: disable memcached --- makefu/2configs/deployment/owncloud.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/deployment/owncloud.nix b/makefu/2configs/deployment/owncloud.nix index 317e0a29f..3a08b1f52 100644 --- a/makefu/2configs/deployment/owncloud.nix +++ b/makefu/2configs/deployment/owncloud.nix @@ -157,10 +157,9 @@ let error_reporting = E_ALL | E_STRICT html_errors = On date.timezone = "Europe/Berlin" - # extension=${pkgs.phpPackages.memcached}/lib/php/extensions/memcached.so extension=${pkgs.phpPackages.redis}/lib/php/extensions/redis.so extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so - ''; + ''; # extension=${pkgs.phpPackages.memcached}/lib/php/extensions/memcached.so systemd.services."nextcloud-cron-${domain}" = { serviceConfig = { User = "nginx"; -- cgit v1.2.3 From 60e1c9a6a7479dd588993eb55048cd3f1e711c01 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 17 Nov 2020 22:23:05 +0100 Subject: ma owncloud: use php.buildEnv --- makefu/2configs/deployment/owncloud.nix | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/deployment/owncloud.nix b/makefu/2configs/deployment/owncloud.nix index 3a08b1f52..af6592b2b 100644 --- a/makefu/2configs/deployment/owncloud.nix +++ b/makefu/2configs/deployment/owncloud.nix @@ -14,8 +14,18 @@ with lib; let + phpPackage = let + base = pkgs.php74; + in + base.buildEnv { + extensions = { enabled, all }: with all; + enabled ++ [ + apcu redis memcached imagick + ]; + }; + # TODO: copy-paste from lass/2/websites/util.nix - nextcloud = pkgs.nextcloud18; + nextcloud = pkgs.nextcloud20; serveCloud = domains: let domain = head domains; @@ -126,6 +136,7 @@ let services.phpfpm.pools."${domain}" = { user = "nginx"; group = "nginx"; + phpPackage = phpPackage; settings = { "listen.owner" = "nginx"; "pm" = "dynamic"; @@ -138,7 +149,7 @@ let "php_admin_flag[log_errors]" = "on"; "catch_workers_output" = true; }; - phpEnv."PATH" = lib.makeBinPath [ pkgs.php ]; + phpEnv."PATH" = lib.makeBinPath [ phpPackage ]; }; services.phpfpm.phpOptions = '' opcache.enable=1 @@ -149,7 +160,7 @@ let opcache.save_comments=1 opcache.revalidate_freq=1 opcache.file_cache = .opcache - zend_extension=${pkgs.php}/lib/php/extensions/opcache.so + zend_extension=${phpPackage}/lib/php/extensions/opcache.so display_errors = on display_startup_errors = on @@ -157,13 +168,15 @@ let error_reporting = E_ALL | E_STRICT html_errors = On date.timezone = "Europe/Berlin" - extension=${pkgs.phpPackages.redis}/lib/php/extensions/redis.so - extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so - ''; # extension=${pkgs.phpPackages.memcached}/lib/php/extensions/memcached.so + extension=${phpPackage}/lib/php/extensions/memcached.so + extension=${phpPackage}/lib/php/extensions/redis.so + extension=${phpPackage}/lib/php/extensions/apcu.so + ''; + systemd.services."nextcloud-cron-${domain}" = { serviceConfig = { User = "nginx"; - ExecStart = "${pkgs.php}/bin/php -f ${root}/cron.php"; + ExecStart = "${phpPackage}/bin/php -f ${root}/cron.php"; }; startAt = "*:0/15"; }; -- cgit v1.2.3 From ccb7655103ff13e1ed9bb7e85dbc2fd644b1e5f5 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 18 Nov 2020 13:42:16 +0100 Subject: ma download.binaergewitter.de: fix for 20.09 --- makefu/2configs/bgt/download.binaergewitter.de.nix | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/bgt/download.binaergewitter.de.nix b/makefu/2configs/bgt/download.binaergewitter.de.nix index 77c9ddc81..e3be6778f 100644 --- a/makefu/2configs/bgt/download.binaergewitter.de.nix +++ b/makefu/2configs/bgt/download.binaergewitter.de.nix @@ -36,6 +36,11 @@ in { } ''; }; + + # 20.09 unharden nginx to write logs + systemd.services.nginx.serviceConfig.ReadWritePaths = [ + "/var/spool/nginx/logs/" + ]; services.nginx = { appendHttpConfig = '' types { -- cgit v1.2.3 From 34da75341bc63e0ade7a6a5596891655d4f82659 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 18 Nov 2020 19:37:33 +0100 Subject: ma bgt/download: remove obsolete netdata entry --- makefu/2configs/bgt/download.binaergewitter.de.nix | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/bgt/download.binaergewitter.de.nix b/makefu/2configs/bgt/download.binaergewitter.de.nix index e3be6778f..4abc7d345 100644 --- a/makefu/2configs/bgt/download.binaergewitter.de.nix +++ b/makefu/2configs/bgt/download.binaergewitter.de.nix @@ -17,12 +17,14 @@ in { PasswordAuthentication no ''; }; + users.users.auphonic = { uid = genid "auphonic"; group = "nginx"; useDefaultShell = true; openssh.authorizedKeys.keys = [ ident config.krebs.users.makefu.pubkey ]; }; + services.logrotate = { enable = true; config = '' @@ -41,6 +43,7 @@ in { systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/spool/nginx/logs/" ]; + services.nginx = { appendHttpConfig = '' types { @@ -60,15 +63,4 @@ in { ''; }; }; - environment.etc."netdata/python.d/web_log.conf".text = '' - nginx_log3: - name: 'nginx' - path: '/var/spool/nginx/logs/access.log' - nginx_log4: - name: 'bgt' - path: '${bgtaccess}' - ''; - - users.users.netdata.extraGroups = [ "nginx" ]; - } -- cgit v1.2.3 From a54974412751c98dec78b5e3977afc4a97aadea9 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 18 Nov 2020 20:50:43 +0100 Subject: ma bureautomation: move to 20.09 style imports --- .../bureautomation/automation/bureau-shutdown.nix | 157 ++++++++++---------- .../bureautomation/automation/hass-restart.nix | 65 +++++---- .../bureautomation/automation/nachtlicht.nix | 71 ++++----- .../bureautomation/automation/schlechteluft.nix | 130 +++++++++-------- .../bureautomation/binary_sensor/buttons.nix | 9 +- .../bureautomation/binary_sensor/motion.nix | 27 ++-- makefu/2configs/bureautomation/camera/comic.nix | 23 +-- .../2configs/bureautomation/camera/stuttgart.nix | 42 +++--- .../bureautomation/camera/verkehrskamera.nix | 31 ++-- makefu/2configs/bureautomation/default.nix | 92 +++++------- .../bureautomation/device_tracker/openwrt.nix | 29 ++-- makefu/2configs/bureautomation/light/buzzer.nix | 12 +- .../2configs/bureautomation/light/statuslight.nix | 14 +- .../2configs/bureautomation/multi/10h_timers.nix | 16 ++- makefu/2configs/bureautomation/multi/README.md | 3 - makefu/2configs/bureautomation/multi/aramark.nix | 21 +-- .../bureautomation/multi/daily-standup.nix | 83 +++++------ makefu/2configs/bureautomation/multi/frosch.nix | 158 +++++++++++---------- makefu/2configs/bureautomation/multi/matrix.nix | 106 +++++++------- .../2configs/bureautomation/multi/mittagessen.nix | 93 ++++++------ makefu/2configs/bureautomation/person/team.nix | 147 +++++++++---------- .../2configs/bureautomation/script/multi_blink.nix | 73 +++++----- .../2configs/bureautomation/sensor/airquality.nix | 21 +-- makefu/2configs/bureautomation/sensor/espeasy.nix | 12 +- makefu/2configs/bureautomation/sensor/influxdb.nix | 18 --- makefu/2configs/bureautomation/sensor/outside.nix | 54 +++---- .../bureautomation/sensor/tasmota_firmware.nix | 5 +- makefu/2configs/bureautomation/switch/rfbridge.nix | 16 ++- .../bureautomation/switch/tasmota_switch.nix | 17 ++- 29 files changed, 794 insertions(+), 751 deletions(-) delete mode 100644 makefu/2configs/bureautomation/multi/README.md delete mode 100644 makefu/2configs/bureautomation/sensor/influxdb.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix index b9aa710c3..f4c10adc8 100644 --- a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix +++ b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix @@ -1,84 +1,87 @@ -[ - { 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 +{ + services.home-assistant.config.automation = + [ + { alias = "Turn on Fernseher on group home"; + trigger = { 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 = [ + from = "not_home"; + to = "home"; + for.seconds = 30; + }; + action = [ + { + service = "homeassistant.turn_on"; + entity_id = [ + "switch.fernseher" + "switch.feuer" + ]; + } { - 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" ]; + service = "media_player.kodi_call_method"; + data = { + entity_id = "media_player.kodi"; + method = "Player.Open"; + item.partymode = "music"; + }; } - { # if anybody is still there - condition = "state"; + { + 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"; - state = "not_home"; + 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/makefu/2configs/bureautomation/automation/hass-restart.nix b/makefu/2configs/bureautomation/automation/hass-restart.nix index be16f6966..3b3ce0599 100644 --- a/makefu/2configs/bureautomation/automation/hass-restart.nix +++ b/makefu/2configs/bureautomation/automation/hass-restart.nix @@ -1,31 +1,34 @@ -[ - { 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"; - # }; - #} - ]; - } -] +{ + 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/makefu/2configs/bureautomation/automation/nachtlicht.nix b/makefu/2configs/bureautomation/automation/nachtlicht.nix index ec6fa20c7..ade89418d 100644 --- a/makefu/2configs/bureautomation/automation/nachtlicht.nix +++ b/makefu/2configs/bureautomation/automation/nachtlicht.nix @@ -1,35 +1,38 @@ -[ - # 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; +{ + 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" ]; - }; - } -] + }; + 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/makefu/2configs/bureautomation/automation/schlechteluft.nix b/makefu/2configs/bureautomation/automation/schlechteluft.nix index 370334743..ea1d44515 100644 --- a/makefu/2configs/bureautomation/automation/schlechteluft.nix +++ b/makefu/2configs/bureautomation/automation/schlechteluft.nix @@ -1,71 +1,75 @@ let long_threshold = 30; -in [ - { - 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"; +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" + ]; } ]; - }; - - 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"; + } ]; - } - ]; - } - { - 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"; + }; + + action = [ + { service = "homeassistant.turn_on"; + entity_id = [ + "script.schlechteluft" + ]; } - { condition = "time"; - after = "06:00:00"; - before = "20:00:00"; + { 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"; + }; } ]; - }; - - 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/makefu/2configs/bureautomation/binary_sensor/buttons.nix b/makefu/2configs/bureautomation/binary_sensor/buttons.nix index e23c4a362..20590a6b3 100644 --- a/makefu/2configs/bureautomation/binary_sensor/buttons.nix +++ b/makefu/2configs/bureautomation/binary_sensor/buttons.nix @@ -12,6 +12,9 @@ let # expire_after = "5"; #expire after 5 seconds qos = 1; }; -in [ - (tasmota_button "RedButton" "redbutton") -] +in { + services.home-assistant.config.binary_sensor = + [ + (tasmota_button "RedButton" "redbutton") + ]; +} diff --git a/makefu/2configs/bureautomation/binary_sensor/motion.nix b/makefu/2configs/bureautomation/binary_sensor/motion.nix index ad8fab038..0c5a808e0 100644 --- a/makefu/2configs/bureautomation/binary_sensor/motion.nix +++ b/makefu/2configs/bureautomation/binary_sensor/motion.nix @@ -1,12 +1,15 @@ -[ - { platform = "mqtt"; - device_class = "motion"; - name = "Motion"; - state_topic = "/bam/easy2/movement/Switch"; - payload_on = "1"; - payload_off = "0"; - availability_topic = "/bam/easy2/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - } -] +{ + services.home-assistant.config.binary_sensor = + [ + { platform = "mqtt"; + device_class = "motion"; + name = "Motion"; + state_topic = "/bam/easy2/movement/Switch"; + payload_on = "1"; + payload_off = "0"; + availability_topic = "/bam/easy2/tele/LWT"; + payload_available = "Online"; + payload_not_available = "Offline"; + } + ]; +} diff --git a/makefu/2configs/bureautomation/camera/comic.nix b/makefu/2configs/bureautomation/camera/comic.nix index a523d032e..ae24760e3 100644 --- a/makefu/2configs/bureautomation/camera/comic.nix +++ b/makefu/2configs/bureautomation/camera/comic.nix @@ -1,10 +1,13 @@ -[ - { 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 ; - } -] +{ + 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/makefu/2configs/bureautomation/camera/stuttgart.nix b/makefu/2configs/bureautomation/camera/stuttgart.nix index 78cbeb3e2..0badcb285 100644 --- a/makefu/2configs/bureautomation/camera/stuttgart.nix +++ b/makefu/2configs/bureautomation/camera/stuttgart.nix @@ -5,22 +5,26 @@ let inherit name still_image_url; platform = "generic"; }; -in [ - ( 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 ) -] +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/makefu/2configs/bureautomation/camera/verkehrskamera.nix b/makefu/2configs/bureautomation/camera/verkehrskamera.nix index f2dfdcd91..f09dc9423 100644 --- a/makefu/2configs/bureautomation/camera/verkehrskamera.nix +++ b/makefu/2configs/bureautomation/camera/verkehrskamera.nix @@ -1,14 +1,17 @@ -[ - { 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 ; - } -] +{ + 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/makefu/2configs/bureautomation/default.nix b/makefu/2configs/bureautomation/default.nix index cd598f0aa..7e8b6a4d3 100644 --- a/makefu/2configs/bureautomation/default.nix +++ b/makefu/2configs/bureautomation/default.nix @@ -1,20 +1,51 @@ { config, pkgs, lib, ... }: let kodi-host = "192.168.8.11"; - ten_hours = import ./multi/10h_timers.nix { inherit lib; }; # provides: timer automation script - mittagessen = import ./multi/mittagessen.nix { inherit lib; }; # provides: automation script - matrix = import ./multi/matrix.nix { inherit lib; }; # provides: matrix automation - frosch = import ./multi/frosch.nix { inherit lib; }; # provides: sensor binary_sensor switch light script automation - aramark = import ./multi/aramark.nix { inherit lib; }; # provides: sensor binary_sensor - standup = import ./multi/daily-standup.nix { inherit lib; }; # provides: automation script in { imports = [ ./ota.nix ./comic-updater.nix ./puppy-proxy.nix + + # hass config + ## complex configs + ./multi/daily-standup.nix + ./multi/aramark.nix + ./multi/matrix.nix + ./multi/frosch.nix + ./multi/mittagessen.nix + ./multi/10h_timers.nix + + ./switch/tasmota_switch.nix + ./switch/rfbridge.nix + + ./light/statuslight.nix + ./light/buzzer.nix + + ./script/multi_blink.nix + + ./binary_sensor/buttons.nix + ./binary_sensor/motion.nix + + # ./sensor/pollen.nix requires dwd_pollen + ./sensor/espeasy.nix + ./sensor/airquality.nix + ./sensor/outside.nix + ./sensor/tasmota_firmware.nix + + ./camera/verkehrskamera.nix + ./camera/comic.nix + ./camera/stuttgart.nix + ./automation/bureau-shutdown.nix + ./automation/nachtlicht.nix + ./automation/schlechteluft.nix + ./automation/hass-restart.nix + ./device_tracker/openwrt.nix + ./person/team.nix ]; networking.firewall.allowedTCPPorts = [ 8123 ]; state = [ "/var/lib/hass/known_devices.yaml" ]; + services.home-assistant = { enable = true; autoExtraComponents = true; @@ -51,7 +82,6 @@ in { source = "hass"; }; }; - matrix = matrix.matrix; mqtt = { discovery = true; discovery_prefix = "homeassistant"; @@ -73,13 +103,6 @@ in { retain = true; }; }; - switch = (import ./switch/tasmota_switch.nix) - ++ frosch.switch - ++ (import ./switch/rfbridge.nix); - light = (import ./light/statuslight.nix) - ++ (import ./light/buzzer.nix) - ++ frosch.light; - timer = ten_hours.timer; notify = [ { platform = "kodi"; @@ -93,7 +116,7 @@ in { (builtins.fromJSON (builtins.readFile )).allowed_chat_ids 0; } - ] ++ matrix.notify; + ]; media_player = [ { platform = "kodi"; host = kodi-host; @@ -102,37 +125,10 @@ in { host = "127.0.0.1"; } ]; - script = lib.fold lib.recursiveUpdate {} [ - ((import ./script/multi_blink.nix) {inherit lib;}) - frosch.script - ten_hours.script - mittagessen.script - # standup.script - ]; - binary_sensor = - (import ./binary_sensor/buttons.nix) - ++ (import ./binary_sensor/motion.nix) - ++ frosch.binary_sensor - ++ aramark.binary_sensor; - sensor = [] - ++ [{ platform = "version"; }] # pyhaversion - # ++ (import ./sensor/pollen.nix) - ++ (import ./sensor/espeasy.nix) - ++ (import ./sensor/airquality.nix) - ++ ((import ./sensor/outside.nix) {inherit lib;}) - ++ (import ./sensor/influxdb.nix) - ++ (import ./sensor/tasmota_firmware.nix) - ++ frosch.sensor - ++ aramark.sensor; + sensor = [{ platform = "version"; }]; # pyhaversion - camera = - (import ./camera/verkehrskamera.nix) - ++ (import ./camera/comic.nix) - ++ (import ./camera/stuttgart.nix); - person = - (import ./person/team.nix ); frontend = { }; http = { @@ -263,16 +259,6 @@ in { # feedreader.urls = [ "http://www.heise.de/security/rss/news-atom.xml" ]; # we don't use imports because the expressions do not merge in # home-assistant - automation = (import ./automation/bureau-shutdown.nix) - ++ (import ./automation/nachtlicht.nix) - ++ (import ./automation/schlechteluft.nix) - ++ (import ./automation/hass-restart.nix) - ++ ten_hours.automation - ++ matrix.automation - # ++ standup.automation - ++ frosch.automation - ++ mittagessen.automation; - device_tracker = (import ./device_tracker/openwrt.nix ); }; }; } diff --git a/makefu/2configs/bureautomation/device_tracker/openwrt.nix b/makefu/2configs/bureautomation/device_tracker/openwrt.nix index 5de216474..6b0144129 100644 --- a/makefu/2configs/bureautomation/device_tracker/openwrt.nix +++ b/makefu/2configs/bureautomation/device_tracker/openwrt.nix @@ -1,16 +1,19 @@ # requires `opkg install luci-mod-rpc` on router # see https://www.home-assistant.io/components/luci/ -[ - { platform = "luci"; - host = "192.168.8.1"; - username = "root"; - password = import ; - interval_seconds = 30; # instead of 12seconds - consider_home = 300; # 5 minutes timeout - new_device_defaults = { - track_new_devices = true; - hide_if_away = false; - }; - } -] +{ + services.home-assistant.config.device_tracker = + [ + { platform = "luci"; + host = "192.168.8.1"; + username = "root"; + password = import ; + interval_seconds = 30; # instead of 12seconds + consider_home = 300; # 5 minutes timeout + new_device_defaults = { + track_new_devices = true; + hide_if_away = false; + }; + } + ]; +} diff --git a/makefu/2configs/bureautomation/light/buzzer.nix b/makefu/2configs/bureautomation/light/buzzer.nix index 2067e47bf..bc2ba4e57 100644 --- a/makefu/2configs/bureautomation/light/buzzer.nix +++ b/makefu/2configs/bureautomation/light/buzzer.nix @@ -21,8 +21,10 @@ let optimistic = false; qos = 0; }; -in -[ -# (tasmota_pwm "RedButton LED" "redbutton" 1 1023) #LED PWM1 - (tasmota_pwm "RedButton Buzzer" "redbutton" 2 512) #buzzer PWM2 -] +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/makefu/2configs/bureautomation/light/statuslight.nix b/makefu/2configs/bureautomation/light/statuslight.nix index c9d301758..de65a2379 100644 --- a/makefu/2configs/bureautomation/light/statuslight.nix +++ b/makefu/2configs/bureautomation/light/statuslight.nix @@ -48,9 +48,11 @@ let 12 # fire pattern ]; }; -in -[ - (tasmota_rgb "Status Felix" "status1") - (tasmota_rgb "Status Daniel" "status2") - (tasmota_rgb "Buslicht" "buslicht") -] +in { + services.home-assistant.config.light = + [ + (tasmota_rgb "Status Felix" "status1") + (tasmota_rgb "Status Daniel" "status2") + (tasmota_rgb "Buslicht" "buslicht") + ]; +} diff --git a/makefu/2configs/bureautomation/multi/10h_timers.nix b/makefu/2configs/bureautomation/multi/10h_timers.nix index a30fb28b0..6edcde4b0 100644 --- a/makefu/2configs/bureautomation/multi/10h_timers.nix +++ b/makefu/2configs/bureautomation/multi/10h_timers.nix @@ -198,11 +198,13 @@ let ]; in { - 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) - ); + 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/makefu/2configs/bureautomation/multi/README.md b/makefu/2configs/bureautomation/multi/README.md deleted file mode 100644 index baad87fda..000000000 --- a/makefu/2configs/bureautomation/multi/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Combination Folder -files return a dictionary of different types used in home-assistant instead of -a single thing. diff --git a/makefu/2configs/bureautomation/multi/aramark.nix b/makefu/2configs/bureautomation/multi/aramark.nix index ebe2cde81..45fadb082 100644 --- a/makefu/2configs/bureautomation/multi/aramark.nix +++ b/makefu/2configs/bureautomation/multi/aramark.nix @@ -12,13 +12,16 @@ let ((aramark "${menue}/price" "${menue} Preis") // { unit_of_measurement = "€"; }) ]; in -{ - 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"; }) - ]; + { + 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/makefu/2configs/bureautomation/multi/daily-standup.nix b/makefu/2configs/bureautomation/multi/daily-standup.nix index 38fb22c1a..063def1ef 100644 --- a/makefu/2configs/bureautomation/multi/daily-standup.nix +++ b/makefu/2configs/bureautomation/multi/daily-standup.nix @@ -1,4 +1,4 @@ -{ lib }: +{lib, ... }: let random_daily_text = ''{{ [ "Es ist so weit, es ist Standup Zeit!", @@ -9,46 +9,49 @@ let "Morgens, halb elf in Deutschland - das Standupchen" ] | random }}''; in { - script = - { "random_daily" = { - alias = "Random Daily Introduction"; + 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"; + 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"; + }; + } + ]; }; - action = - [ - { service = "homeassistant.turn_on"; - entity_id = [ - "script.blitz_10s" - "script.random_daily" - ]; - } - ]; + }; + 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/makefu/2configs/bureautomation/multi/frosch.nix b/makefu/2configs/bureautomation/multi/frosch.nix index 816539d46..61606d4eb 100644 --- a/makefu/2configs/bureautomation/multi/frosch.nix +++ b/makefu/2configs/bureautomation/multi/frosch.nix @@ -1,4 +1,4 @@ -{ lib }: +{lib, ... }: # needs: binary_sensor.pommes # notify.matrix_notify let @@ -17,83 +17,87 @@ let "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 { - 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"; +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; + } + ]; }; - 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/makefu/2configs/bureautomation/multi/matrix.nix b/makefu/2configs/bureautomation/multi/matrix.nix index 4fcfe8da4..b9b8fc4e8 100644 --- a/makefu/2configs/bureautomation/multi/matrix.nix +++ b/makefu/2configs/bureautomation/multi/matrix.nix @@ -8,58 +8,62 @@ # name: my_command let mom_room = "!kTQjvTQvfVsvfEtmth:thales.citadel.team"; -in { - matrix = +in +{ + services.home-assistant.config = { - # 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 - )); - automation = [ + matrix = { - 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}}''; - }; - } + # 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 + )); + 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; - }]; + ]; + notify = [{ + name = "matrix_notify"; + platform = "matrix"; + default_room = mom_room; + }]; + }; } diff --git a/makefu/2configs/bureautomation/multi/mittagessen.nix b/makefu/2configs/bureautomation/multi/mittagessen.nix index 2a9993e92..52ec99a92 100644 --- a/makefu/2configs/bureautomation/multi/mittagessen.nix +++ b/makefu/2configs/bureautomation/multi/mittagessen.nix @@ -38,52 +38,55 @@ let "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 { - automation = [ - { alias = "Mittagessen"; - trigger = { - platform = "time"; - at = "12:30:00"; +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"; + }; + } + ]; }; - 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/makefu/2configs/bureautomation/person/team.nix b/makefu/2configs/bureautomation/person/team.nix index 2a15abaf5..124e85536 100644 --- a/makefu/2configs/bureautomation/person/team.nix +++ b/makefu/2configs/bureautomation/person/team.nix @@ -1,72 +1,75 @@ -[ - { name = "Thorsten"; - id = 1; - device_trackers = [ - "device_tracker.thorsten_phone" - #"device_tracker.thorsten_arbeitphone" - ]; - } - { name = "Felix"; - id = 2; - device_trackers = [ - "device_tracker.felix_phone" - "device_tracker.felix_laptop" - ]; - } - { name = "Ecki"; - id = 3; - device_trackers = [ - "device_tracker.ecki_phone" - "device_tracker.ecki_tablet" - ]; - } - { name = "Daniel"; - id = 4; - device_trackers = [ - "device_tracker.daniel_phone" - ]; - } - { name = "Thierry"