From 80c2ab739d2d51bf47b07fd6f39508a85077b0e6 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 3 Feb 2019 23:17:52 +0100 Subject: ma dict: actually use the dict server --- makefu/2configs/dict.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/dict.nix b/makefu/2configs/dict.nix index 6db9102b..08f1f850 100644 --- a/makefu/2configs/dict.nix +++ b/makefu/2configs/dict.nix @@ -1,5 +1,6 @@ { pkgs, ... }: { + environment.shellAliases.dict = "dict -h 127.0.0.1"; services.dictd.enable = true; services.dictd.DBs = with pkgs.dictdDBs; [ wiktionary wordnet deu2eng eng2deu ]; } -- cgit v1.2.3 From 0b668099468313b4547e1044efdc380d58e1d43e Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 5 Feb 2019 22:32:28 +0100 Subject: ma flameshot: init --- makefu/2configs/home-manager/desktop.nix | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/home-manager/desktop.nix b/makefu/2configs/home-manager/desktop.nix index 3be020fa..63a5cdbe 100644 --- a/makefu/2configs/home-manager/desktop.nix +++ b/makefu/2configs/home-manager/desktop.nix @@ -11,6 +11,15 @@ services.network-manager-applet.enable = true; services.blueman-applet.enable = true; services.pasystray.enable = true; + services.flameshot.enable = true; + home.file.".config/Dharkael/flameshot.ini".text = '' + [General] + disabledTrayIcon=false + drawColor=@Variant(\0\0\0\x43\x1\xff\xff\0\0\0\0\xff\xff\0\0) + drawThickness=0 + filenamePattern=%F_%T_shot + ''; + systemd.user.services.pasystray.Service.Environment = "PATH=" + (lib.makeBinPath (with pkgs;[ pavucontrol paprefs /* pavumeter */ /* paman */ ]) ); programs.chromium = { enable = true; -- cgit v1.2.3 From 0132d371e6403f19bd8d188e8af836c9303db3fc Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 5 Feb 2019 22:33:09 +0100 Subject: ma zsh: revert back to TERM=xterm --- makefu/2configs/home-manager/zsh.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/home-manager/zsh.nix b/makefu/2configs/home-manager/zsh.nix index 59658e66..6c7b632e 100644 --- a/makefu/2configs/home-manager/zsh.nix +++ b/makefu/2configs/home-manager/zsh.nix @@ -86,7 +86,8 @@ share = true; }; sessionVariables = { - TERM = "rxvt-unicode-256color"; + # TERM = "rxvt-unicode-256color"; + TERM = "xterm"; LANG = "en_US.UTF8"; LS_COLORS = ":di=1;31:"; EDITOR = "vim"; -- cgit v1.2.3 From 6dc21884dcc140922c8c2e295a2ed026becdab30 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 5 Feb 2019 22:33:26 +0100 Subject: ma homeautomation: permit Insecure homeassistant --- makefu/2configs/homeautomation/default.nix | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix index 596d0002..2af311c3 100644 --- a/makefu/2configs/homeautomation/default.nix +++ b/makefu/2configs/homeautomation/default.nix @@ -257,4 +257,8 @@ in { enable = true; #configDir = "/var/lib/hass"; }; + nixpkgs.config.permittedInsecurePackages = [ + "homeassistant-0.77.2" + ]; + } -- cgit v1.2.3 From c9314cac8226da1d422ca5d3c73dab3fbb42513a Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 5 Feb 2019 22:33:54 +0100 Subject: ma tools: move at_spi2_core to gui --- makefu/2configs/tools/core-gui.nix | 1 + makefu/2configs/tools/core.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/tools/core-gui.nix b/makefu/2configs/tools/core-gui.nix index 1e85da53..582d941a 100644 --- a/makefu/2configs/tools/core-gui.nix +++ b/makefu/2configs/tools/core-gui.nix @@ -2,6 +2,7 @@ { users.users.makefu.packages = with pkgs; [ + at_spi2_core chromium feh clipit diff --git a/makefu/2configs/tools/core.nix b/makefu/2configs/tools/core.nix index 33e896d4..b4c3a431 100644 --- a/makefu/2configs/tools/core.nix +++ b/makefu/2configs/tools/core.nix @@ -8,7 +8,6 @@ ( pkgs.writeScriptBin "unknow" ''#!/bin/sh ${gnused}/bin/sed -i "''${1}d" ~/.ssh/known_hosts '') - at_spi2_core acpi bc rsync @@ -17,6 +16,7 @@ ${gnused}/bin/sed -i "''${1}d" ~/.ssh/known_hosts lsof which binutils + screen # fs cifs-utils -- cgit v1.2.3 From 7f0354f2bae42e9eb6a341c079aeadfa1fc88e5b Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 8 Feb 2019 15:14:54 +0100 Subject: ma tools/games: disable steam (for now) --- makefu/2configs/tools/games.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/tools/games.nix b/makefu/2configs/tools/games.nix index 40ea4523..0f1e6179 100644 --- a/makefu/2configs/tools/games.nix +++ b/makefu/2configs/tools/games.nix @@ -2,7 +2,7 @@ { imports = [ - ./steam.nix + # ./steam.nix ]; users.users.makefu.packages = with pkgs; [ games-user-env -- cgit v1.2.3 From 6788519e4be7390c76bffacadd05d49f8fc3cace Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 8 Feb 2019 15:17:23 +0100 Subject: ma x: enable remote builder --- makefu/2configs/remote-build/gum.nix | 15 +++++++++++++++ makefu/2configs/remote-build/slave.nix | 1 + 2 files changed, 16 insertions(+) create mode 100644 makefu/2configs/remote-build/gum.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/remote-build/gum.nix b/makefu/2configs/remote-build/gum.nix new file mode 100644 index 00000000..98e2e58b --- /dev/null +++ b/makefu/2configs/remote-build/gum.nix @@ -0,0 +1,15 @@ +{ + nix = { + distributedBuilds = true; + buildMachines = [ + { + hostName = "gum.krebsco.de"; + maxJobs = 8; + sshKey = toString ; + sshUser = "nixBuild"; + system = "x86_64-linux"; + supportedFeatures = [ ]; + } + ]; + }; +} diff --git a/makefu/2configs/remote-build/slave.nix b/makefu/2configs/remote-build/slave.nix index 89121ffd..0227f512 100644 --- a/makefu/2configs/remote-build/slave.nix +++ b/makefu/2configs/remote-build/slave.nix @@ -5,6 +5,7 @@ useDefaultShell = true; openssh.authorizedKeys.keys = [ config.krebs.users.buildbotSlave.pubkey + config.krebs.users.makefu-remote-builder.pubkey ]; }; } -- cgit v1.2.3 From 7661181528df06f3b7e15128c1efcb6ac1854f31 Mon Sep 17 00:00:00 2001 From: makefu Date: Sat, 9 Feb 2019 23:19:53 +0100 Subject: ma google-muell: bump to latest version, use new config --- makefu/2configs/homeautomation/google-muell.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/homeautomation/google-muell.nix b/makefu/2configs/homeautomation/google-muell.nix index 235cc154..5870f298 100644 --- a/makefu/2configs/homeautomation/google-muell.nix +++ b/makefu/2configs/homeautomation/google-muell.nix @@ -3,13 +3,20 @@ with import ; let pkg = pkgs.ampel; home = "/var/lib/ampel"; - sec = "${toString }/google-muell.json"; + sec = "${toString }/ampel/google-muell.json"; ampelsec = "${home}/google-muell.json"; - cred = "${toString }/google-muell-creds.json"; + cred = "${toString }/ampel/google-muell-creds.json"; # TODO: generate this credential file locally ampelcred = "${home}/google-muell-creds.json"; - esp = "192.168.8.204"; sleepval = "1800"; + default-color = "244,220,66"; + config_json = toFile "config.json" (toJSON { + mq_hostname = "localhost"; + mq_port = 1883; + mq_username = "sensor"; + mq_topic = "/ham/flurlicht/cmnd/MEM1"; + mq_password = replaceChars ["\n"] [""] (readFile "${toString }/mqtt/sensor"); + }); in { users.users.ampel = { uid = genid "ampel"; @@ -27,7 +34,7 @@ in { install -m600 -o ampel ${sec} ${ampelsec} install -m600 -o ampel ${cred} ${ampelcred} ''; - ExecStart = "${pkg}/bin/google-muell --esp=${esp} --client-secrets=${ampelsec} --credential-path=${ampelcred} --sleepval=${sleepval}"; + ExecStart = "${pkg}/bin/google-muell --config ${config_json} --default-color=${default-color} --client-secrets=${ampelsec} --credential-path=${ampelcred} --sleepval=${sleepval}"; PermissionsStartOnly = true; Restart = "always"; RestartSec = 10; -- cgit v1.2.3 From d64c6bb976f61b2173a2c170ea1ba6f26c57147e Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 10 Feb 2019 09:53:45 +0100 Subject: Revert "ma cgit: disable irc hook" This reverts commit 1f8ad80695e93687999b8151ddd2e7f2c40b085b. --- makefu/2configs/git/cgit-retiolum.nix | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/git/cgit-retiolum.nix b/makefu/2configs/git/cgit-retiolum.nix index 4890e4af..0ff85598 100644 --- a/makefu/2configs/git/cgit-retiolum.nix +++ b/makefu/2configs/git/cgit-retiolum.nix @@ -62,6 +62,15 @@ let make-krebs-repo = with git; name: { cgit ? {}, ... }: { inherit cgit name; public = true; + hooks = { + post-receive = pkgs.git-hooks.irc-announce { + nick = config.networking.hostName; + verbose = config.krebs.build.host.name == "gum"; + channel = "#xxx"; + # TODO remove the hardcoded hostname + server = "irc.r"; + }; + }; }; -- cgit v1.2.3 From 9c702551abbf5c486d9dac3becc4d5e998511a52 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 6 Mar 2019 16:42:27 +0100 Subject: ma bureautomation: split into files --- .../bureautomation/automation/10h_timer.nix | 147 ++++++++++ .../bureautomation/automation/bureau-shutdown.nix | 55 ++++ .../bureautomation/automation/nachtlicht.nix | 43 +++ .../bureautomation/binary_sensor/buttons.nix | 17 ++ .../bureautomation/binary_sensor/motion.nix | 12 + .../bureautomation/camera/verkehrskamera.nix | 14 + makefu/2configs/bureautomation/hass.nix | 315 ++++----------------- makefu/2configs/bureautomation/led-fader.nix | 23 ++ makefu/2configs/bureautomation/light/buzzer.nix | 28 ++ .../2configs/bureautomation/light/statuslight.nix | 56 ++++ .../2configs/bureautomation/script/multi_blink.nix | 37 +++ makefu/2configs/bureautomation/sensor/espeasy.nix | 31 ++ makefu/2configs/bureautomation/sensor/influxdb.nix | 18 ++ makefu/2configs/bureautomation/sensor/outside.nix | 25 ++ .../bureautomation/switch/tasmota_switch.nix | 19 ++ makefu/2configs/deployment/led-fader.nix | 23 -- 16 files changed, 580 insertions(+), 283 deletions(-) create mode 100644 makefu/2configs/bureautomation/automation/10h_timer.nix create mode 100644 makefu/2configs/bureautomation/automation/bureau-shutdown.nix create mode 100644 makefu/2configs/bureautomation/automation/nachtlicht.nix create mode 100644 makefu/2configs/bureautomation/binary_sensor/buttons.nix create mode 100644 makefu/2configs/bureautomation/binary_sensor/motion.nix create mode 100644 makefu/2configs/bureautomation/camera/verkehrskamera.nix create mode 100644 makefu/2configs/bureautomation/led-fader.nix create mode 100644 makefu/2configs/bureautomation/light/buzzer.nix create mode 100644 makefu/2configs/bureautomation/light/statuslight.nix create mode 100644 makefu/2configs/bureautomation/script/multi_blink.nix create mode 100644 makefu/2configs/bureautomation/sensor/espeasy.nix create mode 100644 makefu/2configs/bureautomation/sensor/influxdb.nix create mode 100644 makefu/2configs/bureautomation/sensor/outside.nix create mode 100644 makefu/2configs/bureautomation/switch/tasmota_switch.nix delete mode 100644 makefu/2configs/deployment/led-fader.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/bureautomation/automation/10h_timer.nix b/makefu/2configs/bureautomation/automation/10h_timer.nix new file mode 100644 index 00000000..a311d468 --- /dev/null +++ b/makefu/2configs/bureautomation/automation/10h_timer.nix @@ -0,0 +1,147 @@ +[ + { alias = "start Felix 10h"; + trigger = { + platform = "state"; + entity_id = "binary_sensor.redbutton"; + to = "on"; + }; + condition = { + condition = "and"; + conditions = [ + { + condition = "state"; + entity_id = "timer.felix_10h"; + state = "idle"; + } + { + condition = "time"; + after = "06:00:00"; + before = "12:00:00"; + } + ]; + }; + action = [ + { service = "timer.start"; + entity_id = [ "timer.felix_10h" "timer.felix_8_30h" "timer.felix_7h" ] ; + } + { service = "homeassistant.turn_on"; + entity_id = [ + "script.buzz_red_led_fast" + "script.blitz_10s" + ]; + } + { service = "light.turn_on"; + data = { + effect = "2"; + entity_id = [ "light.status_felix" ]; + }; + } + ]; + } + + { alias = "Disable Felix timer at button press"; + trigger = { + platform = "state"; + entity_id = "binary_sensor.redbutton"; + to = "on"; + }; + condition = { + condition = "and"; + conditions = [ + { + condition = "state"; + entity_id = "timer.felix_10h"; + state = "active"; + } + { + condition = "time"; + after = "12:00:00"; + before = "22:00:00"; + } + ]; + }; + action = + [ + { + service = "timer.cancel"; + entity_id = [ "timer.felix_10h" "timer.felix_8_30h" "timer.felix_7h" ]; + } + { + service = "homeassistant.turn_on"; + entity_id = [ "script.buzz_red_led_fast" ]; + } + { + service = "homeassistant.turn_off"; + entity_id = [ "light.status_felix" ]; + } + ]; + } + + { + alias = "Genug gearbeitet Felix"; + trigger = + { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.felix_7h"; + }; + action = + [ + { service = "light.turn_on"; + data = { + rgb_color= [0 255 0]; + # effect = "0"; + entity_id = [ "light.status_felix" ]; + }; + } + ]; + } + + { + alias = "nun aber nach hause"; + trigger = + { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.felix_8_30h"; + }; + action = + [ + { service = "light.turn_on"; + data = { + rgb_color= [255 255 0]; + # effect = "0"; + entity_id = [ "light.status_felix" ]; + }; + } + ]; + } + + { + alias = "Zu lange Felix!"; + trigger = + { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.felix_10h"; + }; + action = + [ + # TODO: Pushbullet + { + service = "homeassistant.turn_on"; + entity_id = [ + "script.buzz_red_led" + "script.blitz_10s" + ]; + } + { service = "light.turn_on"; + data = { + rgb_color= [255 0 0]; + effect = "0"; + entity_id = [ "light.status_felix" ]; + }; + } + ]; + } +] diff --git a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix new file mode 100644 index 00000000..9e657430 --- /dev/null +++ b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix @@ -0,0 +1,55 @@ +[ + { alias = "Turn on Fernseher on movement"; + trigger = { + platform = "state"; + entity_id = "binary_sensor.motion"; + to = "on"; + }; + action = { + service = "homeassistant.turn_on"; + entity_id = [ + "switch.fernseher" + "switch.feuer" + ]; + }; + } + { alias = "Turn off Fernseher 10 minutes after last movement"; + trigger = [ + { # trigger when movement was detected at the time + platform = "state"; + entity_id = "binary_sensor.motion"; + to = "off"; + for.minutes = 10; + } + { # trigger at 20: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" + ]; + }; + 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" ]; + } + { + condition = "state"; + entity_id = "binary_sensor.motion"; + state = "off"; + } + ]; + }; + } +] diff --git a/makefu/2configs/bureautomation/automation/nachtlicht.nix b/makefu/2configs/bureautomation/automation/nachtlicht.nix new file mode 100644 index 00000000..066e9b06 --- /dev/null +++ b/makefu/2configs/bureautomation/automation/nachtlicht.nix @@ -0,0 +1,43 @@ +[ + { + alias = "Turn off Nachtlicht on sunrise"; + trigger = + { + platform = "sun"; + event = "sunrise"; + }; + action = + { + service = "homeassistant.turn_off"; + entity_id = [ "switch.nachtlicht" ]; + }; + } + + { + alias = "Turn on Nachtlicht on motion and dusk"; + trigger = + { + platform = "state"; + entity_id = "binary_sensor.motion"; + to = "on"; + }; + condition = # 'when dark' + { + condition = "or"; + conditions = [ + { condition = "sun"; + after = "sunset"; + after_offset = "-00:45:00"; # on dusk + } + { condition = "sun"; + before = "sunrise"; + } + ]; + }; + action = + { + service = "homeassistant.turn_on"; + entity_id = [ "switch.nachtlicht" ]; + }; + } +] diff --git a/makefu/2configs/bureautomation/binary_sensor/buttons.nix b/makefu/2configs/bureautomation/binary_sensor/buttons.nix new file mode 100644 index 00000000..e23c4a36 --- /dev/null +++ b/makefu/2configs/bureautomation/binary_sensor/buttons.nix @@ -0,0 +1,17 @@ +let + tasmota_button = name: topic: + # detects a pushbutton press from tasmota + { platform = "mqtt"; + inherit name; + state_topic = "/bam/${topic}/cmnd/POWER"; + availability_topic = "/bam/${topic}/tele/LWT"; + payload_on = "ON"; + payload_off = "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + # expire_after = "5"; #expire after 5 seconds + qos = 1; + }; +in [ + (tasmota_button "RedButton" "redbutton") +] diff --git a/makefu/2configs/bureautomation/binary_sensor/motion.nix b/makefu/2configs/bureautomation/binary_sensor/motion.nix new file mode 100644 index 00000000..ad8fab03 --- /dev/null +++ b/makefu/2configs/bureautomation/binary_sensor/motion.nix @@ -0,0 +1,12 @@ +[ + { 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/verkehrskamera.nix b/makefu/2configs/bureautomation/camera/verkehrskamera.nix new file mode 100644 index 00000000..f2dfdcd9 --- /dev/null +++ b/makefu/2configs/bureautomation/camera/verkehrskamera.nix @@ -0,0 +1,14 @@ +[ + { 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/hass.nix b/makefu/2configs/bureautomation/hass.nix index b70c9b03..007d00b0 100644 --- a/makefu/2configs/bureautomation/hass.nix +++ b/makefu/2configs/bureautomation/hass.nix @@ -1,76 +1,5 @@ { pkgs, lib, ... }: 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 = false; - # state - # TODO: currently broken, will not use the custom state topic - state_topic = "/bam/${topic}/stat/POWER"; - command_topic = "/bam/${topic}/cmnd/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}/stat/Dimmer"; - brightness_command_topic = "/bam/${topic}/cmnd/Dimmer"; - brightness_value_template = "{{ value_json.Dimmer }}"; - brightness_scale = 100; - # color - rgb_state_topic = "/bam/${topic}/stat/Color"; - rgb_command_topic = "/bam/${topic}/cmnd/Color2"; - rgb_command_mode = "hex"; - rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; - # effects - effect_state_topic = "/bam/${topic}/stat/Scheme"; - effect_command_topic = "/bam/${topic}/cmnd/Scheme"; - effect_value_template = "{{ value_json.Scheme }}"; - effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]; -}; - tasmota_plug = name: topic: - { platform = "mqtt"; - inherit name; - state_topic = "/bam/${topic}/stat/POWER"; - command_topic = "/bam/${topic}/cmnd/POWER"; - availability_topic = "/bam/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - }; - espeasy_dht22 = name: [ - { platform = "mqtt"; - name = "${name} DHT22 Temperature"; - device_class = "temperature"; - state_topic = "/bam/${name}/dht22/Temperature"; - availability_topic = "/bam/${name}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - } - { platform = "mqtt"; - device_class = "humidity"; - name = "${name} DHT22 Humidity"; - state_topic = "/bam/${name}/dht22/Humidity"; - availability_topic = "/bam/${name}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - }]; - espeasy_ds18 = name: - { platform = "mqtt"; - name = "${name} DS18 Temperature"; - state_topic = "/bam/${name}/ds18/Temperature"; - availability_topic = "/bam/${name}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - }; in { networking.firewall.allowedTCPPorts = [ 8123 ]; @@ -104,90 +33,43 @@ in { retain = true; }; }; - switch = [ - (tasmota_plug "Bauarbeiterlampe" "plug") - (tasmota_plug "Blitzdings" "plug2") - (tasmota_plug "Fernseher" "plug3") - (tasmota_plug "Feuer" "plug4") - (tasmota_plug "Nachtlicht" "plug5") - ]; - light = [ - (tasmota_rgb "Status Felix" "status1") - ]; - 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"; + switch = (import ./switch/tasmota_switch.nix); + light = (import ./light/statuslight.nix) ++ + (import ./light/buzzer.nix); + timer = { + felix_10h = { + name = "Felix 10h Timer"; + duration = "10:00:00"; + }; + felix_8_30h = { + name = "Felix 8_30h Timer"; + duration = "08:30:00"; + }; + felix_7h = { + name = "Felix 7h Timer"; + duration = "07:00:00"; + }; + }; + notify = [ + { + platform = "kodi"; + name = "wbob"; + host = "192.168.8.11"; } ]; + script = (import ./script/multi_blink.nix) {inherit lib;}; + binary_sensor = + (import ./binary_sensor/buttons.nix) ++ + (import ./binary_sensor/motion.nix); + sensor = - (espeasy_dht22 "easy1") ++ - (espeasy_dht22 "easy2") ++ - [ (espeasy_ds18 "easy3" ) - { platform = "luftdaten"; - name = "Ditzingen"; - sensorid = "5341"; - monitored_conditions = [ "P1" "P2" ]; - } + (import ./sensor/espeasy.nix) ++ + ((import ./sensor/outside.nix) {inherit lib;}) ++ + (import ./sensor/influxdb.nix); + + camera = + (import ./camera/verkehrskamera.nix); - { platform = "darksky"; - api_key = lib.removeSuffix "\n" - (builtins.readFile ); - language = "de"; - monitored_conditions = [ "summary" "icon" - "nearest_storm_distance" "precip_probability" - "precip_intensity" - "temperature" # "temperature_high" "temperature_low" - "apparent_temperature" - "hourly_summary" # next 24 hours text - "humidity" - "pressure" - "uv_index" ]; - units = "si" ; - update_interval = { - days = 0; - hours = 0; - minutes = 30; - seconds = 0; - }; - } - #{ platform = "influxdb"; - # queries = [ - # { name = "mean value of feinstaub P1"; - # where = '' "node" = 'esp8266-1355142' ''; - # measurement = "feinstaub"; - # database = "telegraf"; - # field = "P1"; - # } - # { name = "mean value of feinstaub P2"; - # where = '' "node" = 'esp8266-1355142' ''; - # measurement = "feinstaub"; - # database = "telegraf"; - # field = "P2"; - # } - # ]; - #} - ]; - 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 ; - } - ]; frontend = { }; http = { }; conversation = {}; @@ -203,13 +85,14 @@ in { "group.outside" "group.switches" "group.automation" - "group.camera" + # "group.camera" ]; }; automation = [ - "automation.turn_off_fernseher_10_minutes_after_last_movement" - "automation.turn_off_nachtlicht_on_sunrise" - "automation.turn_on_nachtlicht_on_motion_and_dusk" + "timer.felix_10h" + "script.blitz_10s" + "script.buzz_red_led_fast" + "camera.Baumarkt" ]; switches = [ "switch.bauarbeiterlampe" @@ -218,125 +101,37 @@ in { "switch.feuer" "switch.nachtlicht" "light.status_felix" + "light.status_daniel" + "light.buslicht" + "light.redbutton_buzzer" ]; - camera = [ - "camera.Baumarkt" - "camera.Autobahn_Heilbronn" - "camera.Autobahn_Singen" - ]; + + camera = [ ]; sensors = [ "binary_sensor.motion" + "binary_sensor.redbutton" "sensor.easy2_dht22_humidity" "sensor.easy2_dht22_temperature" ]; outside = [ - "sensor.ditzingen_pm10" - "sensor.ditzingen_pm25" + # "sensor.ditzingen_pm10" + # "sensor.ditzingen_pm25" "sensor.dark_sky_temperature" "sensor.dark_sky_humidity" - "sensor.dark_sky_pressure" + # "sensor.dark_sky_pressure" "sensor.dark_sky_hourly_summary" - "sensor.dark_sky_minutely_summary" + "camera.Autobahn_Heilbronn" + "camera.Autobahn_Singen" ]; }; # only for automation # feedreader.urls = [ "http://www.heise.de/security/rss/news-atom.xml" ]; - automation = [ - { alias = "Turn on Fernseher on movement"; - trigger = { - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "on"; - }; - action = { - service = "homeassistant.turn_on"; - entity_id = [ - "switch.fernseher" - "switch.feuer" - "light.status_felix" - ]; - }; - } - { - alias = "Turn off Nachtlicht on sunrise"; - trigger = - { - platform = "sun"; - event = "sunrise"; - }; - action = - { - service = "homeassistant.turn_off"; - entity_id = [ "switch.nachtlicht" ]; - }; - } - { - alias = "Turn on Nachtlicht on motion and dusk"; - trigger = - { - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "on"; - }; - condition = # 'when dark' - { - condition = "or"; - conditions = [ - { condition = "sun"; - after = "sunset"; - after_offset = "-00:45:00"; # on dusk - } - { condition = "sun"; - before = "sunrise"; - } - ]; - }; - action = - { - service = "homeassistant.turn_on"; - entity_id = [ "switch.nachtlicht" ]; - }; - } - { alias = "Turn off Fernseher 10 minutes after last movement"; - trigger = [ - { # trigger when movement was detected at the time - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "off"; - for.minutes = 10; - } - { # trigger at 20: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" - ]; - }; - 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" ]; - } - { - condition = "state"; - entity_id = "binary_sensor.motion"; - state = "off"; - } - ]; - }; - } - ]; + # 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/10h_timer.nix); + }; }; } diff --git a/makefu/2configs/bureautomation/led-fader.nix b/makefu/2configs/bureautomation/led-fader.nix new file mode 100644 index 00000000..d7f72853 --- /dev/null +++ b/makefu/2configs/bureautomation/led-fader.nix @@ -0,0 +1,23 @@ +{ config, lib, pkgs, buildPythonPackage, ... }: + +let + mq = "192.168.8.11"; + pkg = pkgs.ampel; +in { + systemd.services.led-fader = { + description = "Send led change to message queue"; + environment = { + NIX_PATH = "/var/src"; + }; + after = [ "network-online.target" ] ++ (lib.optional config.services.mosquitto.enable "mosquitto.service"); + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + # User = "nobody"; # need a user with permissions to run nix-shell + ExecStartPre = pkgs.writeDash "sleep.sh" "sleep 2"; + ExecStart = "${pkg}/bin/ampel"; + Restart = "always"; + RestartSec = 10; + PrivateTmp = true; + }; + }; +} diff --git a/makefu/2configs/bureautomation/light/buzzer.nix b/makefu/2configs/bureautomation/light/buzzer.nix new file mode 100644 index 00000000..2067e47b --- /dev/null +++ b/makefu/2configs/bureautomation/light/buzzer.nix @@ -0,0 +1,28 @@ +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 +[ +# (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 new file mode 100644 index 00000000..3a9582f2 --- /dev/null +++ b/makefu/2configs/bureautomation/light/statuslight.nix @@ -0,0 +1,56 @@ +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 = false; + # state + # TODO: currently broken, will not use the custom state topic + state_topic = "/bam/${topic}/stat/POWER"; + command_topic = "/bam/${topic}/cmnd/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}/stat/Dimmer"; + brightness_command_topic = "/bam/${topic}/cmnd/Dimmer"; + brightness_value_template = "{{ value_json.Dimmer }}"; + brightness_scale = 100; + # color + rgb_state_topic = "/bam/${topic}/stat/Color"; + rgb_command_topic = "/bam/${topic}/cmnd/Color2"; + rgb_command_mode = "hex"; + rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; + # effects + effect_state_topic = "/bam/${topic}/stat/Scheme"; + effect_command_topic = "/bam/${topic}/cmnd/Scheme"; + effect_value_template = "{{ value_json.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 +[ + (tasmota_rgb "Status Felix" "status1") + (tasmota_rgb "Status Daniel" "status2") + (tasmota_rgb "Buslicht" "buslicht") +] diff --git a/makefu/2configs/bureautomation/script/multi_blink.nix b/makefu/2configs/bureautomation/script/multi_blink.nix new file mode 100644 index 00000000..bb28dd46 --- /dev/null +++ b/makefu/2configs/bureautomation/script/multi_blink.nix @@ -0,0 +1,37 @@ +{lib, ... }: +let + # 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 { + 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"; + }); +} diff --git a/makefu/2configs/bureautomation/sensor/espeasy.nix b/makefu/2configs/bureautomation/sensor/espeasy.nix new file mode 100644 index 00000000..4b78ee84 --- /dev/null +++ b/makefu/2configs/bureautomation/sensor/espeasy.nix @@ -0,0 +1,31 @@ +let + espeasy_dht22 = name: [ + { platform = "mqtt"; + name = "${name} DHT22 Temperature"; + device_class = "temperature"; + state_topic = "/bam/${name}/dht22/Temperature"; + availability_topic = "/bam/${name}/tele/LWT"; + payload_available = "Online"; + payload_not_available = "Offline"; + } + { platform = "mqtt"; + device_class = "humidity"; + name = "${name} DHT22 Humidity"; + state_topic = "/bam/${name}/dht22/Humidity"; + availability_topic = "/bam/${name}/tele/LWT"; + payload_available = "Online"; + payload_not_available = "Offline"; + }]; + espeasy_ds18 = name: + { platform = "mqtt"; + name = "${name} DS18 Temperature"; + state_topic = "/bam/${name}/ds18/Temperature"; + availability_topic = "/bam/${name}/tele/LWT"; + payload_available = "Online"; + payload_not_available = "Offline"; + }; +in +(espeasy_dht22 "easy1") ++ +(espeasy_dht22 "easy2") ++ [ + (espeasy_ds18 "easy3" ) +] diff --git a/makefu/2configs/bureautomation/sensor/influxdb.nix b/makefu/2configs/bureautomation/sensor/influxdb.nix new file mode 100644 index 00000000..820a56c4 --- /dev/null +++ b/makefu/2configs/bureautomation/sensor/influxdb.nix @@ -0,0 +1,18 @@ +[ + #{ platform = "influxdb"; + # queries = [ + # { name = "mean value of feinstaub P1"; + # where = '' "node" = 'esp8266-1355142' ''; + # measurement = "feinstaub"; + # database = "telegraf"; + # field = "P1"; + # } + # { name = "mean value of feinstaub P2"; + # where = '' "node" = 'esp8266-1355142' ''; + # measurement = "feinstaub"; + # database = "telegraf"; + # field = "P2"; + # } + # ]; + #} +] diff --git a/makefu/2configs/bureautomation/sensor/outside.nix b/makefu/2configs/bureautomation/sensor/outside.nix new file mode 100644 index 00000000..7dbc192a --- /dev/null +++ b/makefu/2configs/bureautomation/sensor/outside.nix @@ -0,0 +1,25 @@ +{lib,...}: [ + { platform = "darksky"; + api_key = lib.removeSuffix "\n" + (builtins.readFile ); + language = "de"; + monitored_conditions = [ + "summary" "icon" + "nearest_storm_distance" "precip_probability" + "precip_intensity" + "temperature" # "temperature_high" "temperature_low" + "apparent_temperature" + "hourly_summary" # next 24 hours text + "humidity" + "pressure" + "uv_index" + ]; + units = "si" ; + update_interval = { days = 0; hours = 0; minutes = 30; seconds = 0; }; + } + { platform = "luftdaten"; + name = "Ditzingen"; + sensorid = "5341"; + monitored_conditions = [ "P1" "P2" ]; + } + ] diff --git a/makefu/2configs/bureautomation/switch/tasmota_switch.nix b/makefu/2configs/bureautomation/switch/tasmota_switch.nix new file mode 100644 index 00000000..b00a8e45 --- /dev/null +++ b/makefu/2configs/bureautomation/switch/tasmota_switch.nix @@ -0,0 +1,19 @@ +let + tasmota_plug = name: topic: + { platform = "mqtt"; + inherit name; + state_topic = "/bam/${topic}/stat/POWER"; + command_topic = "/bam/${topic}/cmnd/POWER"; + availability_topic = "/bam/${topic}/tele/LWT"; + payload_on= "ON"; + payload_off= "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + }; +in [ + (tasmota_plug "Bauarbeiterlampe" "plug") + (tasmota_plug "Blitzdings" "plug2") + (tasmota_plug "Fernseher" "plug3") + (tasmota_plug "Feuer" "plug4") + (tasmota_plug "Nachtlicht" "plug5") +] diff --git a/makefu/2configs/deployment/led-fader.nix b/makefu/2configs/deployment/led-fader.nix deleted file mode 100644 index d34b6612..00000000 --- a/makefu/2configs/deployment/led-fader.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ config, lib, pkgs, buildPythonPackage, ... }: - -let - mq = "192.168.8.11"; - pkg = pkgs.ampel; -in { - systemd.services.led-fader = { - description = "Send led change to message queue"; - environment = { - NIX_PATH = "/var/src"; - }; - after = [ "network-online.target" ] ++ (lib.optional config.services.mosquitto.enable "mosquitto.service"); - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - # User = "nobody"; # need a user with permissions to run nix-shell - ExecStartPre = pkgs.writeDash "sleep.sh" "sleep 2"; - ExecStart = "${pkg}/bin/ampel 4"; - Restart = "always"; - RestartSec = 10; - PrivateTmp = true; - }; - }; -} -- cgit v1.2.3 From 7e9a2417ba27a19d6db0a87b075b9d55a237931a Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 6 Mar 2019 16:42:52 +0100 Subject: ma homeautomation: update google-muell --- makefu/2configs/homeautomation/default.nix | 65 ++++++++++++++++++++----- makefu/2configs/homeautomation/google-muell.nix | 3 +- 2 files changed, 55 insertions(+), 13 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix index 2af311c3..4e9ac0ee 100644 --- a/makefu/2configs/homeautomation/default.nix +++ b/makefu/2configs/homeautomation/default.nix @@ -55,7 +55,8 @@ let payload_not_available = "Offline"; }; - firetv = "192.168.1.238"; + firetv = "192.168.1.183"; + hassdir = "/var/lib/hass"; tasmota_plug = name: topic: { platform = "mqtt"; inherit name; @@ -105,13 +106,7 @@ in { imports = [ ./mqtt.nix ]; - #systemd.services.firetv = { - # wantedBy = [ "multi-user.target" ]; - # serviceConfig = { - # User = "nobody"; - # ExecStart = "${pkgs.python-firetv}/bin/firetv-server -d ${firetv}:5555"; - # }; - #}; + services.home-assistant = { config = { homeassistant = { @@ -133,9 +128,11 @@ in { { platform = "kodi"; host = firetv; } - #{ platform = "firetv"; - # # assumes python-firetv running - #} + { platform = "firetv"; + name = "FireTV Stick"; + host = firetv; + adbkey = ; + } ]; mqtt = { broker = "localhost"; @@ -211,9 +208,12 @@ in { flur = [ "light.flurlicht" "binary_sensor.flur_bewegung" + "automation.dunkel_bei_sonnenuntergang" + "automation.hell_bei_sonnenaufgang" ]; wohnzimmer = [ "media_player.kodi" + "media_player.firetv_stick" ]; draussen = [ "sensor.dark_sky_temperature" @@ -240,6 +240,47 @@ in { ]; light = [ (tasmota_rgb "Flurlicht" "flurlicht" ) ]; automation = [ + { alias = "Dunkel bei Sonnenuntergang"; + trigger = { + platform = "sun"; + event = "sunset"; + # offset: "-00:45:00" + }; + action = [ + { + service= "light.turn_on"; + data = { + entity_id= "light.flurlicht"; + # rgb_color = [ 0,0,0 ]; <-- TODO default color + brightness_pct = 15; + }; + } + { + service= "light.turn_off"; + entity_id= "light.flurlicht"; + } + ]; + } + { alias = "Hell bei Sonnenaufgang"; + trigger = { + platform = "sun"; + event = "sunrise"; + # offset: "-00:00:00" + }; + action = [ + { + service= "light.turn_on"; + data = { + entity_id= "light.flurlicht"; + brightness_pct = 85; + }; + } + { + service= "light.turn_off"; + entity_id= "light.flurlicht"; + } + ]; + } { alias = "Staubsauger Strom aus nach 6h"; trigger = { platform = "state"; @@ -255,7 +296,7 @@ in { ]; }; enable = true; - #configDir = "/var/lib/hass"; + configDir = hassdir; }; nixpkgs.config.permittedInsecurePackages = [ "homeassistant-0.77.2" diff --git a/makefu/2configs/homeautomation/google-muell.nix b/makefu/2configs/homeautomation/google-muell.nix index 5870f298..c81eae20 100644 --- a/makefu/2configs/homeautomation/google-muell.nix +++ b/makefu/2configs/homeautomation/google-muell.nix @@ -9,7 +9,8 @@ let # TODO: generate this credential file locally ampelcred = "${home}/google-muell-creds.json"; sleepval = "1800"; - default-color = "244,220,66"; + # default-color = "18,63,40"; + default-color = "255,127,0"; config_json = toFile "config.json" (toJSON { mq_hostname = "localhost"; mq_port = 1883; -- cgit v1.2.3 From f0b56730f21e14680261b2e3ddcdd438bbd15903 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 6 Mar 2019 16:44:36 +0100 Subject: ma save-diskspace: programs.info -> documentation.info --- makefu/2configs/save-diskspace.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/save-diskspace.nix b/makefu/2configs/save-diskspace.nix index 4fd56976..b6725e73 100644 --- a/makefu/2configs/save-diskspace.nix +++ b/makefu/2configs/save-diskspace.nix @@ -4,8 +4,8 @@ _: environment.noXlibs = true; nix.gc.automatic = true; nix.gc.dates = "03:10"; - programs.info.enable = false; - programs.man.enable = false; + documentation.info.enable = false; + documentation.man.enable = false; services.journald.extraConfig = "SystemMaxUse=50M"; services.nixosManual.enable = false; } -- cgit v1.2.3 From 6615696461195bbfbfd0fe7ae0d8ff8a4f0b8db1 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 6 Mar 2019 16:45:01 +0100 Subject: ma pkgs.init-host: init --- makefu/2configs/tools/dev.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/tools/dev.nix b/makefu/2configs/tools/dev.nix index 0c877fc7..fe25bd49 100644 --- a/makefu/2configs/tools/dev.nix +++ b/makefu/2configs/tools/dev.nix @@ -26,5 +26,6 @@ nix-review # git-related tig + init-host ]; } -- cgit v1.2.3 From 426bbeaf50fbe67d34ee43f4160058c74a3f11fe Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 13 Mar 2019 10:52:08 +0100 Subject: ma home-manager: add taskwarrior --- makefu/2configs/home-manager/taskwarrior.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 makefu/2configs/home-manager/taskwarrior.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/home-manager/taskwarrior.nix b/makefu/2configs/home-manager/taskwarrior.nix new file mode 100644 index 00000000..8ad16dcf --- /dev/null +++ b/makefu/2configs/home-manager/taskwarrior.nix @@ -0,0 +1,25 @@ +{pkgs, ... }: +let + loc = "/home/makefu/.task"; +in { + state = [ "${loc}/keys" ]; + home-manager.users.makefu.programs.taskwarrior = { + enable = true; + dataLocation = loc; + config = { + default.command = "list"; + taskd = { + server = "gum:53589"; + certificate = "${loc}/keys/public.crt"; + key = "${loc}/keys/private.key"; + ca = "${loc}/keys/ca.crt"; + credentials = "home/makefu/0e6c8146-1ddb-4906-9369-8f77e34cdf84"; + }; + context = { + work = "tags:work"; + shack = "tags:shack"; + home = "tags:home"; + }; + }; + }; +} -- cgit v1.2.3 From bce8dd2348af3f15a6fe3c9cb91b5b7576c2bf99 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 09:18:10 +0200 Subject: ma editors/vim: try out languageClient --- makefu/2configs/editor/vim.nix | 1 + makefu/2configs/editor/vimrc | 11 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/editor/vim.nix b/makefu/2configs/editor/vim.nix index d14a611b..8a58e44d 100644 --- a/makefu/2configs/editor/vim.nix +++ b/makefu/2configs/editor/vim.nix @@ -23,6 +23,7 @@ in { vimrcConfig.vam.pluginDictionaries = [ { names = [ "undotree" # "YouCompleteMe" + "LanguageClient-neovim" "vim-better-whitespace" ]; } # vim-nix handles indentation better but does not perform sanity { names = [ "vim-addon-nix" ]; ft_regex = "^nix\$"; } diff --git a/makefu/2configs/editor/vimrc b/makefu/2configs/editor/vimrc index 8cdab55d..96c505ba 100644 --- a/makefu/2configs/editor/vimrc +++ b/makefu/2configs/editor/vimrc @@ -96,3 +96,14 @@ augroup Binary au BufWritePost *.bin if &bin | %!xxd au BufWritePost *.bin set nomod | endif augroup END + +let g:LanguageClient_serverCommands = { +\ 'python': ['pyls'] +\ } +nnoremap :call LanguageClient_contextMenu() +nnoremap gh :call LanguageClient_textDocument_hover() +nnoremap gd :call LanguageClient_textDocument_definition() +nnoremap gr :call LanguageClient_textDocument_references() +nnoremap gs :call LanguageClient_textDocument_documentSymbol() +nnoremap :call LanguageClient_textDocument_rename() +nnoremap gf :call LanguageClient_textDocument_formatting() -- cgit v1.2.3 From df60cdea0a5beb2df8046bc85b8789862ee8c040 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 09:50:16 +0200 Subject: ma bureautomation: remove faulty motion detector --- .../bureautomation/automation/10h_timer.nix | 5 +- .../bureautomation/automation/bureau-shutdown.nix | 27 ++++----- .../bureautomation/automation/nachtlicht.nix | 4 +- .../bureautomation/device_tracker/openwrt.nix | 14 +++++ makefu/2configs/bureautomation/devices/users.nix | 17 ++++++ makefu/2configs/bureautomation/hass.nix | 65 ++++++++++++++++------ makefu/2configs/bureautomation/person/team.nix | 29 ++++++++++ makefu/2configs/bureautomation/switch/rfbridge.nix | 17 ++++++ .../bureautomation/switch/tasmota_switch.nix | 2 +- 9 files changed, 144 insertions(+), 36 deletions(-) create mode 100644 makefu/2configs/bureautomation/device_tracker/openwrt.nix create mode 100644 makefu/2configs/bureautomation/devices/users.nix create mode 100644 makefu/2configs/bureautomation/person/team.nix create mode 100644 makefu/2configs/bureautomation/switch/rfbridge.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/bureautomation/automation/10h_timer.nix b/makefu/2configs/bureautomation/automation/10h_timer.nix index a311d468..d86b4617 100644 --- a/makefu/2configs/bureautomation/automation/10h_timer.nix +++ b/makefu/2configs/bureautomation/automation/10h_timer.nix @@ -2,8 +2,9 @@ { alias = "start Felix 10h"; trigger = { platform = "state"; - entity_id = "binary_sensor.redbutton"; - to = "on"; + entity_id = [ "device_tracker.felix_phone" "device_tracker.felix_laptop" ]; + from = "not_home"; + to = "home"; }; condition = { condition = "and"; diff --git a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix index 9e657430..1def5f3a 100644 --- a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix +++ b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix @@ -1,9 +1,10 @@ [ - { alias = "Turn on Fernseher on movement"; + { alias = "Turn on Fernseher on group home"; trigger = { - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "on"; + condition = "state"; + entity_id = "group.team"; + from = "not_home"; + to = "home"; }; action = { service = "homeassistant.turn_on"; @@ -13,15 +14,15 @@ ]; }; } - { alias = "Turn off Fernseher 10 minutes after last movement"; + { alias = "Turn off Fernseher after last in group left"; trigger = [ { # trigger when movement was detected at the time - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "off"; - for.minutes = 10; + condition = "state"; + entity_id = "group.team"; + from = "home"; + to = "not_home"; } - { # trigger at 20:00 no matter what + { # trigger at 18:00 no matter what # to avoid 'everybody left before 18:00:00' platform = "time"; at = "18:00:00"; @@ -44,10 +45,10 @@ after = "18:00:00"; # weekday = [ "mon" "tue" "wed" "thu" "fri" ]; } - { + { # if anybody is still there condition = "state"; - entity_id = "binary_sensor.motion"; - state = "off"; + entity_id = "group.team"; + state = "not_home"; } ]; }; diff --git a/makefu/2configs/bureautomation/automation/nachtlicht.nix b/makefu/2configs/bureautomation/automation/nachtlicht.nix index 066e9b06..2becd4a3 100644 --- a/makefu/2configs/bureautomation/automation/nachtlicht.nix +++ b/makefu/2configs/bureautomation/automation/nachtlicht.nix @@ -9,7 +9,7 @@ action = { service = "homeassistant.turn_off"; - entity_id = [ "switch.nachtlicht" ]; + entity_id = [ "group.nachtlicht" ]; }; } @@ -37,7 +37,7 @@ action = { service = "homeassistant.turn_on"; - entity_id = [ "switch.nachtlicht" ]; + entity_id = [ "group.nachtlicht" ]; }; } ] diff --git a/makefu/2configs/bureautomation/device_tracker/openwrt.nix b/makefu/2configs/bureautomation/device_tracker/openwrt.nix new file mode 100644 index 00000000..0db9821a --- /dev/null +++ b/makefu/2configs/bureautomation/device_tracker/openwrt.nix @@ -0,0 +1,14 @@ +[ + { platform = "luci"; + name = "router"; + 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/devices/users.nix b/makefu/2configs/bureautomation/devices/users.nix new file mode 100644 index 00000000..305c0ca8 --- /dev/null +++ b/makefu/2configs/bureautomation/devices/users.nix @@ -0,0 +1,17 @@ +{ + 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/makefu/2configs/bureautomation/hass.nix b/makefu/2configs/bureautomation/hass.nix index 007d00b0..a104f0c4 100644 --- a/makefu/2configs/bureautomation/hass.nix +++ b/makefu/2configs/bureautomation/hass.nix @@ -1,8 +1,9 @@ { pkgs, lib, ... }: let + kodi-host = "192.168.8.11"; in { networking.firewall.allowedTCPPorts = [ 8123 ]; - + state = [ "/var/lib/hass/known_devices.yaml" ]; services.home-assistant = { enable = true; config = { @@ -33,7 +34,8 @@ in { retain = true; }; }; - switch = (import ./switch/tasmota_switch.nix); + switch = (import ./switch/tasmota_switch.nix) ++ + (import ./switch/rfbridge.nix); light = (import ./light/statuslight.nix) ++ (import ./light/buzzer.nix); timer = { @@ -54,7 +56,12 @@ in { { platform = "kodi"; name = "wbob"; - host = "192.168.8.11"; + host = kodi-host; + } + ]; + media_player = [ + { platform = "kodi"; + host = kodi-host; } ]; script = (import ./script/multi_blink.nix) {inherit lib;}; @@ -70,6 +77,10 @@ in { camera = (import ./camera/verkehrskamera.nix); + # not yet released + #person = + # (import ./person/team.nix ); + frontend = { }; http = { }; conversation = {}; @@ -82,36 +93,55 @@ in { { view = "yes"; entities = [ "group.sensors" + "group.camera" "group.outside" - "group.switches" - "group.automation" - # "group.camera" + "group.team" + "group.nachtlicht" + # "group.switches" ]; }; automation = [ - "timer.felix_10h" - "script.blitz_10s" - "script.buzz_red_led_fast" - "camera.Baumarkt" ]; switches = [ "switch.bauarbeiterlampe" "switch.blitzdings" "switch.fernseher" "switch.feuer" - "switch.nachtlicht" "light.status_felix" "light.status_daniel" "light.buslicht" "light.redbutton_buzzer" ]; - - camera = [ ]; + team = [ + "device_tracker.thorsten_phone" + "device_tracker.felix_phone" + "device_tracker.ecki_tablet" + "device_tracker.daniel_phone" + "device_tracker.carsten_phone" + # "person.thorsten" + # "person.felix" + # "person.ecki" + # "person.daniel" + ]; + camera = [ + "camera.Baumarkt" + "camera.Autobahn_Heilbronn" + "camera.Autobahn_Singen" + ]; + nachtlicht = [ + "switch.nachtlicht_a" + "switch.nachtlicht_b" + "switch.nachtlicht_c" + "switch.nachtlicht_d" + ]; sensors = [ - "binary_sensor.motion" - "binary_sensor.redbutton" + "media_player.kodi" + "script.blitz_10s" + "script.buzz_red_led_fast" + "timer.felix_10h" "sensor.easy2_dht22_humidity" "sensor.easy2_dht22_temperature" + # "binary_sensor.redbutton" ]; outside = [ # "sensor.ditzingen_pm10" @@ -120,8 +150,7 @@ in { "sensor.dark_sky_humidity" # "sensor.dark_sky_pressure" "sensor.dark_sky_hourly_summary" - "camera.Autobahn_Heilbronn" - "camera.Autobahn_Singen" + "device_tracker.router" ]; }; # only for automation @@ -131,7 +160,7 @@ in { automation = (import ./automation/bureau-shutdown.nix) ++ (import ./automation/nachtlicht.nix) ++ (import ./automation/10h_timer.nix); - + device_tracker = (import ./device_tracker/openwrt.nix ); }; }; } diff --git a/makefu/2configs/bureautomation/person/team.nix b/makefu/2configs/bureautomation/person/team.nix new file mode 100644 index 00000000..e18c4219 --- /dev/null +++ b/makefu/2configs/bureautomation/person/team.nix @@ -0,0 +1,29 @@ +[ + { 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" + ]; + } +] diff --git a/makefu/2configs/bureautomation/switch/rfbridge.nix b/makefu/2configs/bureautomation/switch/rfbridge.nix new file mode 100644 index 00000000..1336549a --- /dev/null +++ b/makefu/2configs/bureautomation/switch/rfbridge.nix @@ -0,0 +1,17 @@ +let + topic = "rfbridge"; + bridge = name: payload_on: payload_off: + { platform = "mqtt"; + inherit name payload_on payload_off; + command_topic = "/bam/${topic}/cmnd/rfcode"; + availability_topic = "/bam/${topic}/tele/LWT"; + payload_available= "Online"; + payload_not_available= "Offline"; + }; +in +[ + (bridge "Nachtlicht A" "#414551" "#414554") + (bridge "Nachtlicht B" "#415151" "#415154") + (bridge "Nachtlicht C" "#415451" "#415454") + (bridge "Nachtlicht D" "#41551F" "#415514") +] diff --git a/makefu/2configs/bureautomation/switch/tasmota_switch.nix b/makefu/2configs/bureautomation/switch/tasmota_switch.nix index b00a8e45..eb7b5fb8 100644 --- a/makefu/2configs/bureautomation/switch/tasmota_switch.nix +++ b/makefu/2configs/bureautomation/switch/tasmota_switch.nix @@ -15,5 +15,5 @@ in [ (tasmota_plug "Blitzdings" "plug2") (tasmota_plug "Fernseher" "plug3") (tasmota_plug "Feuer" "plug4") - (tasmota_plug "Nachtlicht" "plug5") + (tasmota_plug "Blaulicht" "plug5") ] -- cgit v1.2.3 From 854bd37b06a4bddcf5d71e7c6a2264eaac66c928 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 15:37:35 +0200 Subject: ma pkgs.bento4: rip (upstreamed) init-host: put into configs to still be able to push to NUR --- makefu/2configs/tools/init-host/default.nix | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 makefu/2configs/tools/init-host/default.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/tools/init-host/default.nix b/makefu/2configs/tools/init-host/default.nix new file mode 100644 index 00000000..d1d3f719 --- /dev/null +++ b/makefu/2configs/tools/init-host/default.nix @@ -0,0 +1,47 @@ +{ pkgs }: +pkgs.writeDashBin "generate-secrets" '' + set -euf + HOSTNAME="''${1?must provide hostname}" + TMPDIR=$(${pkgs.coreutils}/bin/mktemp -d) + PASSWORD=$(${pkgs.pwgen}/bin/pwgen 25 1) + HASHED_PASSWORD=$(echo $PASSWORD | ${pkgs.hashPassword}/bin/hashPassword -s) > /dev/null + + ${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f $TMPDIR/ssh.id_ed25519 -P "" -C "" >/dev/null + ${pkgs.openssl}/bin/openssl genrsa -out $TMPDIR/retiolum.rsa_key.priv 4096 2>/dev/null > /dev/null + ${pkgs.openssl}/bin/openssl rsa -in $TMPDIR/retiolum.rsa_key.priv -pubout -out $TMPDIR/retiolum.rsa_key.pub 2>/dev/null > /dev/null + cat < $TMPDIR/hashedPasswords.nix + { + root = "$HASHED_PASSWORD"; + } + EOF + + cd $TMPDIR + for x in *; do + ${pkgs.coreutils}/bin/cat $x | secrets insert -m $HOSTNAME/$x > /dev/null + done + echo $PASSWORD | secrets insert -m $HOSTNAME/root > /dev/null + + cat <