From d857eb875eeec2e146795002e8bd824fd249a5b5 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 3 Aug 2022 12:07:35 +0200 Subject: ma ham: add welcome and bye messages --- makefu/2configs/home/ham/automation/bye.txt.j2 | 2 + makefu/2configs/home/ham/automation/welcome.txt.j2 | 45 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 makefu/2configs/home/ham/automation/bye.txt.j2 create mode 100644 makefu/2configs/home/ham/automation/welcome.txt.j2 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 00000000..8a5ba725 --- /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/welcome.txt.j2 b/makefu/2configs/home/ham/automation/welcome.txt.j2 new file mode 100644 index 00000000..76091b86 --- /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 -%} -- cgit v1.2.3 From f1428c4358f12a8d2f4867f2f190f7e2713eeabb Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 7 Aug 2022 18:07:06 +0200 Subject: ma ham/media: update and add remote controls for media --- .../home/ham/media/arbeitszimmer_matrix.nix | 108 ++++++++++++++ makefu/2configs/home/ham/media/firetv.nix | 13 +- .../home/ham/media/remote_sound_arbeitszimmer.nix | 5 + .../home/ham/media/schlafzimmer_music_remote.nix | 160 +++++++++++++++++++++ makefu/2configs/home/ham/media/sonos.nix | 3 +- 5 files changed, 278 insertions(+), 11 deletions(-) create mode 100644 makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix create mode 100644 makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix diff --git a/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix b/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix new file mode 100644 index 00000000..bd36f02c --- /dev/null +++ b/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix @@ -0,0 +1,108 @@ +{ lib, ... }: +let + remote = "sensor.schlafzimmer_music_remote_action"; + hlib = import ../lib; + step = 0.02; + #room = "bedroom"; + room = "office"; + + player = "media_player.${room}"; + say = hlib.say."${room}"; + + remote_action = key: actions: { + conditions = ''{{ trigger.entity_id == 'binary_sensor.matrix_button_${toString key}' }}''; + sequence = actions; + }; + all_buttons = map (key: "binary_sensor.matrix_button_${toString key}") [ + 0 1 2 3 4 5 6 7 8 9 + "b9" "b10" "b11" "b12" "b13" "b14" + ]; +in + { + services.home-assistant.config.rest_command = { + good_song = { + url = "http://prism.r:8001/good"; + method = "POST"; + }; + bad_song = { + url = "http://prism.r:8001/skip"; + method = "POST"; + }; + }; + services.home-assistant.config.automation = + [ + { alias = "Arbeitszimmer Matrix music action"; + trigger = [ + { + platform = "state"; + entity_id = all_buttons; + } + ]; + action = + [ + { choose = [ + (remote_action "9" { + service = "media_player.media_play"; + target.entity_id = player; + }) + (remote_action "7" + { + service = "media_player.media_mute"; + target.entity_id = player; + data.is_volume_muted = ''{{ not state_attr('${player}' , 'is_volume_muted') }}''; + } + ) + (remote_action "2" + { + service = "media_player.media_stop"; + target.entity_id = player; + } + ) + + (remote_action "b9" + ((say "Guter Song {{ states.sensor.the_playlist_song.state }}") ++ [ + { service = "rest_command.good_song"; } + ])) + + (remote_action "b10" + ((say "Schlechter Song {{ states.sensor.the_playlist_song.state }}") ++ [ + { service = "rest_command.bad_song"; } + ])) + (remote_action "3" + ((say "Starte Lassulus Super Radio") ++ [ + { service = "media_player.play_media"; + data = { + media_content_id = "http://radio.lassul.us:8000/radio.mp3"; + media_content_type = "music"; + }; + target.entity_id = player; + } + ])) + (remote_action "1" + ((say "Starte Groovesalad") ++ [ + { service = "media_player.play_media"; + data = { + media_content_id = "http://ice2.somafm.com/groovesalad-128.mp3"; + media_content_type = "music"; + }; + target.entity_id = player; + } + ])) + (remote_action "8" { + service = "media_player.volume_set"; + target.entity_id = player; + data.volume_level = ''{{ state_attr("${player}","volume_level") + (${toString step}|float) }}''; + }) + (remote_action "5"{ + service = "media_player.volume_set"; + target.entity_id = player; + data.volume_level = ''{{ state_attr("${player}","volume_level") - (${toString step}|float) }}''; + }) + ]; + #default = { }; + } + ]; + } + ]; + +} diff --git a/makefu/2configs/home/ham/media/firetv.nix b/makefu/2configs/home/ham/media/firetv.nix index 429688c6..fc33346c 100644 --- a/makefu/2configs/home/ham/media/firetv.nix +++ b/makefu/2configs/home/ham/media/firetv.nix @@ -3,14 +3,9 @@ let in { services.home-assistant.config = { notify = [ - #{ - # platform = "kodi"; - # name = "Kodi Wohnzimmer"; - # host = firetv_stick; - #} { platform = "nfandroidtv"; - name = "FireTV Wohnzimmer"; + name = "FireTV Wohnzimmer Notification"; host = firetv_stick; } ]; @@ -20,10 +15,10 @@ in { # name = "FireTV Stick kodi"; # host = firetv_stick; #} + # Configuration needs to be done by hand via web interface "integration" { platform = "androidtv"; - name = "FireTV Stick"; - device_class = "firetv"; - # adb_server_ip = firetv_stick; + name = "FireTV Stick Android"; + device_class = "firetv"; host = firetv_stick; port = 5555; } diff --git a/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix b/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix index f59f022f..cfa1da44 100644 --- a/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix +++ b/makefu/2configs/home/ham/media/remote_sound_arbeitszimmer.nix @@ -1,5 +1,10 @@ { lib, ...}: let + # https://www.radiotheque.de/stream/4744806739035994/ABC-Lounge-Music-Radio/pls/ + # http://listen.radionomy.com/ABC-Lounge + # https://str1.openstream.co/589 + # https://listen.openstream.co/3139/audio + # https://str1.openstream.co/589?aw_0_1st.collectionid%3D3139%26stationId%3D3139%26publisherId%3D613%26k%3D1659381767%26aw_0_azn.pcountry%3D%5B%22FR%22%2C%22IT%22%2C%22DE%22%2C%22ES%22%2C%22GB%22%2C%22CH%22%2C%22CA%22%2C%22AT%22%2C%22US%22%5D%26aw_0_azn.planguage%3D%5B%22en%22%2C%22fr%22%2C%22de%22%5D%26aw_0_azn.pgenre%3D%5B%22Jazz%22%2C%22Easy+Listening%22%2C%22Music%22%5D statecond = cond: { # cond must be a list condition = "template"; value_template = "{{ trigger.to_state.state in ( " + diff --git a/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix b/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix new file mode 100644 index 00000000..55b1fd8f --- /dev/null +++ b/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix @@ -0,0 +1,160 @@ +{ lib, ... }: +let + remote = "sensor.schlafzimmer_music_remote_action"; + hlib = import ../lib; + step = 0.03; + room = "bedroom"; + #room = "office"; + + player = "media_player.${room}"; + say = hlib.say."${room}"; + + remote_action = state: actions: { + conditions = ''{{ trigger.to_state.attributes.action == '${state}' }}''; + sequence = actions; + }; + album_list = [ +# Wieso Weshalb Warum Junior +"Doris%20R%c3%bcbel,%20JUMBO%20Neue%20Medien%20%26%20Verlag%20GmbH/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Helfen,%20teilen,%20sich%20vertragen" +"Wieso%3f%20Weshalb%3f%20Warum%3f%20junior/Mein%20Kindergarten" +"Wieso%3f%20Weshalb%3f%20Warum%3f%20junior/Unser%20Werkzeug" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Am%20Meer" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Ampel,%20Stra%c3%9fe%20und%20Verkehr" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Autos%20und%20Laster" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Bagger" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Bauernhof" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Flughafen" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Pinguin" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Der%20Traktor" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Baustelle" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Eisenbahn" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Feuerwehr" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Jahreszeiten" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20M%c3%bcllabfuhr" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Polizei" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Rettungsfahrzeuge" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Die%20Ritterburg" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Heute,%20morgen,%20jetzt%20und%20gleich" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Im%20Streichelzoo" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20In%20den%20Bergen" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Mama,%20Papa,%20Oma,%20Opa" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Mein%20Hund" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Tanken,%20waschen,%20reparieren" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Tiere%20in%20Afrika" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Unsere%20Tierkinder" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Unterwegs%20mit%20Bus%20und%20Bahn" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20ich%20alles%20kann" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20kriecht%20und%20krabbelt%20da%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20an%20Weihnachten%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20im%20Fr%c3%bchling%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20im%20Herbst%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20im%20Sommer%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20machen%20wir%20im%20Winter%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20macht%20der%20Fu%c3%9fballer%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20macht%20der%20Polizist" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20macht%20die%20Prinzessin%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Was%20w%c3%a4chst%20da%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Wenn%20es%20dunkel%20wird" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Wer%20arbeitet%20auf%20der%20Baustelle%3f" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Wir%20feiern%20Geburtstag" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Wir%20gehen%20in%20den%20Zoo" +"Wieso%3f%20Weshalb%3f%20Warum%3f/Wieso%3f%20Weshalb%3f%20Warum%3f%20junior.%20Z%c3%a4hne%20putzen,%20Pipi%20machen" + + ]; + albums = lib.concatMapStringsSep ", " (x: ''"A:ALBUMARTIST/${x}"'') + album_list; +in +{ + services.home-assistant.config.automation = + [ + { alias = "Schlafzimmer music action"; + trigger = [ + { + platform = "state"; + entity_id = remote; + attribute = "action"; + not_to = ""; + } + ]; + action = + [ + { choose = [ + (remote_action "on" { #also called by hold right and left + service = "media_player.media_play"; + target.entity_id = player; + }) + (remote_action "off" + { + service = "media_player.volume_mute"; + target.entity_id = player; + data.is_volume_muted = ''{{ not state_attr('${player}' , 'is_volume_muted') }}''; + } + ) + + (remote_action "arrow_right_hold" + ((say "Starte Lassulus Super Radio") ++ [ + { service = "media_player.play_media"; + data = { + media_content_id = "http://radio.lassul.us:8000/radio.mp3"; + media_content_type = "music"; + }; + target.entity_id = player; + } + ])) + (remote_action "arrow_left_hold" + ((say "Starte Deep House Music") ++ [ + { service = "media_player.play_media"; + data = { + media_content_id = "http://live.dancemusic.ro:7000/stream.mp3"; + media_content_type = "music"; + }; + target.entity_id = player; + } + ])) + #(remote_action "arrow_left_release" { + + #}) + #(remote_action "arrow_left_release" { + + #}) + # TODO: choose random kindermusik? + (remote_action "brightness_move_up" + ((say "Starte Liam Album") ++ [ + { + service = "media_player.play_media"; + target.entity_id = player; + data = { + media_content_id = "{{ [${albums}]|random }}"; + media_content_type = "album"; + }; + } + ]) + ) + (remote_action "brightness_move_down" + ((say "Stoppe Musik") ++ [ + { + service = "media_player.media_stop"; + target.entity_id = player; + } + ]) + ) + (remote_action "arrow_right_click" { + + service = "media_player.volume_set"; + target.entity_id = player; + data.volume_level = ''{{ state_attr("${player}","volume_level") + (${toString step}|float) }}''; + }) + #(remote_action "brightness_move_down" { + (remote_action "arrow_left_click"{ + service = "media_player.volume_set"; + target.entity_id = player; + data.volume_level = ''{{ state_attr("${player}","volume_level") - (${toString step}|float) }}''; + }) + ]; + #default = { }; + } + ]; + } + ]; + +} \ No newline at end of file diff --git a/makefu/2configs/home/ham/media/sonos.nix b/makefu/2configs/home/ham/media/sonos.nix index 40dcfc3c..c9cf1a51 100644 --- a/makefu/2configs/home/ham/media/sonos.nix +++ b/makefu/2configs/home/ham/media/sonos.nix @@ -4,5 +4,4 @@ "192.168.111.31" "192.168.111.32" ]; - - } +} -- cgit v1.2.3 From a10998a86025f052d73250175e2c122d2bd442a4 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 24 Aug 2022 22:42:39 +0200 Subject: nixpkgs-unstable: e4d49de -> f034b56 --- krebs/nixpkgs-unstable.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/krebs/nixpkgs-unstable.json b/krebs/nixpkgs-unstable.json index 9c50f970..e881d4bd 100644 --- a/krebs/nixpkgs-unstable.json +++ b/krebs/nixpkgs-unstable.json @@ -1,9 +1,9 @@ { "url": "https://github.com/NixOS/nixpkgs", - "rev": "e4d49de45a3b5dbcb881656b4e3986e666141ea9", - "date": "2022-07-18T18:21:45+02:00", - "path": "/nix/store/665hb1ysmaadwh4axp7f9inhczq08xay-nixpkgs", - "sha256": "0y0c9ybkcfmjgrl93wzzlk7ii95kh2fb4v5ac5w6rmcsq2ff3yaz", + "rev": "f034b5693a26625f56068af983ed7727a60b5f8b", + "date": "2022-08-24T10:06:14+02:00", + "path": "/nix/store/8rr2y7lwwm09a5cvr26a2yc019b13zxb-nixpkgs", + "sha256": "05x3bjz1af4liwsgha3r85kqa60j22vldp8g0p7nr51zz6jjwqqq", "fetchLFS": false, "fetchSubmodules": false, "deepClone": false, -- cgit v1.2.3 From 12cbc5ed1e022e24a77f959268a63c61ae7086cb Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 29 Aug 2022 21:12:21 +0200 Subject: ma bgt: enable acme with cloudflare --- makefu/2configs/bgt/download.binaergewitter.de.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/makefu/2configs/bgt/download.binaergewitter.de.nix b/makefu/2configs/bgt/download.binaergewitter.de.nix index 1cf21f21..85379e77 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 ; + webroot = lib.mkForce null; + }; services.nginx = { appendHttpConfig = '' @@ -70,6 +75,8 @@ in { recommendedGzipSettings = true; recommendedOptimisation = true; virtualHosts."download.binaergewitter.de" = { + enableSSL = true; + enableACME = true; serverAliases = [ "dl2.binaergewitter.de" ]; root = "/var/www/binaergewitter"; extraConfig = '' -- cgit v1.2.3 From 620398a22bcd51e9b5dfb8b5e8f16e0acf99df86 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 31 Aug 2022 00:43:50 +0200 Subject: ma pkgs.ps3netsrv: package webman-mod ps3netsrv --- makefu/5pkgs/ps3netsrv/default.nix | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 makefu/5pkgs/ps3netsrv/default.nix diff --git a/makefu/5pkgs/ps3netsrv/default.nix b/makefu/5pkgs/ps3netsrv/default.nix new file mode 100644 index 00000000..08d7dbfd --- /dev/null +++ b/makefu/5pkgs/ps3netsrv/default.nix @@ -0,0 +1,33 @@ +{ lib +, stdenv +, fetchFromGitHub +, meson +, ninja +, mbedtls +}: + +stdenv.mkDerivation rec { + pname = "ps3netsrv"; + version = "20220813"; + + src = fetchFromGitHub { + owner = "aldostools"; + repo = "webMAN-MOD"; + rev = "5301277a0eb2275c73d7c82af9cb9e9ec34369e4"; + hash = "sha256-hgQSqRKFomHgOr1ejfKoR/Sywa3AjbinmAAgscVYs44="; + }; + postUnpack = "pwd; ls -alhtr; ls -alhtr source"; + + #dontUseCmakeConfigure = true; + nativeBuildInputs = [ mbedtls meson ninja ]; + buildInputs = [ mbedtls ]; + sourceRoot = "./source/_Projects_/ps3netsrv"; + + meta = with lib; { + homepage = "https://github.com/aldostools/webMAN-MOD/wiki/~-PS3-NET-Server"; + description = "a server application used to stream content from a remote server to the PS3"; + maintainers = [ maintainers.makefu ]; + platforms = platforms.unix; + license = licenses.mit; + }; +} -- cgit v1.2.3 From 092e42f7370b604ba05eda9b3ab1e07c91541d9a Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 22:19:00 +0200 Subject: ma bitlbee: disable purple --- makefu/2configs/bitlbee.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefu/2configs/bitlbee.nix b/makefu/2configs/bitlbee.nix index 52b5d68a..21626d40 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" ]; -- cgit v1.2.3 From 0fc70d222f4a7f10fac70936475cbbc0875c02ce Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 22:25:51 +0200 Subject: ma music.euer.krebsco.de: init --- krebs/3modules/makefu/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix index b0bd8324..ffdd9927 100644 --- a/krebs/3modules/makefu/default.nix +++ b/krebs/3modules/makefu/default.nix @@ -235,6 +235,7 @@ in { maps.work.euer IN A ${nets.internet.ip4.addr} play.work.euer IN A ${nets.internet.ip4.addr} ul.work.euer IN A ${nets.internet.ip4.addr} + music.euer IN A ${nets.internet.ip4.addr} ''; }; cores = 8; -- cgit v1.2.3 From 409751f547a805994f3f6a34a0d5bef49fe5e451 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 22:42:33 +0200 Subject: ma secrects: add lego-binaergewitter --- makefu/0tests/data/secrets/lego-binaergewitter | 0 makefu/2configs/default.nix | 4 +++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 makefu/0tests/data/secrets/lego-binaergewitter diff --git a/makefu/0tests/data/secrets/lego-binaergewitter b/makefu/0tests/data/secrets/lego-binaergewitter new file mode 100644 index 00000000..e69de29b diff --git a/makefu/2configs/default.nix b/makefu/2configs/default.nix index 7905cf4e..66c77e1e 100644 --- a/makefu/2configs/default.nix +++ b/makefu/2configs/default.nix @@ -52,6 +52,7 @@ with import ; gnumake rxvt_unicode.terminfo htop + nix-output-monitor ]; programs.bash.enableCompletion = true; @@ -86,8 +87,9 @@ with import ; ''; 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; } -- cgit v1.2.3 From 9d5087cba036585f3350faecf7966463c17adb62 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 22:48:01 +0200 Subject: ma pkgs.mediawiki-matrix-bot: disable tests (for now) --- makefu/5pkgs/custom/mediawiki-matrix-bot/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/makefu/5pkgs/custom/mediawiki-matrix-bot/default.nix b/makefu/5pkgs/custom/mediawiki-matrix-bot/default.nix index 4a91a916..3da539ee 100644 --- a/makefu/5pkgs/custom/mediawiki-matrix-bot/default.nix +++ b/makefu/5pkgs/custom/mediawiki-matrix-bot/default.nix @@ -1,4 +1,4 @@ -{ buildPythonApplication, fetchFromGitHub, feedparser, matrix-nio, docopt, aiohttp, aiofiles, +{ buildPythonApplication, fetchFromGitHub, feedparser, matrix-nio, docopt, aiohttp, aiofiles, types-aiofiles, mypy }: buildPythonApplication rec { @@ -16,7 +16,10 @@ buildPythonApplication rec { nativeBuildInputs = [ mypy ]; - checkPhase = '' - mypy --strict mediawiki_matrix_bot - ''; + #checkInputs = [ + # types-aiofiles + #]; + #checkPhase = '' + # mypy --strict mediawiki_matrix_bot + #''; } -- cgit v1.2.3 From 0c334ea99cf984920a442a27e33d000f7ac9c2d4 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 23:01:28 +0200 Subject: ma pkgs.tools: update --- makefu/2configs/tools/all.nix | 7 ++++--- makefu/2configs/tools/dev.nix | 1 + makefu/2configs/tools/games.nix | 1 + makefu/2configs/tools/maker.nix | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 makefu/2configs/tools/maker.nix diff --git a/makefu/2configs/tools/all.nix b/makefu/2configs/tools/all.nix index 6844fdfe..37673768 100644 --- a/makefu/2configs/tools/all.nix +++ b/makefu/2configs/tools/all.nix @@ -2,18 +2,19 @@ imports = [ ./android-pentest.nix ./consoles.nix - ./core.nix ./core-gui.nix - ./dev.nix + ./core.nix ./desktop.nix + ./dev.nix ./extra-gui.nix ./games.nix + ./maker.nix ./media.nix ./mobility.nix ./pcmanfm-extra.nix ./scanner-tools.nix - ./sec.nix ./sec-gui.nix + ./sec.nix ./studio.nix ]; } diff --git a/makefu/2configs/tools/dev.nix b/makefu/2configs/tools/dev.nix index 66bc9a0e..2b9baa9c 100644 --- a/makefu/2configs/tools/dev.nix +++ b/makefu/2configs/tools/dev.nix @@ -22,6 +22,7 @@ brain whatsupnix nixpkgs-pytools + nixpkgs-fmt hydra-check # git-related git-preview diff --git a/makefu/2configs/tools/games.nix b/makefu/2configs/tools/games.nix index 0f1e6179..507887cf 100644 --- a/makefu/2configs/tools/games.nix +++ b/makefu/2configs/tools/games.nix @@ -8,5 +8,6 @@ games-user-env wine pkg2zip + steam ]; } diff --git a/makefu/2configs/tools/maker.nix b/makefu/2configs/tools/maker.nix new file mode 100644 index 00000000..8388db58 --- /dev/null +++ b/makefu/2configs/tools/maker.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: +{ + users.users.makefu.packages = with pkgs; [ + # media + picard + asunder + #darkice + lame + # creation + blender + openscad + # slicing + cura + chitubox + ]; +} -- cgit v1.2.3 From f66a4cb237d29ae152ebb601b62bb6c9e29e4031 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 23:01:58 +0200 Subject: ma share: proxy hetzner via gum --- makefu/2configs/share/gum-client.nix | 23 +++++++++++++++-------- makefu/2configs/share/gum.nix | 9 ++------- makefu/2configs/share/hetzner-client.nix | 5 +++-- makefu/2configs/share/omo.nix | 6 ++++++ 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/makefu/2configs/share/gum-client.nix b/makefu/2configs/share/gum-client.nix index db2adfb1..5192ef51 100644 --- a/makefu/2configs/share/gum-client.nix +++ b/makefu/2configs/share/gum-client.nix @@ -2,21 +2,28 @@ let automount_opts = - [ "x-systemd.automount" - "noauto" "x-systemd.idle-timeout=600" - "x-systemd.device-timeout=5s" - "x-systemd.mount-timeout=5s" + [ "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=300" + "x-systemd.mount-timeout=60s" ]; - host = "nextgum"; #TODO + host = "gum"; #TODO in { - fileSystems."/media/download" = { - device = "//${host}/download"; + boot.extraModprobeConfig = '' + options cifs CIFSMaxBufSize=130048 + ''; + fileSystems."/media/cloud" = { + device = "//${host}/cloud-proxy"; fsType = "cifs"; options = automount_opts ++ [ "credentials=/var/src/secrets/download.smb" "file_mode=0775" "dir_mode=0775" - "uid=9001" + "bsize=8388608" + "fsc" + "rsize=130048" + "cache=loose" + "uid=${toString config.users.users.download.uid}" + "gid=${toString config.users.groups.download.gid}" "vers=3" ]; }; diff --git a/makefu/2configs/share/gum.nix b/makefu/2configs/share/gum.nix index fd81f28c..9647e0a6 100644 --- a/makefu/2configs/share/gum.nix +++ b/makefu/2configs/share/gum.nix @@ -1,6 +1,5 @@ { config, lib, pkgs, ... }: -with import ; let hostname = config.krebs.build.host.name; in { @@ -11,15 +10,11 @@ in { # home = "/var/empty"; # }; environment.systemPackages = [ pkgs.samba ]; - users.users.download = { - uid = genid "download"; - isNormalUser = true; - }; services.samba = { enable = true; shares = { - download = { - path = "/var/download"; + cloud-proxy = { + path = "/media/cloud"; "read only" = "no"; browseable = "yes"; "guest ok" = "no"; diff --git a/makefu/2configs/share/hetzner-client.nix b/makefu/2configs/share/hetzner-client.nix index 90bc32de..dc863736 100644 --- a/makefu/2configs/share/hetzner-client.nix +++ b/makefu/2configs/share/hetzner-client.nix @@ -21,11 +21,12 @@ in { "dir_mode=0770" "uid=${toString config.users.users.download.uid}" "gid=${toString config.users.groups.download.gid}" - #"vers=3" - "vers=2.1" + "vers=3" + #"vers=2.1" "rsize=65536" "wsize=130048" "iocharset=utf8" + "cache=loose" ]; }; } diff --git a/makefu/2configs/share/omo.nix b/makefu/2configs/share/omo.nix index e53158b8..4756ccf8 100644 --- a/makefu/2configs/share/omo.nix +++ b/makefu/2configs/share/omo.nix @@ -87,6 +87,12 @@ in { "guest ok" = "no"; "valid users" = "makefu"; }; + #cloud = { + # path = "/media/cloud/download/finished"; + # "read only" = "no"; + # browseable = "yes"; + # "guest ok" = "yes"; + #}; }; extraConfig = '' guest account = smbguest -- cgit v1.2.3 From 101256797fbfd78dfc1482ba99003bac2999b5b6 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 23:02:40 +0200 Subject: ma x.r: disable directly mounting of hetzner box --- makefu/1systems/x/config.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/makefu/1systems/x/config.nix b/makefu/1systems/x/config.nix index 0377c336..3f9e071e 100644 --- a/makefu/1systems/x/config.nix +++ b/makefu/1systems/x/config.nix @@ -137,7 +137,6 @@ # # - # -- cgit v1.2.3 From 3713bdf38ed4d9b4ff1c5ba4da5fedd7910b3af6 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 23:35:50 +0200 Subject: ma pkgs.ns-atmosphere-programmer: fix build --- makefu/5pkgs/ns-atmosphere-programmer/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/makefu/5pkgs/ns-atmosphere-programmer/default.nix b/makefu/5pkgs/ns-atmosphere-programmer/default.nix index aa7af992..7d9110e4 100644 --- a/makefu/5pkgs/ns-atmosphere-programmer/default.nix +++ b/makefu/5pkgs/ns-atmosphere-programmer/default.nix @@ -2,8 +2,9 @@ , makeWrapper , autoPatchelfHook , xorg -, gnome3 , libpng12 +, gtk3 +, gnome }: stdenv.mkDerivation rec { name = "ns-atmosphere-programmer-${version}"; @@ -15,13 +16,13 @@ stdenv.mkDerivation rec { sha256 = "1cnyydsmrcpfwpdiry7qybh179499wpbvlzq5rk442hq9ak416ri"; }; - buildInputs = with xorg; [ libX11 libXxf86vm libSM gnome3.gtk libpng12 ]; + buildInputs = with xorg; [ libX11 libXxf86vm libSM gtk3 libpng12 ]; nativeBuildInputs = [ autoPatchelfHook makeWrapper ]; installPhase = '' install -D -m755 NS-Atmosphere $out/bin/NS-Atmosphere wrapProgram $out/bin/NS-Atmosphere --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \ ---suffix XDG_DATA_DIRS : '${pkgs.gnome.adwaita-icon-theme}/share' +--suffix XDG_DATA_DIRS : '${gnome.adwaita-icon-theme}/share' ''; dontStrip = true; -- cgit v1.2.3 From 2dfde5dc6d37fb5bab8a1b658cfe7e5b21f5a2f4 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 23:39:10 +0200 Subject: ma bgt/download.binaergewitter.de: addssl instead of enableSSL --- makefu/2configs/bgt/download.binaergewitter.de.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefu/2configs/bgt/download.binaergewitter.de.nix b/makefu/2configs/bgt/download.binaergewitter.de.nix index 85379e77..d49ad158 100644 --- a/makefu/2configs/bgt/download.binaergewitter.de.nix +++ b/makefu/2configs/bgt/download.binaergewitter.de.nix @@ -75,7 +75,7 @@ in { recommendedGzipSettings = true; recommendedOptimisation = true; virtualHosts."download.binaergewitter.de" = { - enableSSL = true; + addSSL = true; enableACME = true; serverAliases = [ "dl2.binaergewitter.de" ]; root = "/var/www/binaergewitter"; -- cgit v1.2.3 From 3e8f855f60dfa5bf56ab3a1d1a54e0accccbd618 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 23 Sep 2022 23:41:30 +0200 Subject: ma ham: update --- .../2configs/home/ham/automation/buttonboard.nix | 4 + makefu/2configs/home/ham/automation/check-in.nix | 77 +++++++++++++++---- .../home/ham/automation/daily_speedtext.nix | 17 +++++ .../2configs/home/ham/automation/fenster_auf.nix | 55 +++++++++++++- .../home/ham/automation/firetv_restart.nix | 22 +++--- makefu/2configs/home/ham/automation/flurlicht.nix | 12 ++- .../home/ham/automation/shutdown_button.nix | 11 ++- makefu/2configs/home/ham/automation/urlaub.nix | 7 +- makefu/2configs/home/ham/default.nix | 58 ++++++++++----- makefu/2configs/home/ham/lib/default.nix | 11 +-- makefu/2configs/home/ham/light/tint_wohnzimmer.nix | 12 +-- .../home/ham/media/arbeitszimmer_matrix.nix | 14 ++-- .../home/ham/media/schlafzimmer_music_remote.nix | 50 ++++++------- makefu/2configs/home/ham/sensor/dwd.nix | 8 ++ makefu/2configs/home/ham/sensor/pollen.nix | 65 ++++++++++++++++ makefu/2configs/home/ham/signal-rest/service.nix | 2 + makefu/2configs/home/ham/zigbee2mqtt.nix | 87 ---------------------- 17 files changed, 321 insertions(+), 191 deletions(-) create mode 100644 makefu/2configs/home/ham/automation/buttonboard.nix create mode 100644 makefu/2configs/home/ham/automation/daily_speedtext.nix create mode 100644 makefu/2configs/home/ham/sensor/dwd.nix create mode 100644 makefu/2configs/home/ham/sensor/pollen.nix diff --git a/makefu/2configs/home/ham/automation/buttonboard.nix b/makefu/2configs/home/ham/automation/buttonboard.nix new file mode 100644 index 00000000..533311fc --- /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/check-in.nix b/makefu/2configs/home/ham/automation/check-in.nix index d589a697..db051757 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 00000000..70d59f6e --- /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 fa2052be..b3682fe0 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 12e0e845..01d1ba6e 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 aa62ab9e..bb487710 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 4c12be27..ec1a2556 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 c11c589c..7f47c9da 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/default.nix b/makefu/2configs/home/ham/default.nix index f54fd32f..b0815293 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 = []; automation = []; script = { }; + media_source = {}; }; enable = true; configDir = hassdir; diff --git a/makefu/2configs/home/ham/lib/default.nix b/makefu/2configs/home/ham/lib/default.nix index 67e8e902..cf1c32ab 100644 --- a/makefu/2configs/home/ham/lib/default.nix +++ b/makefu/2configs/home/ham/lib/default.nix @@ -14,7 +14,7 @@ in { service = "tts.google_say"; data = { - entity_id = entity; + entity_id = entity; inherit message; language = "de"; }; @@ -27,10 +27,7 @@ in #} { delay.seconds = 1; } { delay = '' - {% set duration = states.${entity}.attributes.media_duration %} - {% if duration > 0 %} - {% set duration = duration - 1 %} - {% endif %} + {% set duration = state_attr("${entity}","media_duration") %} {% set seconds = duration % 60 %} {% set minutes = (duration / 60)|int % 60 %} {% set hours = (duration / 3600)|int %} @@ -53,6 +50,10 @@ in inherit message; entity = "media_player.office"; }; + bedroom = message: tts { + inherit message; + entity = "media_player.bedroom"; + }; }; zigbee.prefix = "/ham/zigbee"; diff --git a/makefu/2configs/home/ham/light/tint_wohnzimmer.nix b/makefu/2configs/home/ham/light/tint_wohnzimmer.nix index 474bf5c9..24324381 100644 --- a/makefu/2configs/home/ham/light/tint_wohnzimmer.nix +++ b/makefu/2configs/home/ham/light/tint_wohnzimmer.nix @@ -21,24 +21,26 @@ let group_id_2 = 16389; group_id_3 = 16390; remote = "sensor.schlafzimmer_remote1_action"; - main_light_1 = "light.wled"; + main_light_1 = "light.wled"; # fernseher + main_light_2 = "light.wled_2"; #fernsehwand + default_scene_1 = "Solid"; default_color_1 = "Default"; main_color_select_1 = "select.wled_color_palette"; light_group_1.entity_id = [ main_light_1 + main_light_2 ]; # contains only the actually changeable lights - light_group_2 = { entity_id = [ + light_group_2.entity_id = [ "light.wohnzimmer_komode_osram" "light.wohnzimmer_schrank_osram" "light.wohnzimmer_fenster_lichterkette_licht" ]; - }; - light_group_3 = { entity_id = [ + light_group_3.entity_id = [ "light.wohnzimmer_stehlampe_osram" - ]; }; + ]; statecond = cond: { # cond must be a list condition = "template"; diff --git a/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix b/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix index bd36f02c..26fec370 100644 --- a/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix +++ b/makefu/2configs/home/ham/media/arbeitszimmer_matrix.nix @@ -32,10 +32,12 @@ in services.home-assistant.config.automation = [ { alias = "Arbeitszimmer Matrix music action"; + mode = "queued"; trigger = [ { platform = "state"; entity_id = all_buttons; + to = "on"; # ignore 'unavailable' } ]; action = @@ -59,17 +61,11 @@ in } ) - (remote_action "b9" - ((say "Guter Song {{ states.sensor.the_playlist_song.state }}") ++ [ - { service = "rest_command.good_song"; } - ])) + (remote_action "b9" [ { service = "rest_command.good_song"; } ]) + (remote_action "b10" [ { service = "rest_command.bad_song"; } ]) - (remote_action "b10" - ((say "Schlechter Song {{ states.sensor.the_playlist_song.state }}") ++ [ - { service = "rest_command.bad_song"; } - ])) (remote_action "3" - ((say "Starte Lassulus Super Radio") ++ [ + ((say "Starte Lass") ++ [ { service = "media_player.play_media"; data = { media_content_id = "http://radio.lassul.us:8000/radio.mp3"; diff --git a/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix b/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix index 55b1fd8f..438ce6bd 100644 --- a/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix +++ b/makefu/2configs/home/ham/media/schlafzimmer_music_remote.nix @@ -3,7 +3,8 @@ let remote = "sensor.schlafzimmer_music_remote_action"; hlib = import ../lib; step = 0.03; - room = "bedroom"; + #room = "bedroom"; + room = "living_room"; #room = "office"; player = "media_player.${room}"; @@ -68,6 +69,7 @@ in services.home-assistant.config.automation = [ { alias = "Schlafzimmer music action"; + mode = "queued"; trigger = [ { platform = "state"; @@ -79,20 +81,27 @@ in action = [ { choose = [ - (remote_action "on" { #also called by hold right and left - service = "media_player.media_play"; - target.entity_id = player; - }) - (remote_action "off" - { - service = "media_player.volume_mute"; + (remote_action "on" + ((say "Starte Essensmusik") ++ [ + { service = "media_player.play_media"; + data = { + media_content_id = "https://listen.openstream.co/4457/audio.mp3"; + media_content_type = "music"; + }; target.entity_id = player; - data.is_volume_muted = ''{{ not state_attr('${player}' , 'is_volume_muted') }}''; } + ])) + (remote_action "off" + [ + { + service = "media_player.media_stop"; + target.entity_id = player; + } + ] ) (remote_action "arrow_right_hold" - ((say "Starte Lassulus Super Radio") ++ [ + ((say "Starte Lass") ++ [ { service = "media_player.play_media"; data = { media_content_id = "http://radio.lassul.us:8000/radio.mp3"; @@ -101,7 +110,7 @@ in target.entity_id = player; } ])) - (remote_action "arrow_left_hold" + (remote_action "arrow_left_hold" ((say "Starte Deep House Music") ++ [ { service = "media_player.play_media"; data = { @@ -111,12 +120,7 @@ in target.entity_id = player; } ])) - #(remote_action "arrow_left_release" { - - #}) - #(remote_action "arrow_left_release" { - - #}) + # TODO: choose random kindermusik? (remote_action "brightness_move_up" ((say "Starte Liam Album") ++ [ @@ -130,14 +134,8 @@ in } ]) ) - (remote_action "brightness_move_down" - ((say "Stoppe Musik") ++ [ - { - service = "media_player.media_stop"; - target.entity_id = player; - } - ]) - ) + #(remote_action "brightness_move_down" + #) (remote_action "arrow_right_click" { service = "media_player.volume_set"; @@ -157,4 +155,4 @@ in } ]; -} \ No newline at end of file +} diff --git a/makefu/2configs/home/ham/sensor/dwd.nix b/makefu/2configs/home/ham/sensor/dwd.nix new file mode 100644 index 00000000..c1d55d03 --- /dev/null +++ b/makefu/2configs/home/ham/sensor/dwd.nix @@ -0,0 +1,8 @@ +{ + services.home-assistant.config.sensor = + [ + { platform = "dwd_weather_warnings"; + region_name = "Stadt Stuttgart"; + } + ]; +} diff --git a/makefu/2configs/home/ham/sensor/pollen.nix b/makefu/2configs/home/ham/sensor/pollen.nix new file mode 100644 index 00000000..d95c199b --- /dev/null +++ b/makefu/2configs/home/ham/sensor/pollen.nix @@ -0,0 +1,65 @@ +{ pkgs, lib, ... }: +with lib; +let + region = "112"; + types = [ + "Erle" + "Beifuss" + "Ambrosia" + "Birke" + "Esche" + "Hasel" + "Graeser" + "Roggen" + ]; + gen_tomorrow_sensor = type: { + name = "dwd_pollenbelastung_${toLower type}_tomorrow"; + value = { + icon_template = "mdi:grass"; + friendly_name = "${type} Morgen"; + value_template = "{{ state_attr('sensor.dwd_pollenbelastung_${toLower type}', 'tomorrow') }}"; + }; + }; + gen_sensor = type: { + name = "dwd_pollenbelastung_${toLower type}"; + value = { + icon_template = "mdi:tree-outline"; + friendly_name = type; + value_template = '' + {% set dwd_state = state_attr('sensor.dwd_pollenbelastung_stuttgart', '${type}')['today'] %} + {% if dwd_state == "3" %}6{% elif dwd_state == "2-3"%}5{% elif dwd_state == "2"%}4{% elif dwd_state == "1-2"%}3{% elif dwd_state == "1"%}2{% elif dwd_state == "0-1"%}1{% else %}0{% endif %} + ''; + attribute_templates.today = '' + {% set dwd_state = state_attr('sensor.dwd_pollenbelastung_stuttgart', '${type}')['today'] %} + {% if dwd_state == "3" %}6{% elif dwd_state == "2-3"%}5{% elif dwd_state == "2"%}4{% elif dwd_state == "1-2"%}3{% elif dwd_state == "1"%}2{% elif dwd_state == "0-1"%}1{% else %}0{% endif %} + ''; + attribute_templates.tomorrow = '' + {% set dwd_state = state_attr('sensor.dwd_pollenbelastung_stuttgart', '${type}')['tomorrow'] %} + {% if dwd_state == "3" %}6{% elif dwd_state == "2-3"%}5{% elif dwd_state == "2"%}4{% elif dwd_state == "1-2"%}3{% elif dwd_state == "1"%}2{% elif dwd_state == "0-1"%}1{% else %}0{% endif %} + ''; + # -1 == unknown + #attribute_templates.dayafter = '' + # {% set dwd_state = state_attr('sensor.dwd_pollenbelastung', '${type}')['dayafter_to'] %} + # {% if dwd_state == "3" %}6{% elif dwd_state == "2-3"%}5{% elif dwd_state == "2"%}4{% elif dwd_state == "1-2"%}3{% elif dwd_state == "1"%}2{% elif dwd_state == "0-1"%}1{% elif dwd_state == "-1"%}-1{% else %}0{% endif %} + #''; + }; + }; +in + { + services.home-assistant.config.sensor = [ + { + platform = "rest"; + scan_interval = 3600; + name = "DWD Pollenbelastung Stuttgart"; + resource = "https://opendata.dwd.de/climate_environment/health/alerts/s31fg.json"; + json_attributes_path = "$..content[?(@.partregion_id==${region})].Pollen"; + json_attributes = types; + value_template = "{{ value_json.last_update }}"; + } + { + platform = "template"; + sensors = (listToAttrs (map gen_sensor types)) // + (listToAttrs (map gen_tomorrow_sensor types)) ; + } + ]; +} diff --git a/makefu/2configs/home/ham/signal-rest/service.nix b/makefu/2configs/home/ham/signal-rest/service.nix index 250a3596..1f718efa 100644 --- a/makefu/2configs/home/ham/signal-rest/service.nix +++ b/makefu/2configs/home/ham/signal-rest/service.nix @@ -14,5 +14,7 @@ in { volumes = [ "${config}:/home/.local/share/signal-cli" ]; + environment.MODE ="json-rpc"; + #environment.MODE ="native"; # only required for reigstration }; } diff --git a/makefu/2configs/home/ham/zigbee2mqtt.nix b/makefu/2configs/home/ham/zigbee2mqtt.nix index 7809dbb5..efcbb0d0 100644 --- a/makefu/2configs/home/ham/zigbee2mqtt.nix +++ b/makefu/2configs/home/ham/zigbee2mqtt.nix @@ -38,93 +38,6 @@ in icon = "mdi:chip"; } ]; - switch = [ - { - platform = "mqtt"; - name = "Zigbee2mqtt Main join"; - state_topic = "${prefix}/bridge/config/permit_join"; - command_topic = "${prefix}/bridge/config/permit_join"; - payload_on = "true"; - payload_off = "false"; - } - ]; - automation = [ - { - alias = "Zigbee2mqtt Log Level"; - initial_state = "on"; - trigger = { - platform = "state"; - entity_id = "input_select.zigbee2mqtt_log_level"; - }; - action = [ - { - service = "mqtt.publish"; - data = { - payload_template = "{{ states('input_select.zigbee2mqtt_log_level') }}"; - topic = "${prefix}/bridge/config/log_level"; - }; - } - ]; - } - # Automation to start timer when enable join is turned on - { - id = "zigbee_join_enabled"; - alias = "Zigbee Join Enabled"; - trigger = - { - platform = "state"; - entity_id = "switch.zigbee2mqtt_main_join"; - to = "on"; - }; - action = - { - service = "timer.start"; - entity_id = "timer.zigbee_permit_join"; - }; - } - # # Automation to stop timer when switch turne