summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2020-03-13 10:41:01 +0100
committermakefu <github@syntax-fehler.de>2020-03-13 10:41:01 +0100
commitf28d580a4f86041d6f0df9482315d36673d8ef9d (patch)
tree123226642f9349bc86f659a700be41f3cdea8fdc
parenta72d8c58747de4b554b6f9643ba7e6db9249cf8a (diff)
ma bureautomation: use discovery, cleanup
-rw-r--r--makefu/2configs/bureautomation/automation/daily-news.nix20
-rw-r--r--makefu/2configs/bureautomation/automation/quotes.nix4
-rw-r--r--makefu/2configs/bureautomation/automation/schlechteluft.nix3
-rw-r--r--makefu/2configs/bureautomation/camera/stuttgart.nix16
-rw-r--r--makefu/2configs/bureautomation/default.nix21
-rw-r--r--makefu/2configs/bureautomation/deps/aresponses.nix38
-rw-r--r--makefu/2configs/bureautomation/multi/10h_timers.nix59
-rw-r--r--makefu/2configs/bureautomation/multi/daily-standup.nix4
-rw-r--r--makefu/2configs/bureautomation/multi/frosch.nix6
-rw-r--r--makefu/2configs/bureautomation/multi/mittagessen.nix6
-rw-r--r--makefu/2configs/bureautomation/person/team.nix19
-rw-r--r--makefu/2configs/bureautomation/puppy-proxy.nix5
-rw-r--r--makefu/2configs/bureautomation/script/multi_blink.nix12
-rw-r--r--makefu/2configs/bureautomation/stream/puppies.nix4
14 files changed, 172 insertions, 45 deletions
diff --git a/makefu/2configs/bureautomation/automation/daily-news.nix b/makefu/2configs/bureautomation/automation/daily-news.nix
new file mode 100644
index 000000000..2bafe4795
--- /dev/null
+++ b/makefu/2configs/bureautomation/automation/daily-news.nix
@@ -0,0 +1,20 @@
+[
+ {
+ alias = "Daily news for Felix";
+ trigger = {
+ platform = "time";
+ at = "07:35:00";
+ };
+ action =
+ [
+ {
+ service = "notify.telegrambot";
+ data_template = {
+ title = "Daily News";
+ # TODO
+ message = "";
+ };
+ }
+ ];
+ }
+]
diff --git a/makefu/2configs/bureautomation/automation/quotes.nix b/makefu/2configs/bureautomation/automation/quotes.nix
new file mode 100644
index 000000000..c4625ae30
--- /dev/null
+++ b/makefu/2configs/bureautomation/automation/quotes.nix
@@ -0,0 +1,4 @@
+# heiss
+Lieber Freund, was für ein Sommer! Ich denke Sie mir im Zimmer sitzend, mehr Omelette als Mensch.
+Sommer ist die Zeit, in der es zu heiß ist, um das zu tun, wozu es im Winter zu kalt war.
+
diff --git a/makefu/2configs/bureautomation/automation/schlechteluft.nix b/makefu/2configs/bureautomation/automation/schlechteluft.nix
index 8787ee280..370334743 100644
--- a/makefu/2configs/bureautomation/automation/schlechteluft.nix
+++ b/makefu/2configs/bureautomation/automation/schlechteluft.nix
@@ -66,9 +66,6 @@ in [
language = "de";
};
}
- { service = "notify.matrix_notify";
- data_template.message = "Schlechte Luft Alarm seit ${toString long_threshold} Minuten ({{states.sensor.air_quality.state_with_unit}})!";
- }
];
}
]
diff --git a/makefu/2configs/bureautomation/camera/stuttgart.nix b/makefu/2configs/bureautomation/camera/stuttgart.nix
index 99eecd5d9..78cbeb3e2 100644
--- a/makefu/2configs/bureautomation/camera/stuttgart.nix
+++ b/makefu/2configs/bureautomation/camera/stuttgart.nix
@@ -8,5 +8,19 @@ let
in [
( cam "Max-Eyth-See" https://www.wav-stuttgart.de/webcam/_/webcam1.jpg )
( cam "Wilhelma" http://webcam.wilhelma.de/webcam02/webcam02.jpg )
- ( cam "Wilhelma" http://webcam.wilhelma.de/webcam02/webcam02.jpg )
+ ( cam "Marktplatz" https://webcam.stuttgart.de/wcam007/current.jpg )
+ ( cam "Schoch Areal" https://webcam.stuttgart.de/wcam004/current.jpg )
+ ( cam "Leuze" https://webcam.stuttgart.de/wcam005/current.jpg )
+ ( cam "Straße Wilhelma" https://webcam.stuttgart.de/wcam006/current.jpg )
+ ( cam "Fernsehturm 1" http://webcam.fernsehturmstuttgart.com/current.jpg )
+ ( cam "Fernsehturm 2" http://webcam.fernsehturmstuttgart.com/current2.jpg )
+ ( cam "Feuerbach Lemberg" http://www.regio7.de/handy/current.jpg )
+ ( cam "Flughafen Stuttgart 1" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam2.jpg )
+ ( cam "Flughafen Stuttgart 2" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam5.jpg )
+ ( cam "Flughafen Stuttgart 3" http://webcam.flughafen-stuttgart.de/Flughafen_Stuttgart_Webcam7.jpg )
+ ( cam "S21 1" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-03/s21-turm03.jpg )
+ ( cam "S21 2" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-02/s21-turm-02.jpg )
+ ( cam "S21 3" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-01/s21-turm-01.jpg )
+ ( cam "S21 4" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Jaegerstrasse-Nordkopf/s21-jaegerstrassse-nordkopf.jpg )
+ ( cam "S21 5" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Bahndirektion-Nord/S21-Bundesbahndirektion-Nord.jpg )
]
diff --git a/makefu/2configs/bureautomation/default.nix b/makefu/2configs/bureautomation/default.nix
index c55bc1d14..3c1659558 100644
--- a/makefu/2configs/bureautomation/default.nix
+++ b/makefu/2configs/bureautomation/default.nix
@@ -11,6 +11,7 @@ in {
imports = [
./ota.nix
./comic-updater.nix
+ ./puppy-proxy.nix
];
networking.firewall.allowedTCPPorts = [ 8123 ];
state = [ "/var/lib/hass/known_devices.yaml" ];
@@ -33,13 +34,14 @@ in {
'';
})).override {
extraPackages = ps: with ps; [
- pkgs.pico2wave
+ pkgs.picotts
python-forecastio jsonrpc-async jsonrpc-websocket mpd2
(callPackage ./deps/openwrt-luci-rpc.nix { })
];
};
autoExtraComponents = true;
config = {
+ discovery = {};
homeassistant = {
name = "Bureautomation";
time_zone = "Europe/Berlin";
@@ -72,6 +74,8 @@ in {
};
matrix = matrix.matrix;
mqtt = {
+ discovery = true;
+ discovery_prefix = "homeassistant";
broker = "localhost";
port = 1883;
client_id = "home-assistant";
@@ -124,7 +128,7 @@ in {
frosch.script
ten_hours.script
mittagessen.script
- standup.script
+ # standup.script
];
binary_sensor =
(import ./binary_sensor/buttons.nix)
@@ -145,7 +149,8 @@ in {
camera =
(import ./camera/verkehrskamera.nix)
- ++ (import ./camera/comic.nix);
+ ++ (import ./camera/comic.nix)
+ ++ (import ./camera/stuttgart.nix);
person =
(import ./person/team.nix );
@@ -198,9 +203,10 @@ in {
"switch.blitzdings"
"switch.fernseher"
"switch.feuer"
+ "switch.frosch_blasen"
"light.status_felix"
- "light.status_daniel"
- "light.buslicht"
+ # "light.status_daniel"
+ # "light.buslicht"
];
team = [
"person.thorsten"
@@ -212,6 +218,7 @@ in {
"person.thierry"
"person.frank"
"person.emeka"
+ "person.tancrede"
#"device_tracker.felix_phone"
#"device_tracker.ecki_tablet"
#"device_tracker.daniel_phone"
@@ -228,6 +235,7 @@ in {
"camera.Baumarkt"
"camera.Autobahn_Heilbronn"
"camera.Autobahn_Singen"
+ "camera.puppies"
"camera.poorly_drawn_lines"
];
nachtlicht = [
@@ -264,7 +272,6 @@ in {
outside = [
# "sensor.ditzingen_pm10"
# "sensor.ditzingen_pm25"
- "sensor.dark_sky_icon"
"sensor.dark_sky_temperature"
"sensor.dark_sky_humidity"
"sensor.dark_sky_uv_index"
@@ -282,7 +289,7 @@ in {
++ (import ./automation/hass-restart.nix)
++ ten_hours.automation
++ matrix.automation
- ++ standup.automation
+ # ++ standup.automation
++ frosch.automation
++ mittagessen.automation;
device_tracker = (import ./device_tracker/openwrt.nix );
diff --git a/makefu/2configs/bureautomation/deps/aresponses.nix b/makefu/2configs/bureautomation/deps/aresponses.nix
new file mode 100644
index 000000000..9e64d2f65
--- /dev/null
+++ b/makefu/2configs/bureautomation/deps/aresponses.nix
@@ -0,0 +1,38 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+# propagatedBuildInputs
+, aiohttp
+# buildInputs
+, pytest
+, pytest-asyncio
+}:
+
+buildPythonPackage rec {
+ pname = "aresponses";
+ version = "1.1.1";
+
+ src = fetchPypi {
+ inherit pname version;
+ sha256 = "d1d6ef52b9a97142d106688cf9b112602ef3dc66f6368de8f91f47241d8cfc9c";
+ };
+
+ propagatedBuildInputs = [
+ aiohttp
+ ];
+
+ buildInputs = [
+ pytest
+ pytest-asyncio
+ ];
+
+ # tests only distributed via git repository, not pypi
+ doCheck = false;
+
+ meta = with lib; {
+ description = "Asyncio testing server";
+ homepage = "https://github.com/circleup/aresponses";
+ license = licenses.mit;
+ maintainers = [ maintainers.makefu ];
+ };
+}
diff --git a/makefu/2configs/bureautomation/multi/10h_timers.nix b/makefu/2configs/bureautomation/multi/10h_timers.nix
index 73709e738..a30fb28b0 100644
--- a/makefu/2configs/bureautomation/multi/10h_timers.nix
+++ b/makefu/2configs/bureautomation/multi/10h_timers.nix
@@ -2,6 +2,8 @@
let
persons = [ "frank" "daniel" "thorsten" "carsten" "ecki" "felix"
"thierry" # tjeri
+ "emeka"
+ "tancrede"
];
random_zu_lange = name: ''{{ [
"Du musst jetzt endlich nach Hause gehen ${name}!",
@@ -20,6 +22,7 @@ let
random_announce = name: ''{{ [
"${name} is in da House",
"Ahoi ${name}",
+ "Hallöchen Popöchen ${name}",
"Moinsen ${name}",
"Moin Moin ${name}",
"Palim, Palim ${name}",
@@ -55,7 +58,7 @@ let
"Und es startet für ${name} wieder ein Tag im Paradies",
"Lieber ${name}, Markus Keck hat dich bereits drei mal Versucht anzurufen!",
"Trotz schwerer Männergrippe ist ${name} heute im Büro erschienen.",
- "${name} kenne keine Parteien mehr, ${name} kenne nur noch Arbeitsplätze",
+ "${name} kennt keine Parteien mehr, ${name} kennt nur noch Arbeitsplätze",
"${name}, Frage nicht, was dein Arbeitsplatz für dich tun kann. Frage, was du für deinen Arbeitsplatz tun kannst",
"${name} läuft bis in den Jemen - für sein Unternehmen. ${name} schwimmt bis nach Birma - für seine Firma",
"Der Cyberian ${name} ist gekommen um die Bahnwelt vor Cyber-Angriffen zu schützen",
@@ -121,7 +124,6 @@ let
{ alias = "start ${name} 10h";
trigger = {
platform = "state";
- # TODO: ecki
entity_id = [ "person.${name}"];
from = "not_home";
to = "home";
@@ -129,13 +131,11 @@ let
condition = {
condition = "and";
conditions = [
- {
- condition = "state";
+ { condition = "state";
entity_id = "timer.${name}_10h";
state = "idle";
}
- {
- condition = "time";
+ { condition = "time";
after = "06:00:00";
before = "12:00:00";
}
@@ -146,8 +146,8 @@ let
entity_id = [ "timer.${name}_10h" ] ;
}
{ service = "homeassistant.turn_on";
- entity_id = [
- # "switch.fernseher"
+ entity_id =
+ [ "switch.fernseher"
"script.blitz_10s"
"script.announce_${name}"
];
@@ -155,30 +155,45 @@ let
];
}
+ { alias = "pommes announce ${name}";
+ trigger =
+ { platform = "event";
+ event_type = "timer.started";
+ event_data.entity_id = "timer.${name}_10h";
+ };
+
+ condition =
+ { condition = "state";
+ entity_id = "binary_sensor.pommes";
+ state = "on";
+ };
+
+ action =
+ { service = "homeassistant.turn_on";
+ entity_id = "script.blasen_10s" ;
+ };
+ }
+
{ alias = "Zu lange ${name}!";
trigger =
- {
- platform = "event";
+ { platform = "event";
event_type = "timer.finished";
event_data.entity_id = "timer.${name}_10h";
};
condition =
- {
- condition = "state";
+ { condition = "state";
entity_id = "person.${name}";
state = "home";
};
action =
- [
- { service = "homeassistant.turn_on";
- entity_id = [
- "script.blitz_10s"
- "script.zu_lange_${name}"
- ];
- }
- ];
+ { service = "homeassistant.turn_on";
+ entity_id = [
+ "script.blitz_10s"
+ "script.zu_lange_${name}"
+ ];
+ };
}
];
in
@@ -187,7 +202,7 @@ in
(map tmr_10h persons);
automation = (lib.flatten (map automation_10h persons));
script = lib.fold lib.recursiveUpdate {} (
- (map (p: announce_user p) persons) ++
- (map (p: zu_lange_user p) persons)
+ (map announce_user persons) ++
+ (map zu_lange_user persons)
);
}
diff --git a/makefu/2configs/bureautomation/multi/daily-standup.nix b/makefu/2configs/bureautomation/multi/daily-standup.nix
index f5bd85b9d..38fb22c1a 100644
--- a/makefu/2configs/bureautomation/multi/daily-standup.nix
+++ b/makefu/2configs/bureautomation/multi/daily-standup.nix
@@ -3,9 +3,9 @@ let
random_daily_text = ''{{ [
"Es ist so weit, es ist Standup Zeit!",
"Zehn Uhr Fünfunddreissig ist genau die richtige Zeit für ein Standup!",
- "Hat jeder seine Hausaufgaben gemacht? Bitte einmal aufstehen und den Zettel nach rechts geben",
+ "Hat jeder seine zum Standup seine Hausaufgaben gemacht. Bitte einmal aufstehen und den Zettel nach rechts geben",
"Aufstehen zum Appell, es wird die Anwesenheit kontrolliert!",
- "Hallo Kinder, wisst ihr welche Zeit es ist??? ... Genau! ... Standup Zeit!",
+ "Hallo Kinder, wisst ihr welche Zeit es ist ... Genau ... Standup Zeit!",
"Morgens, halb elf in Deutschland - das Standupchen" ] | random }}'';
in {
diff --git a/makefu/2configs/bureautomation/multi/frosch.nix b/makefu/2configs/bureautomation/multi/frosch.nix
index c0e267b69..816539d46 100644
--- a/makefu/2configs/bureautomation/multi/frosch.nix
+++ b/makefu/2configs/bureautomation/multi/frosch.nix
@@ -1,5 +1,6 @@
{ lib }:
# needs: binary_sensor.pommes
+# notify.matrix_notify
let
random_pommes = '' {{ [
"Nur ein Pommes Tag ist ein guter Tag",
@@ -51,7 +52,7 @@ in {
{ alias = "Pommeszeit";
trigger = {
platform = "time";
- at = "12:15:00";
+ at = "11:00:00";
};
condition = {
condition = "state";
@@ -89,6 +90,9 @@ in {
language = "de";
};
}
+ { service = "notify.matrix_notify";
+ data_template.message = random_pommes;
+ }
];
};
};
diff --git a/makefu/2configs/bureautomation/multi/mittagessen.nix b/makefu/2configs/bureautomation/multi/mittagessen.nix
index 3ec70998d..2a9993e92 100644
--- a/makefu/2configs/bureautomation/multi/mittagessen.nix
+++ b/makefu/2configs/bureautomation/multi/mittagessen.nix
@@ -22,9 +22,9 @@ let
"Heute bei Aramark: Rezepte aus Ländern, von denen Ihr noch nie gehört habt, Deutsch zubereitet",
"Heute bei Aramark im Angebot: Scheiss mit Reis oder Reste von Freitag",
"MHHHH es ist wieder mal so weit, lecker Bayerisch Kraut mit asiatischen Nudeln",
- "Es ist 12 Uhr 30 und Heute gibt es Pommes - vielleicht",
- "Heute gibt es Pommes - leider nicht einzeln zu verkaufen, da die Schälchen alle sind",
- "Heute gibt es Pommes - verarscht! Natürlich gibt es nur salzlosen Reis, oder salzlose Nudeln.",
+ "Es ist 12 Uhr 30 und Heute gibt es nur Pommes, wenn der Pommesfrosch Blasen gespuckt hat.",
+ "Heute gibt es Pommes leider nicht einzeln zu verkaufen, da die Schälchen alle sind",
+ "Heute gibt es Pommes, verarscht! Natürlich gibt es nur salzlosen Reis, oder salzlose Nudeln.",
"Heute auf dem Speiseplan: Sushi vom Vortag",
"Aramark Kantinenessen: Der Hunger treibt es rein, der Geiz hält es drin.",
"Das Essen in der Snackeria sieht heute wie die bessere Alternative aus",
diff --git a/makefu/2configs/bureautomation/person/team.nix b/makefu/2configs/bureautomation/person/team.nix
index fc2d9ba17..2a15abaf5 100644
--- a/makefu/2configs/bureautomation/person/team.nix
+++ b/makefu/2configs/bureautomation/person/team.nix
@@ -50,16 +50,23 @@
"device_tracker.emeka_phone"
];
}
- #{ name = "Sabine";
- # id = 9;
- # device_trackers = [
- # "device_tracker.sabine_phone"
- # ];
- #}
+ { name = "Sabine";
+ id = 9;
+ device_trackers = [
+ "device_tracker.sabine_phone"
+ ];
+ }
{ name = "Tobias";
id = 10;
device_trackers = [
"device_tracker.tobias_phone"
];
}
+ { name = "Tancrede";
+ id = 11;
+ device_trackers = [
+ "device_tracker.tancrede_phone"
+ "device_tracker.tancrede_laptop"
+ ];
+ }
]
diff --git a/makefu/2configs/bureautomation/puppy-proxy.nix b/makefu/2configs/bureautomation/puppy-proxy.nix
new file mode 100644
index 000000000..9e3542509
--- /dev/null
+++ b/makefu/2configs/bureautomation/puppy-proxy.nix
@@ -0,0 +1,5 @@
+{ pkgs, ... }:
+# streamlink 'https://www.ustream.tv/channel/maximilian-schnauzers-cam4' worst --player-external-http --player-external-http-port 15321 --player-passthrough rtsp --retry-streams 60
+{
+ environment.systemPackages = [ pkgs.liveproxy ];
+}
diff --git a/makefu/2configs/bureautomation/script/multi_blink.nix b/makefu/2configs/bureautomation/script/multi_blink.nix
index 5076111ac..e6acdc303 100644
--- a/makefu/2configs/bureautomation/script/multi_blink.nix
+++ b/makefu/2configs/bureautomation/script/multi_blink.nix
@@ -36,6 +36,18 @@ in {
count = 1;
alias = "blitz for 10 seconds";
});
+ blasen_10s = (flash_entity {
+ entity = "switch.frosch_blasen";
+ delay = 10000;
+ count = 1;
+ alias = "blasen for 10 seconds";
+ });
+ blasen_30s = (flash_entity {
+ entity = "switch.frosch_blasen";
+ delay = 30000;
+ count = 1;
+ alias = "blasen for 30 seconds";
+ });
schlechteluft = (flash_entity {
entity = "switch.bauarbeiterlampe";
alias = "Schlechte Luft Lampe 5 secs";
diff --git a/makefu/2configs/bureautomation/stream/puppies.nix b/makefu/2configs/bureautomation/stream/puppies.nix
new file mode 100644
index 000000000..d22be9ea6
--- /dev/null
+++ b/makefu/2configs/bureautomation/stream/puppies.nix
@@ -0,0 +1,4 @@
+[
+ { stream_source = "http://127.0.0.1:53422/base64/c3RyZWFtbGluayBodHRwczovL3d3dy51c3RyZWFtLnR2L2NoYW5uZWwvbWF4aW1pbGlhbi1zY2huYXV6ZXJzLWNhbTIgd29yc3Q=/";
+ }
+]