summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/deployment
diff options
context:
space:
mode:
Diffstat (limited to 'makefu/2configs/deployment')
-rw-r--r--makefu/2configs/deployment/bgt/hidden_service.nix48
-rw-r--r--makefu/2configs/deployment/bureautomation/default.nix41
-rw-r--r--makefu/2configs/deployment/bureautomation/hass.nix240
-rw-r--r--makefu/2configs/deployment/bureautomation/mpd.nix9
-rw-r--r--makefu/2configs/deployment/google-muell.nix37
-rw-r--r--makefu/2configs/deployment/homeautomation/default.nix260
-rw-r--r--makefu/2configs/deployment/homeautomation/mqtt.nix24
7 files changed, 0 insertions, 659 deletions
diff --git a/makefu/2configs/deployment/bgt/hidden_service.nix b/makefu/2configs/deployment/bgt/hidden_service.nix
deleted file mode 100644
index c1a31b8dc..000000000
--- a/makefu/2configs/deployment/bgt/hidden_service.nix
+++ /dev/null
@@ -1,48 +0,0 @@
-{ pkgs, lib, ... }:
-
-with lib;
-let
- name = "bgt_cyberwar_hidden_service";
- sec = (toString <secrets>) + "/";
- secdir = sec + name;
- srvdir = "/var/lib/tor/onion/";
- basedir = srvdir + name;
- hn = builtins.readFile (secdir + "/hostname");
-in
-{
- systemd.services.prepare-hidden-service = {
- wantedBy = [ "local-fs.target" ];
- before = [ "tor.service" ];
- serviceConfig = {
- ExecStart = pkgs.writeScript "prepare-euer-blog-service" ''
- #!/bin/sh
- set -euf
- if ! test -d "${basedir}" ;then
- mkdir -p "${srvdir}"
- cp -r "${secdir}" "${srvdir}"
- chown -R tor:tor "${srvdir}"
- chmod -R 700 "${basedir}"
- else
- echo "not overwriting ${basedir}"
- fi
- '';
- Type = "oneshot";
- RemainAfterExit = "yes";
- TimeoutSec = "0";
- };
- };
- services.nginx.virtualHosts."${hn}".locations."/" = {
- proxyPass = "https://blog.binaergewitter.de";
- extraConfig = ''
- proxy_set_header Host blog.binaergewitter.de;
- proxy_ssl_server_name on;
- '';
- };
- services.tor = {
- enable = true;
- hiddenServices."${name}".map = [
- { port = "80"; }
- # { port = "443"; toHost = "blog.binaergewitter.de"; }
- ];
- };
-}
diff --git a/makefu/2configs/deployment/bureautomation/default.nix b/makefu/2configs/deployment/bureautomation/default.nix
deleted file mode 100644
index 3897537ea..000000000
--- a/makefu/2configs/deployment/bureautomation/default.nix
+++ /dev/null
@@ -1,41 +0,0 @@
-{ pkgs, lib, ... }:
-
-with lib;
-let
- port = 3001;
- runit = pkgs.writeDash "runit" ''
- set -xeuf
- PATH=${pkgs.curl}/bin:${pkgs.coreutils}/bin
- name=''${1?must provide name as first arg}
- state=''${2?must provide state as second arg}
- # val=''${3?must provide val as third arg}
-
- # we ignore non-alerting events
- test $state = alerting || exit 0
-
- echo $name - $state
- curl 'http://bauarbeiterlampe/ay?o=1'
- sleep 5
- curl 'http://bauarbeiterlampe/ay?o=1'
- '';
-in {
- services.logstash = {
- package = pkgs.logstash5;
- enable = true;
- inputConfig = ''
- http {
- port => ${toString port}
- host => "127.0.0.1"
- }
- '';
- filterConfig = ''
- '';
- outputConfig = ''
- stdout { codec => json }
- exec { command => "${runit} '%{ruleName}' '%{state}'" }
- '';
- extraSettings = ''
- path.plugins: [ "${pkgs.logstash-output-exec}" ]
- '';
- };
-}
diff --git a/makefu/2configs/deployment/bureautomation/hass.nix b/makefu/2configs/deployment/bureautomation/hass.nix
deleted file mode 100644
index 443484a34..000000000
--- a/makefu/2configs/deployment/bureautomation/hass.nix
+++ /dev/null
@@ -1,240 +0,0 @@
-{ pkgs, lib, ... }:
-let
- tasmota_plug = name: topic:
- { platform = "mqtt";
- inherit name;
- state_topic = "/bam/${topic}/stat/POWER1";
- command_topic = "/bam/${topic}/cmnd/POWER1";
- availability_topic = "/bam/${topic}/tele/LWT";
- payload_on= "ON";
- payload_off= "OFF";
- payload_available= "Online";
- payload_not_available= "Offline";
- };
- tasmota_stecki = name: topic:
- ( tasmota_plug name topic) //
- { state_topic = "/bam/${topic}/stat/POWER";
- command_topic = "/bam/${topic}/cmnd/POWER";
- };
- espeasy_dht22 = name: [
- { platform = "mqtt";
- name = "${name} DHT22 Temperature";
- device_class = "temperature";
- state_topic = "/bam/${name}/dht22/Temperature";
- availability_topic = "/bam/${name}/tele/LWT";
- payload_available = "Online";
- payload_not_available = "Offline";
- }
- { platform = "mqtt";
- device_class = "humidity";
- name = "${name} DHT22 Humidity";
- state_topic = "/bam/${name}/dht22/Humidity";
- availability_topic = "/bam/${name}/tele/LWT";
- payload_available = "Online";
- payload_not_available = "Offline";
- }];
- espeasy_ds18 = name:
- { platform = "mqtt";
- name = "${name} DS18 Temperature";
- state_topic = "/bam/${name}/ds18/Temperature";
- availability_topic = "/bam/${name}/tele/LWT";
- payload_available = "Online";
- payload_not_available = "Offline";
- };
-in {
- networking.firewall.allowedTCPPorts = [ 8123 ];
-
- services.home-assistant = {
- enable = true;
- config = {
- homeassistant = {
- name = "Bureautomation";
- time_zone = "Europe/Berlin";
- latitude = "48.8265";
- longitude = "9.0676";
- elevation = 303;
- };
-
- mqtt = {
- broker = "localhost";
- port = 1883;
- client_id = "home-assistant";
- keepalive = 60;
- protocol = 3.1;
- birth_message = {
- topic = "/bam/hass/tele/LWT";
- payload = "Online";
- qos = 1;
- retain = true;
- };
- will_message = {
- topic = "/bam/hass/tele/LWT";
- payload = "Offline";
- qos = 1;
- retain = true;
- };
- };
- switch = [
- (tasmota_plug "Bauarbeiterlampe" "plug")
- (tasmota_plug "Blitzdings" "plug2")
- (tasmota_stecki "Fernseher" "fernseher")
- (tasmota_plug "Pluggy" "plug4")
- ];
- binary_sensor = [
- { platform = "mqtt";
- device_class = "motion";
- name = "Motion";
- state_topic = "/bam/easy2/movement/Switch";
- payload_on = "1";
- payload_off = "0";
- availability_topic = "/bam/easy2/tele/LWT";
- payload_available = "Online";
- payload_not_available = "Offline";
- }
- ];
- sensor =
- (espeasy_dht22 "easy1") ++
- (espeasy_dht22 "easy2") ++
- [ (espeasy_ds18 "easy3" )
- { platform = "luftdaten";
- name = "Ditzingen";
- sensorid = "5341";
- monitored_conditions = [ "P1" "P2" ];
- }
-
- { platform = "darksky";
- api_key = lib.removeSuffix "\n"
- (builtins.readFile <secrets/hass/darksky.apikey>);
- language = "de";
- monitored_conditions = [ "summary" "icon"
- "nearest_storm_distance" "precip_probability"
- "precip_intensity"
- "temperature" # "temperature_high" "temperature_low"
- "apparent_temperature"
- "hourly_summary" # next 24 hours text
- "minutely_summary"
- "humidity"
- "pressure"
- "uv_index" ];
- units = "si" ;
- update_interval = {
- days = 0;
- hours = 0;
- minutes = 30;
- seconds = 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";
- # }
- # ];
- #}
- ];
- camera = [
- { name = "Baumarkt";
- platform = "generic";
- still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt
- }
- { name = "Autobahn Heilbronn";
- platform = "generic";
- still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K10 ;
- }
- { name = "Autobahn Singen";
- platform = "generic";
- still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ;
- }
- ];
- frontend = { };
- http = { };
- conversation = {};
- history = {};
- logbook = {};
- tts = [ { platform = "google";} ];
- recorder = {};
- group =
- { default_view =
- { view = "yes";
- entities = [
- "group.sensors"
- "group.outside"
- "group.switches"
- "group.automation"
- "group.camera"
- ];
- };
- automation = [
- "automation.turn_off_fernseher_10_minutes_after_last_movement"
- ];
- switches = [
- "switch.bauarbeiterlampe"
- "switch.blitzdings"
- "switch.fernseher"
- "switch.pluggy"
- ];
- camera = [
- "camera.Baumarkt"
- "camera.Autobahn_Heilbronn"
- "camera.Autobahn_Singen"
- ];
- sensors = [
- "binary_sensor.motion"
- "sensor.easy2_dht22_humidity"
- "sensor.easy2_dht22_temperature"
- ];
- outside = [
- "sensor.ditzingen_pm10"
- "sensor.ditzingen_pm25"
- "sensor.dark_sky_temperature"
- "sensor.dark_sky_humidity"
- "sensor.dark_sky_pressure"
- "sensor.dark_sky_hourly_summary"
- "sensor.dark_sky_minutely_summary"
- ];
- };
- # only for automation
- # feedreader.urls = [ "http://www.heise.de/security/rss/news-atom.xml" ];
- automation = [
- { alias = "Turn on Fernseher on movement";
- trigger = {
- platform = "state";
- entity_id = "binary_sensor.motion";
- to = "on";
- };
- action = {
- service= "homeassistant.turn_on";
- entity_id= "switch.fernseher";
- };
- }
- { alias = "Turn off Fernseher 10 minutes after last movement";
- trigger = {
- platform = "state";
- entity_id = "binary_sensor.motion";
- to = "off";
- for.minutes = 10;
- };
- action = {
- service= "homeassistant.turn_off";
- entity_id= "switch.fernseher";
- };
- condition = [{
- condition = "time";
- before = "06:30:00"; #only turn off between 6:30 and 18:00
- after = "18:00:00";
- weekday = [ "mon" "tue" "wed" "thu" "fri" ];
- }];
- }
- ];
- };
- };
-}
diff --git a/makefu/2configs/deployment/bureautomation/mpd.nix b/makefu/2configs/deployment/bureautomation/mpd.nix
deleted file mode 100644
index 1f5acb357..000000000
--- a/makefu/2configs/deployment/bureautomation/mpd.nix
+++ /dev/null
@@ -1,9 +0,0 @@
-{lib,pkgs, ... }:
-
-{
- systemd.services."ympd-wbob" = {
- description = "mpd ";
- wantedBy = [ "multi-user.target" ];
- serviceConfig.ExecStart = "${pkgs.ympd}/bin/ympd --host localhost --port 6600 --webport 8866 --user nobody";
- };
-}
diff --git a/makefu/2configs/deployment/google-muell.nix b/makefu/2configs/deployment/google-muell.nix
deleted file mode 100644
index 235cc1546..000000000
--- a/makefu/2configs/deployment/google-muell.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-{ config, lib, pkgs, buildPythonPackage, ... }:
-with import <stockholm/lib>;
-let
- pkg = pkgs.ampel;
- home = "/var/lib/ampel";
- sec = "${toString <secrets>}/google-muell.json";
- ampelsec = "${home}/google-muell.json";
- cred = "${toString <secrets>}/google-muell-creds.json";
- # TODO: generate this credential file locally
- ampelcred = "${home}/google-muell-creds.json";
- esp = "192.168.8.204";
- sleepval = "1800";
-in {
- users.users.ampel = {
- uid = genid "ampel";
- createHome = true;
- isSystemUser = true;
- inherit home;
- };
- systemd.services.google-muell-ampel = {
- description = "Send led change to rgb cubes";
- after = [ "network-online.target" ];
- wantedBy = [ "multi-user.target" ];
- serviceConfig = {
- User = "ampel";
- ExecStartPre = pkgs.writeDash "copy-ampel-secrets" ''
- install -m600 -o ampel ${sec} ${ampelsec}
- install -m600 -o ampel ${cred} ${ampelcred}
- '';
- ExecStart = "${pkg}/bin/google-muell --esp=${esp} --client-secrets=${ampelsec} --credential-path=${ampelcred} --sleepval=${sleepval}";
- PermissionsStartOnly = true;
- Restart = "always";
- RestartSec = 10;
- PrivateTmp = true;
- };
- };
-}
diff --git a/makefu/2configs/deployment/homeautomation/default.nix b/makefu/2configs/deployment/homeautomation/default.nix
deleted file mode 100644
index 94799b11d..000000000
--- a/makefu/2configs/deployment/homeautomation/default.nix
+++ /dev/null
@@ -1,260 +0,0 @@
-{ pkgs, lib, config, ... }:
-
-# Ideas:
-## wake-on-lan server
-##
-let
- tasmota_rgb = name: topic:
-# LED WS2812b
-# effect_state_topic: "stat/led/Scheme"
-# effect_command_topic: "cmnd/led/Scheme"
-# effect_value_template: "{{ value_json.Scheme }}"
- { platform = "mqtt";
- inherit name;
- retain = false;
- qos = 1;
- optimistic = false;
- # state
- # TODO: currently broken, will not use the custom state topic
- #state_topic = "/ham/${topic}/stat/POWER";
- state_topic = "/ham/${topic}/stat/POWER";
- command_topic = "/ham/${topic}/cmnd/POWER";
- availability_topic = "/ham/${topic}/tele/LWT";
- payload_on= "ON";
- payload_off= "OFF";
- payload_available= "Online";
- payload_not_available= "Offline";
- # brightness
- brightness_state_topic = "/ham/${topic}/stat/Dimmer";
- brightness_command_topic = "/ham/${topic}/cmnd/Dimmer";
- brightness_value_template = "{{ value_json.Dimmer }}";
- brightness_scale = 100;
- # color
- rgb_state_topic = "/ham/${topic}/stat/Color";
- rgb_command_topic = "/ham/${topic}/cmnd/Color2";
- rgb_command_mode = "hex";
- rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}";
- # effects
- effect_state_topic = "/ham/${topic}/stat/Scheme";
- effect_command_topic = "/ham/${topic}/cmnd/Scheme";
- effect_value_template = "{{ value_json.Scheme }}";
- effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ];
-};
- # switchmode 1 - also toggle power
- # switchtopic flurlicht
- tasmota_motion = name: topic:
- { platform = "mqtt";
- device_class = "motion";
- inherit name;
- # TODO: currently broken, will not use the custom state topic
- state_topic = "/ham/${topic}/stat/POWER";
- payload_on = "ON";
- payload_off = "OFF";
- availability_topic = "/ham/${topic}/tele/LWT";
- payload_available = "Online";
- payload_not_available = "Offline";
- };
-
- firetv = "192.168.1.238";
- tasmota_plug = name: topic:
- { platform = "mqtt";
- inherit name;
- state_topic = "/ham/${topic}/stat/POWER1";
- command_topic = "/ham/${topic}/cmnd/POWER1";
- availability_topic = "/ham/${topic}/tele/LWT";
- payload_on= "ON";
- payload_off= "OFF";
- payload_available= "Online";
- payload_not_available= "Offline";
- };
- tasmota_bme = name: topic:
- [ { platform = "mqtt";
- name = "${name} Temperatur";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.BME280.Temperature }}";
- unit_of_measurement = "°C";
- }
- { platform = "mqtt";
- name = "${name} Luftfeuchtigkeit";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.BME280.Humidity }}";
- unit_of_measurement = "%";
- }
- { platform = "mqtt";
- name = "${name} Luftdruck";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.BME280.Pressure }}";
- unit_of_measurement = "hPa";
- }
- ];
- tasmota_am2301 = name: topic:
- [ { platform = "mqtt";
- name = "${name} Temperatur";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.AM2301.Temperature }}";
- unit_of_measurement = "°C";
- }
- { platform = "mqtt";
- name = "${name} Luftfeuchtigkeit";
- state_topic = "/ham/${topic}/tele/SENSOR";
- value_template = "{{ value_json.AM2301.Humidity }}";
- unit_of_measurement = "%";
- }
- ];
-in {
- imports = [
- ./mqtt.nix
- ];
- #systemd.services.firetv = {
- # wantedBy = [ "multi-user.target" ];
- # serviceConfig = {
- # User = "nobody";
- # ExecStart = "${pkgs.python-firetv}/bin/firetv-server -d ${firetv}:5555";
- # };
- #};
- services.home-assistant = {
- config = {
- homeassistant = {
- name = "Home"; time_zone = "Europe/Berlin";
- latitude = "48.7687";
- longitude = "9.2478";
- elevation = 247;
- };
- #discovery = {};
- conversation = {};
- history = {};
- logbook = {};
- tts = [
- { platform = "google";}
- ];
- sun.elevation = 247;
- recorder = {};
- media_player = [
- { platform = "kodi";
- host = firetv;
- }
- #{ platform = "firetv";
- # # assumes python-firetv running
- #}
- ];
- mqtt = {
- broker = "localhost";
- port = 1883;
- client_id = "home-assistant";
- username = "hass";
- password = lib.removeSuffix "\n" (builtins.readFile <secrets/mqtt/hass>);
- keepalive = 60;
- protocol = 3.1;
- birth_message = {
- topic = "/ham/hass/tele/LWT";
- payload = "Online";
- qos = 1;
- retain = true;
- };
- will_message = {
- topic = "/ham/hass/tele/LWT";
- payload = "Offline";
- qos = 1;
- retain = true;
- };
- };
- binary_sensor = [
- (tasmota_motion "Flur Bewegung" "flurlicht")
- ];
- sensor = [
- # broken
- #{ platform = "speedtest";
- # monitored_conditions = [ "ping" "download" "upload" ];
- #}
- { platform = "luftdaten";
- name = "Wangen";
- sensorid = "663";
- monitored_conditions = [ "P1" "P2" ];
- }
- # https://www.home-assistant.io/cookbook/automation_for_rainy_days/
- { platform = "darksky";
- api_key = lib.removeSuffix "\n"
- (builtins.readFile <secrets/hass/darksky.apikey>);
- language = "de";
- monitored_conditions = [ "summary" "icon"
- "nearest_storm_distance" "precip_probability"
- "precip_intensity"
- "temperature"
- "apparent_temperature"
- "hourly_summary"
- "humidity"
- "pressure"
- "uv_index" ];
- units = "si" ;
- update_interval = {
- days = 0;
- hours = 0;
- minutes = 30;
- seconds = 0;
- };
- }
- ]
- ++ (tasmota_bme "Schlafzimmer" "schlafzimmer")
- ++ (tasmota_am2301 "Arbeitszimmer" "arbeitszimmer");
- frontend = { };
- group =
- { default_view =
- { view = "yes";
- entities = [
- "group.flur"
- "group.schlafzimmer"
- "group.draussen"
- "group.wohnzimmer"
- "group.arbeitszimmer"
- ];
- };
- flur = [
- "light.flurlicht"
- "binary_sensor.flur_bewegung"
- ];
- wohnzimmer = [
- "media_player.kodi"
- ];
- draussen = [
- "sensor.dark_sky_temperature"
- "sensor.dark_sky_hourly_summary"
- "sensor.wangen_pm10"
- "sensor.wangen_pm25"
- ];
- schlafzimmer = [
- "sensor.schlafzimmer_temperatur"
- "sensor.schlafzimmer_luftdruck"
- "sensor.schlafzimmer_luftfeuchtigkeit"
- "switch.lichterkette_schlafzimmer"
- ];
- arbeitszimmer = [
- "switch.strom_staubsauger"
- "sensor.arbeitszimmer_temperatur"
- "sensor.arbeitszimmer_luftfeuchtigkeit"
- ];
- };
- http = { };
- switch = [
- (tasmota_plug "Lichterkette Schlafzimmer" "schlafzimmer")
- (tasmota_plug "Strom Staubsauger" "arbeitszimmer")
- ];
- light = [ (tasmota_rgb "Flurlicht" "flurlicht" ) ];
- automation = [
- { alias = "Staubsauger Strom aus nach 6h";
- trigger = {
- platform = "state";
- entity_id = "switch.strom_staubsauger";
- to = "on";
- for.hours = 6;
- };
- action = {
- service= "homeassistant.turn_off";
- entity_id= "switch.strom_staubsauger";
- };
- }
- ];
- };
- enable = true;
- #configDir = "/var/lib/hass";
- };
-}
diff --git a/makefu/2configs/deployment/homeautomation/mqtt.nix b/makefu/2configs/deployment/homeautomation/mqtt.nix
deleted file mode 100644
index cd1c328d7..000000000
--- a/makefu/2configs/deployment/homeautomation/mqtt.nix
+++ /dev/null
@@ -1,24 +0,0 @@
-{ pkgs, config, ... }:
-{
- services.mosquitto = {
- enable = true;
- host = "0.0.0.0";
- allowAnonymous = false;
- checkPasswords = true;
- # see <host>/mosquitto
- users.sensor = {
- hashedPassword = "$6$2DXU7W1bvqXPqxkF$vtdz5KTd/T09hmoc9LjgEGFjvpwQbQth6vlVcr5hJNLgcBHv4U03YCKC8TKXbmQAa8xiJ76xJIg25kcL+KI3tg==";
- acl = [ "topic readwrite #" ];
- };
- users.hass = {
- hashedPassword = "$6$SHuYGrE5kPSUc/hu$EomZ0KBy+vkxLt/6eJkrSBjYblCCeMjhDfUd2mwqXYJ4XsP8hGmZ59mMlmBCd3AvlFYQxb4DT/j3TYlrqo7cDA==";
- acl = [ "topic readwrite #" ];
- };
- users.stats = {
- hashedPassword = "$6$j4H7KXD/YZgvgNmL$8e9sUKRXowDqJLOVgzCdDrvDE3+4dGgU6AngfAeN/rleGOgaMhee2Mbg2KS5TC1TOW3tYbk9NhjLYtjBgfRkoA==";
- acl = [ "topic read #" ];
- };
- };
- environment.systemPackages = [ pkgs.mosquitto ];
- # port open via trusted interface
-}