diff options
author | lassulus <lassulus@lassul.us> | 2022-09-26 15:36:25 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2022-09-26 15:36:25 +0200 |
commit | 059a5b48af9f6c21c3c442bb0fc35d2105d3b682 (patch) | |
tree | 15de5c35d213d677bc2b294fc411d0f43dc536b2 /makefu/2configs | |
parent | 4d7aacdd1c2a8cc9f6d826cb7e3bb2bc10e36a5e (diff) | |
parent | 5b9d7e47c3f1877bcffdf2aafac712451db43d61 (diff) |
Merge remote-tracking branch 'gum/master'
Diffstat (limited to 'makefu/2configs')
40 files changed, 849 insertions, 199 deletions
diff --git a/makefu/2configs/bgt/download.binaergewitter.de.nix b/makefu/2configs/bgt/download.binaergewitter.de.nix index 1cf21f213..d49ad158b 100644 --- a/makefu/2configs/bgt/download.binaergewitter.de.nix +++ b/makefu/2configs/bgt/download.binaergewitter.de.nix @@ -59,6 +59,11 @@ in { systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/spool/nginx/logs/" ]; + security.acme.certs."download.binaergewitter.de" = { + dnsProvider = "cloudflare"; + credentialsFile = toString <secrets/lego-binaergewitter>; + webroot = lib.mkForce null; + }; services.nginx = { appendHttpConfig = '' @@ -70,6 +75,8 @@ in { recommendedGzipSettings = true; recommendedOptimisation = true; virtualHosts."download.binaergewitter.de" = { + addSSL = true; + enableACME = true; serverAliases = [ "dl2.binaergewitter.de" ]; root = "/var/www/binaergewitter"; extraConfig = '' diff --git a/makefu/2configs/bitlbee.nix b/makefu/2configs/bitlbee.nix index 52b5d68a5..21626d406 100644 --- a/makefu/2configs/bitlbee.nix +++ b/makefu/2configs/bitlbee.nix @@ -2,7 +2,7 @@ { services.bitlbee = { enable = true; - libpurple_plugins = [ pkgs.telegram-purple pkgs.pidgin-skypeweb]; + # libpurple_plugins = [ pkgs.telegram-purple pkgs.pidgin-skypeweb]; }; users.users.makefu.packages = with pkgs; [ weechat tmux ]; state = [ "/var/lib/bitlbee" ]; diff --git a/makefu/2configs/default.nix b/makefu/2configs/default.nix index 7905cf4eb..66c77e1eb 100644 --- a/makefu/2configs/default.nix +++ b/makefu/2configs/default.nix @@ -52,6 +52,7 @@ with import <stockholm/lib>; gnumake rxvt_unicode.terminfo htop + nix-output-monitor ]; programs.bash.enableCompletion = true; @@ -86,8 +87,9 @@ with import <stockholm/lib>; ''; environment.pathsToLink = [ "/share" ]; security.acme = { - email = "letsencrypt@syntax-fehler.de"; + defaults.email = "letsencrypt@syntax-fehler.de"; acceptTerms = true; }; system.stateVersion = lib.mkDefault "20.03"; + services.postgresql.package = pkgs.postgresql_14; } diff --git a/makefu/2configs/deployment/owncloud.nix b/makefu/2configs/deployment/owncloud.nix index e5c7e48de..b660720e5 100644 --- a/makefu/2configs/deployment/owncloud.nix +++ b/makefu/2configs/deployment/owncloud.nix @@ -57,7 +57,7 @@ systemd.services.postgresqlBackup-nextcloud.serviceConfig.SupplementaryGroups = users.users.nextcloud.extraGroups = [ "download" ]; services.nextcloud = { enable = true; - package = pkgs.nextcloud23; + package = pkgs.nextcloud24; hostName = "o.euer.krebsco.de"; # Use HTTPS for links https = true; diff --git a/makefu/2configs/home/3dprint.nix b/makefu/2configs/home/3dprint.nix new file mode 100644 index 000000000..859a18840 --- /dev/null +++ b/makefu/2configs/home/3dprint.nix @@ -0,0 +1,45 @@ +{ pkgs, ... }: +{ + services.mjpg-streamer = { + enable = true; + inputPlugin = "input_uvc.so -d /dev/web_cam -r 1280x960"; + }; + users.users.octoprint.extraGroups = [ "video" ]; + # allow octoprint to access /dev/vchiq + # also ensure that the webcam always comes up under the same name + services.udev.extraRules = '' + SUBSYSTEM=="vchiq",GROUP="video",MODE="0660" + SUBSYSTEM=="video4linux", ATTR{name}=="UVC Camera (046d:0825)",SYMLINK+="web_cam", MODE="0666", GROUP="video" + ''; + systemd.services.octoprint = { + path = [ pkgs.libraspberrypi ]; + }; + services.octoprint = { + enable = true; + plugins = plugins: with plugins;[ + costestimation + displayprogress + mqtt + stlviewer + themeify + # octolapse + (buildPlugin rec { + pname = "OctoPrint-HomeAssistant"; + version = "3.6.2"; + src = pkgs.fetchFromGitHub { + owner = "cmroche"; + repo = pname; + rev = version; + hash = "sha256-oo9OBmHoJFNGK7u9cVouMuBuUcUxRUrY0ppRq0OS1ro="; + }; + }) + ]; + extraConfig.plugins.mqtt.broker = { + url = "omo.lan"; + # TODO TODO TODO + username = "hass"; + password = "lksue43jrf"; + # TODO TODO TODO + }; + }; +} diff --git a/makefu/2configs/home/ham/automation/buttonboard.nix b/makefu/2configs/home/ham/automation/buttonboard.nix new file mode 100644 index 000000000..533311fc5 --- /dev/null +++ b/makefu/2configs/home/ham/automation/buttonboard.nix @@ -0,0 +1,4 @@ +# good, bad radio +# stop +# start radio +# lauter, leister diff --git a/makefu/2configs/home/ham/automation/bye.txt.j2 b/makefu/2configs/home/ham/automation/bye.txt.j2 new file mode 100644 index 000000000..8a5ba7257 --- /dev/null +++ b/makefu/2configs/home/ham/automation/bye.txt.j2 @@ -0,0 +1,2 @@ +Endlich ist Pappa fertig mit arbeit! +Heute hast du {{ states("sensor.felix_at_work_today") |round(1) }} Stunden gearbeitet. diff --git a/makefu/2configs/home/ham/automation/check-in.nix b/makefu/2configs/home/ham/automation/check-in.nix index d589a6971..db051757e 100644 --- a/makefu/2configs/home/ham/automation/check-in.nix +++ b/makefu/2configs/home/ham/automation/check-in.nix @@ -7,6 +7,21 @@ let in { services.home-assistant.config.input_boolean.felix_at_work.name = "Felix auf Arbeit"; + services.home-assistant.config.timer.felix_at_work = { + name = "Felix auf Arbeit Timer"; + duration = "10:00:00"; + }; + services.home-assistant.config.sensor = [ + { + platform = "history_stats"; + name = "Felix at work today"; + entity_id = "input_boolean.felix_at_work"; + state = "on"; + type = "time"; + start = "{{ now().replace(hour=0, minute=0, second=0) }}"; + end = "{{ now() }}"; + } + ]; services.home-assistant.config.script.start_office_radio.sequence = [ { service = "media_player.play_media"; @@ -19,13 +34,41 @@ in ]; services.home-assistant.config.automation = [ - { service = "media_player.play_media"; - data = { - media_content_id = "http://radio.lassul.us:8000/radio.mp3"; - media_content_type = "music"; - }; - target.entity_id = "media_player.office"; - } + { alias = "Zu lange Felix!"; + trigger = + { platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.felix_at_work"; + }; + + condition = + { + condition = "state"; + entity_id = at_work; + state = "off"; + }; + + action = (say "Felix, die zehn Stunden sind um, aufhören jetzt"); + } + { alias = "Turn off at work sensor"; + trigger = [ + { platform = "time"; at = "00:00:00"; } + ]; + condition = + { + condition = "state"; + entity_id = at_work; + state = "off"; + }; + action = + [ + # felix forgot to stamp out ... + { + service = "homeassistant.turn_off"; + entity_id = [ at_work ]; + } + ]; + } { alias = "Push Check-in Button Felix with button"; trigger = [ { @@ -54,15 +97,12 @@ in { service = "homeassistant.turn_on"; entity_id = at_work; } - ] ++ (say "Willkommen auf Arbeit") ++ - [ - { service = "media_player.play_media"; - data = { - media_content_id = "http://radio.lassul.us:8000/radio.mp3"; - media_content_type = "music"; - }; - target.entity_id = "media_player.office"; + { service = "timer.start"; + entity_id = [ "timer.felix_at_work" ] ; } + ] ++ (say (builtins.readFile ./welcome.txt.j2)) ++ + [ + { service = "script.start_office_radio"; } ]; } { @@ -78,7 +118,12 @@ in { service = "homeassistant.turn_off"; entity_id = at_work; } - ] ++ (say "Endlich ist Pappa fertig mit arbeit!"); + ] ++ (say (builtins.readFile ./bye.txt.j2)) ++ + [ + { service = "timer.stop"; + entity_id = [ "timer.felix_at_work" ] ; + } + ]; } ]; } diff --git a/makefu/2configs/home/ham/automation/daily_speedtext.nix b/makefu/2configs/home/ham/automation/daily_speedtext.nix new file mode 100644 index 000000000..70d59f6e1 --- /dev/null +++ b/makefu/2configs/home/ham/automation/daily_speedtext.nix @@ -0,0 +1,17 @@ +{ + services.home-assistant.config.automation = + [ + { + trigger = [ + { platform = "time"; at = "03:21"; } + ]; + action = + [ + { + service = "speedtestdotnet.speedtest"; + } + ]; + } + ]; + +} diff --git a/makefu/2configs/home/ham/automation/fenster_auf.nix b/makefu/2configs/home/ham/automation/fenster_auf.nix index fa2052be8..b3682fe0c 100644 --- a/makefu/2configs/home/ham/automation/fenster_auf.nix +++ b/makefu/2configs/home/ham/automation/fenster_auf.nix @@ -4,6 +4,11 @@ # binary_sensor.badezimmer_fenster_contact # binary_sensor.dusche_fenster_contact let + hlib = import ../lib; + say = hlib.say.office; + draussen = "sensor.wohnzimmer_temp_temperature"; + draussen_diff = "sensor.unterschied_draussen_drinnen"; + draussen_heiss = 23; min = 20; fenster_offen = name: entity: { alias = "${name} seit ${toString min} Minuten offen"; @@ -16,10 +21,6 @@ let } ]; condition = [ - { condition = "state"; - entity_id = "input_boolean.ist_sommer"; - state = "off"; - } ]; action = [ @@ -67,6 +68,17 @@ let }; in { services.home-assistant.config = { + template = [ + { sensor = { + name = "Unterschied Draussen Drinnen"; + unit_of_measurement = "°C"; + state = '' + {% set inside = states("${draussen}") | float | round(2) -%} + {% set outside = states("sensor.dark_sky_temperature") | float | round(2) -%} + {{ ((outside - inside) | round(1) )}}''; + }; + } + ]; sensor = [ { platform = "season"; type = "meteorological";} ]; @@ -86,6 +98,41 @@ in { (fenster_offen "Badezimmerfenster" "binary_sensor.badezimmer_fenster_contact") (fenster_offen "Duschfenster" "binary_sensor.dusche_fenster_contact") + + { alias = "Draussen ist wieder kaelter"; + trigger = [ + { + platform = "numeric_state"; + entity_id = draussen_diff; + below = 0; + for.minutes = 20; + } + ]; + condition = [ + { condition = "numeric_state"; + entity_id = draussen; + above = draussen_heiss; + } + ]; + action = (say "Draussen ist es endlich kühler, jetzt kann man die Fenster auf machen"); + } + { alias = "Draussen ist zu warm"; + trigger = [ + { + platform = "numeric_state"; + entity_id = draussen_diff; + above = 0; + for.minutes = 20; + } + ]; + condition = [ + { condition = "numeric_state"; + entity_id = draussen; + above = draussen_heiss; + } + ]; + action = (say "Draussen wird es jetzt zu warm, besser das fenster schliessen"); + } ]; }; } diff --git a/makefu/2configs/home/ham/automation/firetv_restart.nix b/makefu/2configs/home/ham/automation/firetv_restart.nix index 12e0e845a..01d1ba6e9 100644 --- a/makefu/2configs/home/ham/automation/firetv_restart.nix +++ b/makefu/2configs/home/ham/automation/firetv_restart.nix @@ -20,17 +20,17 @@ in action = [ (cmd "reboot") (sec 90) # go to my music because apparently select_source does not seem to always work - (cmd "HOME") - (sec 2) - (cmd "DOWN") - (sec 2) - (cmd "DOWN") - (sec 2) - (cmd "ENTER") - (sec 4) - (cmd "RIGHT") - (sec 2) - (cmd "RIGHT") + #(cmd "HOME") + #(sec 2) + #(cmd "DOWN") + #(sec 2) + #(cmd "DOWN") + #(sec 2) + #(cmd "ENTER") + #(sec 4) + #(cmd "RIGHT") + #(sec 2) + #(cmd "RIGHT") ]; } ]; diff --git a/makefu/2configs/home/ham/automation/flurlicht.nix b/makefu/2configs/home/ham/automation/flurlicht.nix index aa62ab9e4..bb4877100 100644 --- a/makefu/2configs/home/ham/automation/flurlicht.nix +++ b/makefu/2configs/home/ham/automation/flurlicht.nix @@ -32,12 +32,16 @@ in [ { choose = [ (lightcond "Badezimmer Fenster Auf" - { condition = "state"; entity_id = "binary_sensor.badezimmer_fenster_contact"; state = "on"; } - [ 64 207 255 ] 255 # helblau + [ { condition = "state"; entity_id = "binary_sensor.badezimmer_fenster_contact"; state = "on"; } + { condition = "state"; entity_id = "input_boolean.ist_sommer"; state = "off"; } + + ] + [ 64 207 255 ] 128 # hellblau ) (lightcond "Duschenster auf" - { condition = "state"; entity_id = "binary_sensor.dusche_fenster_contact"; state = "on"; } - [ 64 207 255 ] 255 # helblau + [ { condition = "state"; entity_id = "binary_sensor.dusche_fenster_contact"; state = "on"; } + { condition = "state"; entity_id = "input_boolean.ist_sommer"; state = "off"; } ] + [ 64 207 255 ] 128 # hellblau ) (lightcond "Nachtlicht" { condition = "state"; entity_id = "sun.sun"; state = "below_horizon"; } diff --git a/makefu/2configs/home/ham/automation/shutdown_button.nix b/makefu/2configs/home/ham/automation/shutdown_button.nix index 4c12be277..ec1a25567 100644 --- a/makefu/2configs/home/ham/automation/shutdown_button.nix +++ b/makefu/2configs/home/ham/automation/shutdown_button.nix @@ -1,5 +1,8 @@ let btn = "sensor.arbeitszimmer_btn1_action"; + lib = import ../lib; + say = lib.say.living_room; + all_lights = [ # Wohnzimmer "light.wled" @@ -21,6 +24,8 @@ let all_media_player = [ "media_player.living_room" "media_player.office" + "media_player.bedroom" + ]; in { services.home-assistant.config.automation = @@ -30,13 +35,13 @@ in { { platform = "state"; entity_id = btn; - to = "on"; + to = "single"; } ]; condition = [ ]; - action = [ + action = (say "Alles Aus" )++ [ { - service = "home_assistant.turn_off"; + service = "light.turn_off"; target.entity_id = all_lights; } { service = "media_player.media_stop"; diff --git a/makefu/2configs/home/ham/automation/urlaub.nix b/makefu/2configs/home/ham/automation/urlaub.nix index c11c589cf..7f47c9da5 100644 --- a/makefu/2configs/home/ham/automation/urlaub.nix +++ b/makefu/2configs/home/ham/automation/urlaub.nix @@ -4,7 +4,10 @@ # "all" lights let - schranklicht = "light.wohnzimmer_schrank_osram"; + schranklicht = [ + "light.wohnzimmer_schrank_osram" + "light.wohnzimmer_komode_osram" + ]; weihnachtslicht = "light.wohnzimmer_fenster_lichterkette_licht"; fernsehlicht = "light.wled"; @@ -24,7 +27,7 @@ let turn_on = entity_id: offset: # negative offset => before sunset - { alias = "Turn on ${entity_id} at sunset ${offset}"; + { alias = "Turn on ${toString entity_id} at sunset ${offset}"; trigger = [ { platform = "sun"; event = "sunset"; inherit offset; } ]; diff --git a/makefu/2configs/home/ham/automation/welcome.txt.j2 b/makefu/2configs/home/ham/automation/welcome.txt.j2 new file mode 100644 index 000000000..76091b868 --- /dev/null +++ b/makefu/2configs/home/ham/automation/welcome.txt.j2 @@ -0,0 +1,45 @@ +{% set arbeit_heute = is_state("binary_sensor.arbeitstag","on") -%} +{% set weekday = ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][now().weekday()] -%} +{% set is_friday = now().weekday() == 4 %} + +{% if not arbeit_heute %} +Heute ist {{ weekday }}, du solltest gar nicht arbeiten! +{% else %} +Willkommen auf Arbeit Felix. +{% endif -%} +Das aktuell gewählte Projekt ist {{ states("sensor.felix_project") }}. + +{% set inside = states("sensor.wohnzimmer_temp_temperature") | float | round(2) -%} +{% set outside = states("sensor.dark_sky_temperature") | float | round(2) -%} +{% set arbeit_morgen = is_state("binary_sensor.arbeitstag_morgen","on") -%} + +Die Wetteraussichten: {{ states("sensor.dark_sky_hourly_summary") | replace(".","")}} bei {{ states("sensor.dark_sky_temperature") }} Grad mit {{ states("sensor.dark_sky_humidity") | round(0) }}% Luftfeuchtigkeit. +{% if states("calendar.abfall_papiermuell") == "on" %} +Heute ist Papiermuell, bring noch schnell dein Papier raus +{% endif %} +{% if states("calendar.abfall_restmuell") == "on" %} +Ausserdem ist heute Restmuell. +{% endif -%} + +{% if ( outside < inside ) and ( outside > 18 ) %} +Draussen ist es gerade {{ ((inside - outside) | round(1) )}} gerade kühler +{% endif -%} + +{% set current_count = state_attr("sensor.dwd_weather_warnings_current_warning_level", "warning_count") %} +{% for i in range(current_count) %} +{% set idx = i + 1 %} + {% set headline = state_attr("sensor.dwd_weather_warnings_current_warning_level", "warning_" ~ idx ~ "_headline") %} + {% set description = state_attr("sensor.dwd_weather_warnings_current_warning_level", "warning_" ~ idx ~ "_description") %} + {% set level = state_attr("sensor.dwd_weather_warnings_current_warning_level", "warning_" ~ idx ~ "_level") %} + {% set time_start = state_attr("sensor.dwd_weather_warnings_current_warning_level", "warning_" ~ idx ~ "_start") %} + {% set time_end = state_attr("sensor.dwd_weather_warnings_current_warning_level", "warning_" ~ idx ~ "_end") %} +Wetterwarnung {{idx}}: {{ headline }} Stufe {{level}} von {{ time_start.strftime("%H:%M") ~ " bis " ~ time_end.strftime("%H:%M") }} Uhr + +{{ description }} +{% endfor %} + +{% if is_friday %} +Endlich ist Freitag! +{% elif not arbeit_morgen %} +Morgen ist Feiertag, also nicht versehentlich arbeiten +{% endif -%} diff --git a/makefu/2configs/home/ham/default.nix b/makefu/2configs/home/ham/default.nix index f54fd32f7..b08152935 100644 --- a/makefu/2configs/home/ham/default.nix +++ b/makefu/2configs/home/ham/default.nix @@ -24,13 +24,17 @@ in { ./device_tracker/tile.nix ./sensor/outside.nix + ./sensor/pollen.nix + ./sensor/dwd.nix ./calendar/nextcloud.nix ./media/firetv.nix ./media/sonos.nix + ./media/schlafzimmer_music_remote.nix ./media/remote_sound_wohnzimmer.nix ./media/remote_sound_arbeitszimmer.nix + ./media/arbeitszimmer_matrix.nix ./automation/check-in.nix ./automation/fenster_auf.nix @@ -41,9 +45,12 @@ in { ./automation/flurlicht.nix ./automation/giesskanne.nix ./automation/pflanzen_giessen_erinnerung.nix - ./automation/urlaub.nix + # ./automation/urlaub.nix ./automation/moodlight.nix ./automation/shutdown_button.nix + ./automation/project_tracker.nix + ./automation/daily_speedtext.nix + ./light/arbeitszimmer.nix ./light/schlafzimmer.nix @@ -53,18 +60,14 @@ in { ]; services.home-assistant = { - package = (pkgs.home-assistant.overrideAttrs (old: { - doInstallCheck = false; - })).override { - extraPackages = p: [ - (p.callPackage ./deps/dwdwfsapi.nix {}) - # (p.callPackage ./signal-rest/pkg.nix {}) - (p.callPackage ./deps/pykodi.nix {}) - ]; - }; + extraComponents = [ "mobile_app" ]; + extraPackages = python3Packages: with python3Packages; [ pytz ]; config = { + default_config = {}; # for sonos aiodiscover + influxdb = { + api_version = 1; database = "ham"; host = "localhost"; tags = { @@ -87,6 +90,25 @@ in { { type = "homeassistant"; } ]; }; + binary_sensor = [ + { platform = "workday"; + name = "Arbeitstag"; + country = "DE"; + province = "BW"; + } + { platform = "workday"; + name = "Arbeitstag Morgen"; + country = "DE"; + province = "BW"; + days_offset = 1; + } + { platform = "workday"; + name = "Arbeitstag Gestern"; + country = "DE"; + province = "BW"; + days_offset = 1; + } + ]; discovery = {}; conversation = {}; history = {}; @@ -141,22 +163,19 @@ in { retain = true; }; }; - #luftdaten = { - # show_on_map = true; - # sensor_id = 10529; - # sensors.monitored_conditions = [ "P1" "P2" ]; - #}; + luftdaten = { + # show_on_map = true; + sensor_id = 72935; + # sensors.monitored_conditions = [ "P1" "P2" ]; + }; #binary_sensor = # flurlicht.binary_sensor; sensor = [ - { platform = "speedtestdotnet"; - scan_interval.hours = 6; - monitored_conditions = [ "ping" "download" "upload" ]; - } # https://www.home-assistant.io/cookbook/automation_for_rainy_days/ ]; frontend = { }; + speedtestdotnet = { }; http = { use_x_forwarded_for = true; #server_host = "127.0.0.1"; @@ -167,6 +186,7 @@ in { switch |