diff options
author | lassulus <lassulus@lassul.us> | 2019-04-08 17:13:47 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2019-04-08 17:13:47 +0200 |
commit | 8df36824c35e0573c966b355264816dbef63a05b (patch) | |
tree | 2e757d9146b1e22c5f3e1c8426bd2ad8fc099dfd /makefu/2configs | |
parent | 9e7729def580d83bc439985616f8c5d7162bcd48 (diff) | |
parent | 2f53271af0fda00bdc452c2bc5e569f064f562f6 (diff) |
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'makefu/2configs')
18 files changed, 274 insertions, 59 deletions
diff --git a/makefu/2configs/bureautomation/automation/10h_timer.nix b/makefu/2configs/bureautomation/automation/10h_timer.nix index a311d468c..dd747114e 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"; @@ -127,7 +128,13 @@ }; action = [ - # TODO: Pushbullet + { + service = "notify.telegrambot"; + data = { + title = "Zu lange Felix!"; + message = "Du bist schon 10 Stunden auf Arbeit, geh jetzt gefälligst nach Hause!"; + }; + } { service = "homeassistant.turn_on"; entity_id = [ diff --git a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix index 9e6574300..c632a9e69 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"; + entity_id = "group.team"; + from = "not_home"; + to = "home"; }; action = { service = "homeassistant.turn_on"; @@ -13,28 +14,38 @@ ]; }; } - { 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; + 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"; } ]; - action = { - service = "homeassistant.turn_off"; - entity_id = [ - "switch.fernseher" - "switch.feuer" - "light.status_felix" - ]; - }; + action = [ + { + service = "homeassistant.turn_off"; + entity_id = [ + "switch.fernseher" + "switch.feuer" + "light.status_felix" + "light.status_daniel" + ]; + } + { + service = "notify.telegrambot"; + data = { + title = "Bureau Shutdown"; + message = "All devices are turned off due to {{ trigger.platform }} - {{ trigger }}"; + }; + } + ]; condition = { condition = "and"; conditions = [ @@ -44,10 +55,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 066e9b06c..2becd4a39 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 000000000..0db9821a1 --- /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 <secrets/hass/router.nix>; + 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 000000000..305c0ca86 --- /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 007d00b09..4e5fe7b63 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 = { @@ -53,8 +55,20 @@ in { notify = [ { platform = "kodi"; - name = "wbob"; - host = "192.168.8.11"; + name = "wbob-kodi"; + host = kodi-host; + } + { + platform = "telegram"; + name = "telegrambot"; + chat_id = builtins.elemAt + (builtins.fromJSON (builtins.readFile + <secrets/hass/telegram-bot.json>)).allowed_chat_ids 0; + } + ]; + media_player = [ + { platform = "kodi"; + host = kodi-host; } ]; script = (import ./script/multi_blink.nix) {inherit lib;}; @@ -70,6 +84,10 @@ in { camera = (import ./camera/verkehrskamera.nix); + # not yet released + #person = + # (import ./person/team.nix ); + frontend = { }; http = { }; conversation = {}; @@ -77,41 +95,63 @@ in { logbook = {}; tts = [ { platform = "google";} ]; recorder = {}; + telegram_bot = [ + (builtins.fromJSON + (builtins.readFile <secrets/hass/telegram-bot.json>)) + ]; group = { default_view = { view = "yes"; entities = [ "group.sensors" + "group.camera" "group.outside" + "group.team" + "group.nachtlicht" "group.switches" - "group.automation" - # "group.camera" ]; }; 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 +160,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 +170,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/light/statuslight.nix b/makefu/2configs/bureautomation/light/statuslight.nix index 3a9582f2f..0acab7281 100644 --- a/makefu/2configs/bureautomation/light/statuslight.nix +++ b/makefu/2configs/bureautomation/light/statuslight.nix @@ -8,20 +8,20 @@ let inherit name; retain = false; qos = 1; - optimistic = false; + #optimistic = true; # state - # TODO: currently broken, will not use the custom state topic - state_topic = "/bam/${topic}/stat/POWER"; command_topic = "/bam/${topic}/cmnd/POWER"; + state_topic = "/bam/${topic}/tele/STATE"; + value_template = "{{ value_json.POWER }}"; availability_topic = "/bam/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; + payload_on = "ON"; + payload_off = "OFF"; payload_available= "Online"; payload_not_available= "Offline"; # brightness - brightness_state_topic = "/bam/${topic}/stat/Dimmer"; + brightness_state_topic = "/bam/${topic}/tele/STATE"; + brightness_value_template = "{{value_json.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"; @@ -29,10 +29,11 @@ let rgb_command_mode = "hex"; rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; # effects - effect_state_topic = "/bam/${topic}/stat/Scheme"; + effect_state_topic = "/bam/${topic}/tele/STATE"; + effects_value_template = "{{value_json.Scheme}}"; effect_command_topic = "/bam/${topic}/cmnd/Scheme"; effect_value_template = "{{ value_json.Scheme }}"; - effect_list = [ + effect_list = [ 0 # single color for LED light 1 # start wake up sequence (same as Wakeup) 2 # cycle up through colors using Speed option diff --git a/makefu/2configs/bureautomation/person/team.nix b/makefu/2configs/bureautomation/person/team.nix new file mode 100644 index 000000000..e18c42194 --- /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 000000000..1336549a3 --- /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 b00a8e454..115bae0cc 100644 --- a/makefu/2configs/bureautomation/switch/tasmota_switch.nix +++ b/makefu/2configs/bureautomation/switch/tasmota_switch.nix @@ -2,18 +2,21 @@ let tasmota_plug = name: topic: { platform = "mqtt"; inherit name; - state_topic = "/bam/${topic}/stat/POWER"; + state_topic = "/bam/${topic}/tele/STATE"; + value_template = "{{ value_json.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"; + retain = false; + qos = 1; }; in [ (tasmota_plug "Bauarbeiterlampe" "plug") (tasmota_plug "Blitzdings" "plug2") (tasmota_plug "Fernseher" "plug3") (tasmota_plug "Feuer" "plug4") - (tasmota_plug "Nachtlicht" "plug5") + (tasmota_plug "Blaulicht" "plug5") ] diff --git a/makefu/2configs/editor/vim.nix b/makefu/2configs/editor/vim.nix index d14a611b4..8a58e44de 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 8cdab55db..96c505ba8 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 <F6> :call LanguageClient_contextMenu()<CR> +nnoremap <silent> gh :call LanguageClient_textDocument_hover()<CR> +nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR> +nnoremap <silent> gr :call LanguageClient_textDocument_references()<CR> +nnoremap <silent> gs :call LanguageClient_textDocument_documentSymbol()<CR> +nnoremap <silent> <F2> :call LanguageClient_textDocument_rename()<CR> +nnoremap <silent> gf :call LanguageClient_textDocument_formatting()<CR> diff --git a/makefu/2configs/tools/all.nix b/makefu/2configs/tools/all.nix index b6554e040..6844fdfe4 100644 --- a/makefu/2configs/tools/all.nix +++ b/makefu/2configs/tools/all.nix @@ -10,6 +10,7 @@ ./games.nix ./media.nix ./mobility.nix + ./pcmanfm-extra.nix ./scanner-tools.nix ./sec.nix ./sec-gui.nix diff --git a/makefu/2configs/tools/core-gui.nix b/makefu/2configs/tools/core-gui.nix index 582d941a6..41bfef270 100644 --- a/makefu/2configs/tools/core-gui.nix +++ b/makefu/2configs/tools/core-gui.nix @@ -6,7 +6,7 @@ chromium feh clipit - firefox + # firefox keepassx pcmanfm evince diff --git a/makefu/2configs/tools/dev.nix b/makefu/2configs/tools/dev.nix index fe25bd49a..23da9d577 100644 --- a/makefu/2configs/tools/dev.nix +++ b/makefu/2configs/tools/dev.nix @@ -2,10 +2,15 @@ { users.users.makefu.packages = with pkgs;[ - python3 - python3Packages.pyserial + (python3.withPackages(ps: [ + ps.python-language-server + # the following plugins are optional, they provide type checking, import sorting and code formatting + ps.pyls-mypy ps.pyls-isort ps.pyls-black + ps.virtualenv + ])) picocom - python3Packages.virtualenv + python3.pkgs.pyserial + python3.pkgs.virtualenv # embedded gi flashrom @@ -26,6 +31,6 @@ nix-review # git-related tig - init-host + (pkgs.callPackage ./init-host {}) ]; } diff --git a/makefu/2configs/tools/extra-gui.nix b/makefu/2configs/tools/extra-gui.nix index 3d26cc574..dfb4183df 100644 --- a/makefu/2configs/tools/extra-gui.nix +++ b/makefu/2configs/tools/extra-gui.nix @@ -14,5 +14,6 @@ saleae-logic gitAndTools.gitFull signal-desktop + rambox ]; } diff --git a/makefu/2configs/tools/init-host/default.nix b/makefu/2configs/tools/init-host/default.nix new file mode 100644 index 000000000..d1d3f7195 --- /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 <<EOF > $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 <<EOF + $HOSTNAME = { + cores = 1; + owner = config.krebs.users.makefu; + nets = { + retiolum = { + ip4.addr = "10.243.0.changeme"; + ip6.addr = "42:0:0:0:0:0:0:changeme"; + aliases = [ + "$HOSTNAME.r" + ]; + tinc.pubkey = ${"''"} + $(cat $TMPDIR/retiolum.rsa_key.pub) + ${"''"}; + }; + }; + ssh.privkey.path = <secrets/ssh.id_ed25519>; + ssh.pubkey = "$(cat $TMPDIR/ssh.id_ed25519.pub)"; + }; + EOF + + rm -rf $TMPDIR +'' + diff --git a/makefu/2configs/tools/pcmanfm-extra.nix b/makefu/2configs/tools/pcmanfm-extra.nix new file mode 100644 index 000000000..2d5d20f80 --- /dev/null +++ b/makefu/2configs/tools/pcmanfm-extra.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: +{ + users.users.makefu.packages = with pkgs; [ + pcmanfm + lxqt.lxqt-policykit + shared_mime_info + lxmenu-data + ]; + environment.variables.GIO_EXTRA_MODULES = [ "${pkgs.gvfs}/lib/gio/modules" ]; + services.gnome3.gvfs.enable = true; +} |