Merge remote-tracking branch 'gum/master'

This commit is contained in:
lassulus 2020-08-06 23:22:35 +02:00
commit 04d9ff2dcd
8 changed files with 151 additions and 48 deletions

View File

@ -16,6 +16,7 @@
<stockholm/krebs/2configs/shack/ssh-keys.nix> <stockholm/krebs/2configs/shack/ssh-keys.nix>
<stockholm/krebs/2configs/shack/prometheus/node.nix> <stockholm/krebs/2configs/shack/prometheus/node.nix>
<stockholm/krebs/2configs/shack/prometheus/server.nix> <stockholm/krebs/2configs/shack/prometheus/server.nix>
<stockholm/krebs/2configs/shack/prometheus/blackbox.nix>
<stockholm/krebs/2configs/shack/prometheus/unifi.nix> <stockholm/krebs/2configs/shack/prometheus/unifi.nix>
<stockholm/krebs/2configs/shack/gitlab-runner.nix> <stockholm/krebs/2configs/shack/gitlab-runner.nix>

View File

@ -0,0 +1,29 @@
# Needs:
# sun.sunset
# switch.lounge_diskoschalter_relay
let
glados = import ../lib;
disko_schalter = "switch.lounge_diskoschalter_relay";
player = "media_player.lounge";
in
[
{ alias = "Party um 21 Uhr";
trigger = {
platform = "sun";
event = "sunset";
};
action =
( glados.say.kiosk "Die Sonne geht unter. Und jetzt geht die Party im shack erst richtig los. Partybeleuchtung, aktiviert!" )
++
[
{
service = "homeassistant.turn_on";
entity_id = disko_schalter;
}
{
service = "media_player.turn_on";
data.entity_id = player;
} # TODO: also start playlist if nothing is running?
];
}
]

View File

@ -29,8 +29,7 @@ in {
}; };
in { in {
enable = true; enable = true;
package = (pkgs.home-assistant.overrideAttrs (old: { package = (pkgs.home-assistant.overrideAttrs (old: { # TODO: find correct python package
# TODO: find correct python package
installCheckPhase = '' installCheckPhase = ''
echo LOLLLLLLLLLLLLLL echo LOLLLLLLLLLLLLLL
''; '';
@ -70,6 +69,8 @@ in {
# source = "hass"; # source = "hass";
# }; # };
#}; #};
esphome = {};
api = {};
mqtt = { mqtt = {
broker = "localhost"; broker = "localhost";
port = 1883; port = 1883;
@ -130,11 +131,9 @@ in {
trusted_proxies = "127.0.0.1"; trusted_proxies = "127.0.0.1";
}; };
#conversation = {}; #conversation = {};
history = {}; # history = {};
#logbook = {}; #logbook = {};
logger = { logger.default = "info";
default = "info";
};
#recorder = {}; #recorder = {};
tts = [ tts = [
{ platform = "google_translate"; { platform = "google_translate";
@ -143,16 +142,13 @@ in {
cache = true; cache = true;
time_memory = 57600; time_memory = 57600;
} }
{ platform = "picotts";
language = "de-DE";
service_name = "pico";
}
]; ];
sun = {}; sun = {};
automation = wasser.automation automation = wasser.automation
++ badair.automation ++ badair.automation
++ (import ./automation/shack-startup.nix) ++ (import ./automation/shack-startup.nix)
++ (import ./automation/party-time.nix)
++ (import ./automation/hass-restart.nix); ++ (import ./automation/hass-restart.nix);
device_tracker = []; device_tracker = [];

View File

@ -1,5 +1,7 @@
let let
glados = import ../lib; glados = import ../lib;
feinstaub_sensor = "sensor.fablab_particulate_matter_2_5um_concentration";
ledring = "light.fablab_led_ring";
in in
{ {
automation = automation =
@ -8,15 +10,15 @@ in
trigger = [ trigger = [
{ {
platform = "numeric_state"; platform = "numeric_state";
below = 25; entity_id = feinstaub_sensor;
entity_id = "sensor.fablab_feinstaub_2_5um"; below = 3;
} }
]; ];
action = action =
[ [
{ service = "light.turn_on"; { service = "light.turn_on";
data = { data = {
entity_id = "light.fablab_led"; entity_id = ledring;
effect = "Twinkle"; effect = "Twinkle";
color_name = "green"; color_name = "green";
}; };
@ -25,23 +27,18 @@ in
} }
{ alias = "mäßige Luft Fablab"; { alias = "mäßige Luft Fablab";
trigger = [ trigger = [
#{
# platform = "numeric_state";
# above = 25;
# entity_id = "sensor.fablab_feinstaub_25m";
#}
{ {
platform = "numeric_state"; platform = "numeric_state";
above = 25; above = 3;
below = 50; below = 10;
entity_id = "sensor.fablab_feinstaub_2_5um"; entity_id = feinstaub_sensor;
} }
]; ];
action = action =
[ [
{ service = "light.turn_on"; { service = "light.turn_on";
data = { data = {
entity_id = "light.fablab_led"; entity_id = ledring;
effect = "Twinkle"; effect = "Twinkle";
color_name = "yellow"; color_name = "yellow";
}; };
@ -52,16 +49,16 @@ in
trigger = [ trigger = [
{ {
platform = "numeric_state"; platform = "numeric_state";
above = 50; above = 10;
entity_id = "sensor.fablab_feinstaub_2_5um"; entity_id = feinstaub_sensor;
} }
]; ];
action = action =
[ [
{ service = "light.turn_on"; { service = "light.turn_on";
data = { data = {
entity_id = "light.fablab_led"; entity_id = ledring;
effect = "Twinkle"; effect = "Fireworks";
color_name = "red"; color_name = "red";
}; };
} }
@ -72,14 +69,14 @@ in
{ {
platform = "state"; platform = "state";
to = "unavailable"; to = "unavailable";
entity_id = "sensor.fablab_feinstaub_2_5um"; entity_id = feinstaub_sensor;
} }
]; ];
action = action =
[ [
{ service = "light.turn_on"; { service = "light.turn_on";
data = { data = {
entity_id = "light.fablab_led"; entity_id = ledring;
effect = "Rainbow"; effect = "Rainbow";
color_name = "blue"; color_name = "blue";
}; };
@ -91,14 +88,14 @@ in
{ {
platform = "state"; platform = "state";
from = "unavailable"; from = "unavailable";
entity_id = "light.fablab_led"; entity_id = ledring;
} }
]; ];
action = action =
[ [
{ service = "light.turn_on"; { service = "light.turn_on";
data = { data = {
entity_id = "light.fablab_led"; entity_id = ledring;
effect = "Rainbow"; effect = "Rainbow";
color_name = "orange"; color_name = "orange";
}; };

View File

@ -1,6 +1,9 @@
# uses:
# switch.crafting_giesskanne_relay
let let
glados = import ../lib; glados = import ../lib;
seconds = 20; seconds = 5;
wasser = "switch.crafting_giesskanne_relay";
in in
{ {
switch = [ switch = [
@ -22,14 +25,14 @@ in
{ {
service = "homeassistant.turn_on"; service = "homeassistant.turn_on";
entity_id = [ entity_id = [
"switch.wasser" wasser
]; ];
} }
{ delay.seconds = seconds; } { delay.seconds = seconds; }
{ {
service = "homeassistant.turn_off"; service = "homeassistant.turn_off";
entity_id = [ entity_id = [
"switch.wasser" wasser
]; ];
} }
]; ];
@ -38,7 +41,7 @@ in
trigger = [ trigger = [
{ {
platform = "state"; platform = "state";
entity_id = "switch.wasser"; entity_id = wasser;
to = "on"; to = "on";
for.seconds = seconds*2; for.seconds = seconds*2;
} }
@ -47,7 +50,7 @@ in
[ [
{ {
service = "homeassistant.turn_off"; service = "homeassistant.turn_off";
entity_id = [ "switch.wasser" ]; entity_id = [ wasser ];
} }
]; ];
} }

View File

@ -0,0 +1,19 @@
{pkgs, ... }:
{
systemd.services.prometheus-blackbox-exporter.serviceConfig = {
CapabilityBoundingSet = ["CAP_NET_RAW"]; # icmp allow
AmbientCapabilities = ["CAP_NET_RAW"];
};
services.prometheus.exporters.blackbox = {
enable = true;
# openFirewall = true; # not requred if running on the same host as prometheus
port = 9115;
configFile = pkgs.writeText "icmp" ''
modules:
icmp:
prober: icmp
icmp:
preferred_ip_protocol: ip4
'';
};
}

View File

@ -18,16 +18,6 @@
}; };
prometheus = { prometheus = {
enable = true; enable = true;
extraFlags = [
"-storage.local.retention 720h"
"-storage.local.series-file-shrink-ratio 0.3"
"-storage.local.memory-chunks 2097152"
"-storage.local.max-chunks-to-persist 1048576"
"-storage.local.index-cache-size.fingerprint-to-metric 2097152"
"-storage.local.index-cache-size.fingerprint-to-timerange 1048576"
"-storage.local.index-cache-size.label-name-to-label-values 2097152"
"-storage.local.index-cache-size.label-pair-to-fingerprints 41943040"
];
ruleFiles = lib.singleton (pkgs.writeText "prometheus-rules.yml" (builtins.toJSON { ruleFiles = lib.singleton (pkgs.writeText "prometheus-rules.yml" (builtins.toJSON {
groups = lib.singleton { groups = lib.singleton {
name = "mf-alerting-rules"; name = "mf-alerting-rules";
@ -41,7 +31,7 @@
static_configs = [ static_configs = [
{ {
targets = [ targets = [
"localhost:9100" "wolf.shack:9100"
]; ];
labels = { labels = {
alias = "wolf.shack"; alias = "wolf.shack";
@ -49,7 +39,15 @@
} }
{ {
targets = [ targets = [
"localhost:9130" "infra01.shack:9100"
];
labels = {
alias = "infra01.shack";
};
}
{
targets = [
"unifi.shack:9130"
]; ];
labels = { labels = {
alias = "unifi.shack"; alias = "unifi.shack";
@ -57,7 +55,7 @@
} }
{ {
targets = [ targets = [
"10.42.22.184:9100" # puyak.shack "puyak.shack:9100" # puyak.shack
]; ];
labels = { labels = {
alias = "puyak.shack"; alias = "puyak.shack";
@ -81,6 +79,36 @@
} }
]; ];
} }
{
job_name = "blackbox";
metrics_path = "/probe";
params.module = [ "icmp" ];
static_configs = [
{
targets = [
"google.com"
"wolf.shack"
"web.de"
"10.0.0.1"
"licht.shack"
];
}
];
relabel_configs = [
{
source_labels = ["__address__"];
target_label = "__param_target";
}
{
source_labels = ["__param_target"];
target_label = "instance";
}
{
target_label = "__address__";
replacement = "127.0.0.1:9115";
}
];
}
]; ];
alertmanagers = [ alertmanagers = [
{ scheme = "http"; { scheme = "http";

View File

@ -0,0 +1,30 @@
{ coreutils, fetchFromGitHub, makeWrapper, xdotool, stdenv, ... }:
stdenv.mkDerivation rec {
name = "chapter-marker-${version}";
version = "master";
src = fetchFromGitHub {
owner = "makefu";
repo = "chapter-marker";
rev = "7602b611fb3d67fdb8a86db23220074dfa9dfa1e";
sha256 = "0cwh650c3qhdrcvrqfzgrwpsnj4lbq64fw2sfwvnbxz94b4q36av";
};
buildInputs = [ makeWrapper ];
installPhase =
let
path = stdenv.lib.makeBinPath [
coreutils
xdotool
];
in
''
mkdir -p $out/bin
cp chapter-mark chapter-start $out/bin/
wrapProgram $out/bin/chapter-mark \
--prefix PATH : ${path}
wrapProgram $out/bin/chapter-start \
--prefix PATH : ${path}
'';
}