ma bureautomation: move to 20.09 style imports

This commit is contained in:
makefu 2020-11-18 20:50:43 +01:00
parent f66309f028
commit a549744127
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
29 changed files with 795 additions and 752 deletions

View File

@ -1,4 +1,6 @@
[ {
services.home-assistant.config.automation =
[
{ alias = "Turn on Fernseher on group home"; { alias = "Turn on Fernseher on group home";
trigger = { trigger = {
platform = "state"; platform = "state";
@ -81,4 +83,5 @@
]; ];
}; };
} }
] ];
}

View File

@ -1,4 +1,6 @@
[ {
services.home-assistant.config.automation =
[
{ alias = "State on HA start-up"; { alias = "State on HA start-up";
trigger = { trigger = {
platform = "homeassistant"; platform = "homeassistant";
@ -28,4 +30,5 @@
#} #}
]; ];
} }
] ];
}

View File

@ -1,4 +1,6 @@
[ {
services.home-assistant.config.automation =
[
# TODO: trigger if it is before dusk and somebody arives but nachtlichter are # TODO: trigger if it is before dusk and somebody arives but nachtlichter are
# off from last day # off from last day
# TODO: do not have nachtlicht turned on at night # TODO: do not have nachtlicht turned on at night
@ -32,4 +34,5 @@
entity_id = [ "group.nachtlicht" ]; entity_id = [ "group.nachtlicht" ];
}; };
} }
] ];
}

View File

@ -1,6 +1,9 @@
let let
long_threshold = 30; long_threshold = 30;
in [ in
{
services.home-assistant.config.automation =
[
{ {
alias = "Bad Air Alarm 60 seconds"; alias = "Bad Air Alarm 60 seconds";
trigger = trigger =
@ -68,4 +71,5 @@ in [
} }
]; ];
} }
] ];
}

View File

@ -12,6 +12,9 @@ let
# expire_after = "5"; #expire after 5 seconds # expire_after = "5"; #expire after 5 seconds
qos = 1; qos = 1;
}; };
in [ in {
services.home-assistant.config.binary_sensor =
[
(tasmota_button "RedButton" "redbutton") (tasmota_button "RedButton" "redbutton")
] ];
}

View File

@ -1,4 +1,6 @@
[ {
services.home-assistant.config.binary_sensor =
[
{ platform = "mqtt"; { platform = "mqtt";
device_class = "motion"; device_class = "motion";
name = "Motion"; name = "Motion";
@ -9,4 +11,5 @@
payload_available = "Online"; payload_available = "Online";
payload_not_available = "Offline"; payload_not_available = "Offline";
} }
] ];
}

View File

@ -1,4 +1,6 @@
[ {
services.home-assistant.config.camera =
[
{ name = "Poorly Drawn Lines"; { name = "Poorly Drawn Lines";
platform = "generic"; platform = "generic";
still_image_url = http://127.0.0.1:8123/local/lines.png ; still_image_url = http://127.0.0.1:8123/local/lines.png ;
@ -7,4 +9,5 @@
platform = "generic"; platform = "generic";
still_image_url = http://127.0.0.1:8123/local/xkcd.png ; still_image_url = http://127.0.0.1:8123/local/xkcd.png ;
} }
] ];
}

View File

@ -5,7 +5,10 @@ let
inherit name still_image_url; inherit name still_image_url;
platform = "generic"; platform = "generic";
}; };
in [ in
{
services.home-assistant.config.camera =
[
( cam "Max-Eyth-See" https://www.wav-stuttgart.de/webcam/_/webcam1.jpg ) ( 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 "Marktplatz" https://webcam.stuttgart.de/wcam007/current.jpg )
@ -23,4 +26,5 @@ in [
( cam "S21 3" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Turm-01/s21-turm-01.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 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 ) ( cam "S21 5" http://webcam-bahnprojekt-stuttgart-ulm.de/S21-Bahndirektion-Nord/S21-Bundesbahndirektion-Nord.jpg )
] ];
}

View File

@ -1,4 +1,6 @@
[ {
services.home-assistant.config.camera =
[
{ name = "Baumarkt"; { name = "Baumarkt";
platform = "generic"; platform = "generic";
still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt
@ -11,4 +13,5 @@
platform = "generic"; platform = "generic";
still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ; still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ;
} }
] ];
}

View File

@ -1,20 +1,51 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
kodi-host = "192.168.8.11"; kodi-host = "192.168.8.11";
ten_hours = import ./multi/10h_timers.nix { inherit lib; }; # provides: timer automation script
mittagessen = import ./multi/mittagessen.nix { inherit lib; }; # provides: automation script
matrix = import ./multi/matrix.nix { inherit lib; }; # provides: matrix automation
frosch = import ./multi/frosch.nix { inherit lib; }; # provides: sensor binary_sensor switch light script automation
aramark = import ./multi/aramark.nix { inherit lib; }; # provides: sensor binary_sensor
standup = import ./multi/daily-standup.nix { inherit lib; }; # provides: automation script
in { in {
imports = [ imports = [
./ota.nix ./ota.nix
./comic-updater.nix ./comic-updater.nix
./puppy-proxy.nix ./puppy-proxy.nix
# hass config
## complex configs
./multi/daily-standup.nix
./multi/aramark.nix
./multi/matrix.nix
./multi/frosch.nix
./multi/mittagessen.nix
./multi/10h_timers.nix
./switch/tasmota_switch.nix
./switch/rfbridge.nix
./light/statuslight.nix
./light/buzzer.nix
./script/multi_blink.nix
./binary_sensor/buttons.nix
./binary_sensor/motion.nix
# ./sensor/pollen.nix requires dwd_pollen
./sensor/espeasy.nix
./sensor/airquality.nix
./sensor/outside.nix
./sensor/tasmota_firmware.nix
./camera/verkehrskamera.nix
./camera/comic.nix
./camera/stuttgart.nix
./automation/bureau-shutdown.nix
./automation/nachtlicht.nix
./automation/schlechteluft.nix
./automation/hass-restart.nix
./device_tracker/openwrt.nix
./person/team.nix
]; ];
networking.firewall.allowedTCPPorts = [ 8123 ]; networking.firewall.allowedTCPPorts = [ 8123 ];
state = [ "/var/lib/hass/known_devices.yaml" ]; state = [ "/var/lib/hass/known_devices.yaml" ];
services.home-assistant = { services.home-assistant = {
enable = true; enable = true;
autoExtraComponents = true; autoExtraComponents = true;
@ -51,7 +82,6 @@ in {
source = "hass"; source = "hass";
}; };
}; };
matrix = matrix.matrix;
mqtt = { mqtt = {
discovery = true; discovery = true;
discovery_prefix = "homeassistant"; discovery_prefix = "homeassistant";
@ -73,13 +103,6 @@ in {
retain = true; retain = true;
}; };
}; };
switch = (import ./switch/tasmota_switch.nix)
++ frosch.switch
++ (import ./switch/rfbridge.nix);
light = (import ./light/statuslight.nix)
++ (import ./light/buzzer.nix)
++ frosch.light;
timer = ten_hours.timer;
notify = [ notify = [
{ {
platform = "kodi"; platform = "kodi";
@ -93,7 +116,7 @@ in {
(builtins.fromJSON (builtins.readFile (builtins.fromJSON (builtins.readFile
<secrets/hass/telegram-bot.json>)).allowed_chat_ids 0; <secrets/hass/telegram-bot.json>)).allowed_chat_ids 0;
} }
] ++ matrix.notify; ];
media_player = [ media_player = [
{ platform = "kodi"; { platform = "kodi";
host = kodi-host; host = kodi-host;
@ -102,37 +125,10 @@ in {
host = "127.0.0.1"; host = "127.0.0.1";
} }
]; ];
script = lib.fold lib.recursiveUpdate {} [
((import ./script/multi_blink.nix) {inherit lib;})
frosch.script
ten_hours.script
mittagessen.script
# standup.script
];
binary_sensor =
(import ./binary_sensor/buttons.nix)
++ (import ./binary_sensor/motion.nix)
++ frosch.binary_sensor
++ aramark.binary_sensor;
sensor = [] sensor = [{ platform = "version"; }]; # pyhaversion
++ [{ platform = "version"; }] # pyhaversion
# ++ (import ./sensor/pollen.nix)
++ (import ./sensor/espeasy.nix)
++ (import ./sensor/airquality.nix)
++ ((import ./sensor/outside.nix) {inherit lib;})
++ (import ./sensor/influxdb.nix)
++ (import ./sensor/tasmota_firmware.nix)
++ frosch.sensor
++ aramark.sensor;
camera =
(import ./camera/verkehrskamera.nix)
++ (import ./camera/comic.nix)
++ (import ./camera/stuttgart.nix);
person =
(import ./person/team.nix );
frontend = { }; frontend = { };
http = { http = {
@ -263,16 +259,6 @@ in {
# feedreader.urls = [ "http://www.heise.de/security/rss/news-atom.xml" ]; # feedreader.urls = [ "http://www.heise.de/security/rss/news-atom.xml" ];
# we don't use imports because the expressions do not merge in # we don't use imports because the expressions do not merge in
# home-assistant # home-assistant
automation = (import ./automation/bureau-shutdown.nix)
++ (import ./automation/nachtlicht.nix)
++ (import ./automation/schlechteluft.nix)
++ (import ./automation/hass-restart.nix)
++ ten_hours.automation
++ matrix.automation
# ++ standup.automation
++ frosch.automation
++ mittagessen.automation;
device_tracker = (import ./device_tracker/openwrt.nix );
}; };
}; };
} }

View File

@ -1,7 +1,9 @@
# requires `opkg install luci-mod-rpc` on router # requires `opkg install luci-mod-rpc` on router
# see https://www.home-assistant.io/components/luci/ # see https://www.home-assistant.io/components/luci/
[ {
services.home-assistant.config.device_tracker =
[
{ platform = "luci"; { platform = "luci";
host = "192.168.8.1"; host = "192.168.8.1";
username = "root"; username = "root";
@ -13,4 +15,5 @@
hide_if_away = false; hide_if_away = false;
}; };
} }
] ];
}

View File

@ -21,8 +21,10 @@ let
optimistic = false; optimistic = false;
qos = 0; qos = 0;
}; };
in in {
[ services.home-assistant.config.light =
# (tasmota_pwm "RedButton LED" "redbutton" 1 1023) #LED PWM1 [
# (tasmota_pwm "RedButton LED" "redbutton" 1 1023) #LED PWM1
(tasmota_pwm "RedButton Buzzer" "redbutton" 2 512) #buzzer PWM2 (tasmota_pwm "RedButton Buzzer" "redbutton" 2 512) #buzzer PWM2
] ];
}

View File

@ -48,9 +48,11 @@ let
12 # fire pattern 12 # fire pattern
]; ];
}; };
in in {
[ services.home-assistant.config.light =
[
(tasmota_rgb "Status Felix" "status1") (tasmota_rgb "Status Felix" "status1")
(tasmota_rgb "Status Daniel" "status2") (tasmota_rgb "Status Daniel" "status2")
(tasmota_rgb "Buslicht" "buslicht") (tasmota_rgb "Buslicht" "buslicht")
] ];
}

View File

@ -198,6 +198,7 @@ let
]; ];
in in
{ {
services.home-assistant.config = {
timer =lib.fold lib.recursiveUpdate {} timer =lib.fold lib.recursiveUpdate {}
(map tmr_10h persons); (map tmr_10h persons);
automation = (lib.flatten (map automation_10h persons)); automation = (lib.flatten (map automation_10h persons));
@ -205,4 +206,5 @@ in
(map announce_user persons) ++ (map announce_user persons) ++
(map zu_lange_user persons) (map zu_lange_user persons)
); );
};
} }

View File

@ -1,3 +0,0 @@
# Combination Folder
files return a dictionary of different types used in home-assistant instead of
a single thing.

View File

@ -12,7 +12,9 @@ let
((aramark "${menue}/price" "${menue} Preis") // { unit_of_measurement = ""; }) ((aramark "${menue}/price" "${menue} Preis") // { unit_of_measurement = ""; })
]; ];
in in
{ {
services.home-assistant.config =
{
sensor = (aramark_menue "Menü 1") sensor = (aramark_menue "Menü 1")
++ (aramark_menue "Menü 2") ++ (aramark_menue "Menü 2")
++ (aramark_menue "Mercato") ++ (aramark_menue "Mercato")
@ -21,4 +23,5 @@ in
[ [
((aramark "pommes" "Pommes" ) // { payload_on = "True"; payload_off = "False"; }) ((aramark "pommes" "Pommes" ) // { payload_on = "True"; payload_off = "False"; })
]; ];
};
} }

View File

@ -1,4 +1,4 @@
{ lib }: {lib, ... }:
let let
random_daily_text = ''{{ [ random_daily_text = ''{{ [
"Es ist so weit, es ist Standup Zeit!", "Es ist so weit, es ist Standup Zeit!",
@ -9,6 +9,8 @@ let
"Morgens, halb elf in Deutschland - das Standupchen" ] | random }}''; "Morgens, halb elf in Deutschland - das Standupchen" ] | random }}'';
in { in {
services.home-assistant.config =
{
script = script =
{ "random_daily" = { { "random_daily" = {
alias = "Random Daily Introduction"; alias = "Random Daily Introduction";
@ -51,4 +53,5 @@ in {
} }
]; ];
};
} }

View File

@ -1,4 +1,4 @@
{ lib }: {lib, ... }:
# needs: binary_sensor.pommes # needs: binary_sensor.pommes
# notify.matrix_notify # notify.matrix_notify
let let
@ -17,7 +17,10 @@ let
"Der Weltmarktpreis von Pommes ist durch verschiedene Weltkrisen leider so hoch, dass Aramark den Verkaufspreis verdoppeln musste.", "Der Weltmarktpreis von Pommes ist durch verschiedene Weltkrisen leider so hoch, dass Aramark den Verkaufspreis verdoppeln musste.",
"Vorfreude, schönste Freude, Freude bei Aramark. Pommes in die Schale rein, alle Kunden werden glücklich sein.", "Vorfreude, schönste Freude, Freude bei Aramark. Pommes in die Schale rein, alle Kunden werden glücklich sein.",
"In 15 Minuten ist es wieder so weit, es ist Pommes Zeit!"] | random }}''; "In 15 Minuten ist es wieder so weit, es ist Pommes Zeit!"] | random }}'';
in { in
{
services.home-assistant.config =
{
sensor = [ sensor = [
{ platform = "mqtt"; { platform = "mqtt";
name = "frosch brightness"; name = "frosch brightness";
@ -96,4 +99,5 @@ in {
]; ];
}; };
}; };
};
} }

View File

@ -8,7 +8,10 @@
# name: my_command # name: my_command
let let
mom_room = "!kTQjvTQvfVsvfEtmth:thales.citadel.team"; mom_room = "!kTQjvTQvfVsvfEtmth:thales.citadel.team";
in { in
{
services.home-assistant.config =
{
matrix = matrix =
{ {
# secrets: # secrets:
@ -62,4 +65,5 @@ in {
platform = "matrix"; platform = "matrix";
default_room = mom_room; default_room = mom_room;
}]; }];
};
} }

View File

@ -38,7 +38,9 @@ let
"Jetzt nur noch kurz die Mail fertig schreiben und schon kann es los gehen.", "Jetzt nur noch kurz die Mail fertig schreiben und schon kann es los gehen.",
"Es ist 13 Uhr und die Mittagspause ist bald vorbei .... Kleiner Scherz, es ist erst 12:30, aber Ihr hättet auch nicht wirklich etwas verpasst.", "Es ist 13 Uhr und die Mittagspause ist bald vorbei .... Kleiner Scherz, es ist erst 12:30, aber Ihr hättet auch nicht wirklich etwas verpasst.",
"Hallo, es ist nun 12 Uhr 30! Dies entspricht der Essenszeit aller Büroinsassen. Bitte begebt euch zur Aramark Essensausgabe um euren menschlichen Bedürfnissen nachzukommen."] | random }}''; "Hallo, es ist nun 12 Uhr 30! Dies entspricht der Essenszeit aller Büroinsassen. Bitte begebt euch zur Aramark Essensausgabe um euren menschlichen Bedürfnissen nachzukommen."] | random }}'';
in { in
{
services.home-assistant.config = {
automation = [ automation = [
{ alias = "Mittagessen"; { alias = "Mittagessen";
trigger = { trigger = {
@ -86,4 +88,5 @@ in {
]; ];
}; };
}; };
};
} }

View File

@ -1,4 +1,6 @@
[ {
services.home-assistant.config.person =
[
{ name = "Thorsten"; { name = "Thorsten";
id = 1; id = 1;
device_trackers = [ device_trackers = [
@ -69,4 +71,5 @@
"device_tracker.tancrede_laptop" "device_tracker.tancrede_laptop"
]; ];
} }
] ];
}

View File

@ -19,6 +19,8 @@ let
) count); ) count);
}; };
in { in {
services.home-assistant.config.script =
{
buzz_red_led = (flash_entity { buzz_red_led = (flash_entity {
entity = "light.redbutton_buzzer"; entity = "light.redbutton_buzzer";
alias = "Red Button Buzz"; alias = "Red Button Buzz";
@ -54,4 +56,5 @@ in {
delay = 5000; delay = 5000;
count = 1; count = 1;
}); });
};
} }

View File

@ -1,4 +1,6 @@
[ {
services.home-assistant.config.sensor =
[
# coming from 2configs/stats/telegraf/ # coming from 2configs/stats/telegraf/
{ platform = "mqtt"; { platform = "mqtt";
name = "Air Quality"; name = "Air Quality";
@ -6,4 +8,5 @@
value_template = "{{ value_json.fields.value }}"; value_template = "{{ value_json.fields.value }}";
unit_of_measurement = "VOC"; unit_of_measurement = "VOC";
} }
] ];
}

View File

@ -24,8 +24,10 @@ let
payload_available = "Online"; payload_available = "Online";
payload_not_available = "Offline"; payload_not_available = "Offline";
}; };
in in {
(espeasy_dht22 "easy1") ++ services.home-assistant.config.sensor =
(espeasy_dht22 "easy2") ++ [ (espeasy_dht22 "easy1") ++
(espeasy_dht22 "easy2") ++ [
(espeasy_ds18 "easy3" ) (espeasy_ds18 "easy3" )
] ];
}

View File

@ -1,18 +0,0 @@
[
#{ platform = "influxdb";
# queries = [
# { name = "mean value of feinstaub P1";
# where = '' "node" = 'esp8266-1355142' '';
# measurement = "feinstaub";
# database = "telegraf";
# field = "P1";
# }
# { name = "mean value of feinstaub P2";
# where = '' "node" = 'esp8266-1355142' '';
# measurement = "feinstaub";
# database = "telegraf";
# field = "P2";
# }
# ];
#}
]

View File

@ -1,4 +1,7 @@
{lib,...}: [ {lib,...}:
{
services.home-assistant.config.sensor =
[
{ platform = "darksky"; { platform = "darksky";
api_key = lib.removeSuffix "\n" api_key = lib.removeSuffix "\n"
(builtins.readFile <secrets/hass/darksky.apikey>); (builtins.readFile <secrets/hass/darksky.apikey>);
@ -22,4 +25,5 @@
sensorid = "5341"; sensorid = "5341";
monitored_conditions = [ "P1" "P2" ]; monitored_conditions = [ "P1" "P2" ];
} }
] ];
}

View File

@ -9,8 +9,11 @@ let
payload_not_available= "Offline"; payload_not_available= "Offline";
}; };
in in
{
services.home-assistant.config.sensor =
map tasmota_firmware [ map tasmota_firmware [
"plug" "plug2" "plug3" "plug4" "plug5" "plug" "plug2" "plug3" "plug4" "plug5"
"status1" "status2" "buslicht" "status1" "status2" "buslicht"
"rfbridge" "rfbridge"
] ];
}

View File

@ -8,10 +8,12 @@ let
payload_available= "Online"; payload_available= "Online";
payload_not_available= "Offline"; payload_not_available= "Offline";
}; };
in in {
[ services.home-assistant.config.switch =
[
(bridge "Nachtlicht A" "#414551" "#414554") (bridge "Nachtlicht A" "#414551" "#414554")
(bridge "Nachtlicht B" "#415151" "#415154") (bridge "Nachtlicht B" "#415151" "#415154")
(bridge "Nachtlicht C" "#415451" "#415454") (bridge "Nachtlicht C" "#415451" "#415454")
(bridge "Nachtlicht D" "#41551F" "#415514") (bridge "Nachtlicht D" "#41551F" "#415514")
] ];
}

View File

@ -13,10 +13,13 @@ let
retain = false; retain = false;
qos = 1; qos = 1;
}; };
in [ in {
services.home-assistant.config.switch =
[
(tasmota_plug "Bauarbeiterlampe" "plug") (tasmota_plug "Bauarbeiterlampe" "plug")
(tasmota_plug "Blitzdings" "plug2") (tasmota_plug "Blitzdings" "plug2")
(tasmota_plug "Fernseher" "plug3") (tasmota_plug "Fernseher" "plug3")
(tasmota_plug "Feuer" "plug4") (tasmota_plug "Feuer" "plug4")
(tasmota_plug "Blaulicht" "plug5") (tasmota_plug "Blaulicht" "plug5")
] ];
}