summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/shack/glados
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/2configs/shack/glados')
-rw-r--r--krebs/2configs/shack/glados/automation/hass-restart.nix20
-rw-r--r--krebs/2configs/shack/glados/default.nix19
-rw-r--r--krebs/2configs/shack/glados/lib/default.nix107
-rw-r--r--krebs/2configs/shack/glados/multi/schlechte_luft.nix123
-rw-r--r--krebs/2configs/shack/glados/multi/wasser.nix17
-rw-r--r--krebs/2configs/shack/glados/sensors/hass.nix23
6 files changed, 268 insertions, 41 deletions
diff --git a/krebs/2configs/shack/glados/automation/hass-restart.nix b/krebs/2configs/shack/glados/automation/hass-restart.nix
new file mode 100644
index 000000000..e87354978
--- /dev/null
+++ b/krebs/2configs/shack/glados/automation/hass-restart.nix
@@ -0,0 +1,20 @@
+# needs:
+# light.fablab_led
+[
+ { alias = "State on HA start-up";
+ trigger = {
+ platform = "homeassistant";
+ event = "start";
+ };
+ action = [
+ { service = "light.turn_on";
+ data = {
+ entity_id = "light.fablab_led";
+ effect = "Rainbow";
+ color_name = "yellow";
+ };
+ }
+ ];
+ }
+]
+
diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix
index d000af397..e48a54551 100644
--- a/krebs/2configs/shack/glados/default.nix
+++ b/krebs/2configs/shack/glados/default.nix
@@ -2,6 +2,7 @@
let
shackopen = import ./multi/shackopen.nix;
wasser = import ./multi/wasser.nix;
+ badair = import ./multi/schlechte_luft.nix;
in {
services.nginx.virtualHosts."hass.shack" = {
serverAliases = [ "glados.shack" ];
@@ -44,7 +45,7 @@ in {
autoExtraComponents = true;
config = {
homeassistant = {
- name = "Bureautomation";
+ name = "Glados";
time_zone = "Europe/Berlin";
latitude = "48.8265";
longitude = "9.0676";
@@ -89,7 +90,7 @@ in {
};
};
switch = wasser.switch;
- light = [];
+ light = badair.light;
media_player = [
{ platform = "mpd";
host = "lounge.mpd.shack";
@@ -99,7 +100,8 @@ in {
sensor =
(import ./sensors/hass.nix)
++ (import ./sensors/power.nix)
- ++ shackopen.sensor;
+ ++ shackopen.sensor
+ ++ badair.sensor;
binary_sensor = shackopen.binary_sensor;
@@ -113,8 +115,9 @@ in {
trusted_proxies = "127.0.0.1";
};
#conversation = {};
- #history = {};
- #logbook = {};
+ history = {};
+ logbook = {};
+ recorder = {};
tts = [
{ platform = "google_translate";
language = "de";
@@ -123,10 +126,12 @@ in {
# language = "de-DE";
#}
];
- #recorder = {};
sun = {};
- automation = wasser.automation;
+ automation = wasser.automation
+ ++ badair.automation
+ ++ (import ./automation/hass-restart.nix);
+
device_tracker = [];
};
};
diff --git a/krebs/2configs/shack/glados/lib/default.nix b/krebs/2configs/shack/glados/lib/default.nix
new file mode 100644
index 000000000..6737af842
--- /dev/null
+++ b/krebs/2configs/shack/glados/lib/default.nix
@@ -0,0 +1,107 @@
+let
+ prefix = "glados";
+in
+{
+ esphome =
+ {
+ temp = {host, topic ? "temperature" }:
+ {
+ platform = "mqtt";
+ name = "${host} Temperature";
+ device_class = "temperature";
+ unit_of_measurement = "°C";
+ icon = "mdi:thermometer";
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ payload_available = "online";
+ payload_not_available = "offline";
+ };
+ hum = {host, topic ? "humidity" }:
+ {
+ platform = "mqtt";
+ unit_of_measurement = "%";
+ icon = "mdi:water-percent";
+ device_class = "humidity";
+ name = "${host} Humidity";
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ payload_available = "online";
+ payload_not_available = "offline";
+ };
+ # copied from "homeassistant/light/fablab_led/led_ring/config"
+ led = {host, topic ? "led", name ? host}:
+ { # name: fablab_led
+ # topic: led_ring
+ platform = "mqtt";
+ inherit name;
+ schema = "json";
+ brightness = true;
+ rgb = true;
+ effect = true;
+ effect_list = [ # TODO: may be different
+ "Random"
+ "Strobe"
+ "Rainbow"
+ "Color Wipe"
+ "Scan"
+ "Twinkle"
+ "Fireworks"
+ "Addressable Flicker"
+ "None"
+ ];
+ state_topic = "${prefix}/${host}/light/${topic}/state";
+ command_topic = "${prefix}/${host}/light/${topic}/command";
+ availability_topic = "${prefix}/${host}/status";
+ payload_available = "online";
+ payload_not_available = "offline";
+ qos = 1;
+ };
+ # Feinstaub
+ dust_25m = { host, name ? "${host} < 2.5µm", topic ? "particulate_matter_25m_concentration" }:
+ {
+ platform = "mqtt";
+ unit_of_measurement = "µg/m³";
+ icon = "mdi:chemical-weapon";
+ inherit name;
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ };
+ dust_100m = {host, name ? "${host} < 10µm", topic ? "particulate_matter_100m_concentration" }:
+ {
+ platform = "mqtt";
+ unit_of_measurement = "µg/m³";
+ icon = "mdi:chemical-weapon";
+ inherit name;
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ };
+ switch = {host, name ? "${host} Button", topic ? "btn" }:
+ # host: ampel
+ # name: Button 1
+ # topic: btn1
+ {
+ inherit name;
+ platform = "mqtt";
+ state_topic = "${prefix}/${host}/sensor/${topic}/state";
+ command_topic = "${prefix}/${host}/switch/${topic}/state";
+ availability_topic = "${prefix}/${host}/status";
+ };
+ };
+ tasmota =
+ {
+ plug = {host, name ? host, topic ? host}:
+ {
+ platform = "mqtt";
+ inherit name;
+ state_topic = "sonoff/stat/${topic}/POWER1";
+ command_topic = "sonoff/cmnd/${topic}/POWER1";
+ availability_topic = "sonoff/tele/${topic}/LWT";
+ payload_on= "ON";
+ payload_off= "OFF";
+ payload_available= "Online";
+ payload_not_available= "Offline";
+ retain = false;
+ qos = 1;
+ };
+ };
+}
diff --git a/krebs/2configs/shack/glados/multi/schlechte_luft.nix b/krebs/2configs/shack/glados/multi/schlechte_luft.nix
new file mode 100644
index 000000000..9cd2c56f4
--- /dev/null
+++ b/krebs/2configs/shack/glados/multi/schlechte_luft.nix
@@ -0,0 +1,123 @@
+let
+ glados = import ../lib;
+in
+{
+ # LED
+ light = [
+ (glados.esphome.led { name = "Fablab LED"; host = "fablab_led"; topic = "led_ring"; })
+
+ (glados.esphome.led { name = "Fablab LED Part A"; host = "fablab_led"; topic = "A";})
+ (glados.esphome.led { name = "Fablab LED Part B"; host = "fablab_led"; topic = "B";})
+ (glados.esphome.led { name = "Fablab LED Part C"; host = "fablab_led"; topic = "C";})
+ (glados.esphome.led { name = "Fablab LED Part D"; host = "fablab_led"; topic = "D";})
+ ];
+ sensor = [
+ (glados.esphome.temp { host = "fablab_feinstaub";})
+ (glados.esphome.dust_25m { host = "fablab_feinstaub";})
+ (glados.esphome.dust_100m { host = "fablab_feinstaub";})
+ ];
+ automation =
+ [
+ { alias = "Gute Luft Fablab";
+ trigger = [
+ {
+ platform = "numeric_state";
+ below = 25;
+ entity_id = "sensor.fablab_feinstaub_2_5um";
+ }
+ ];
+ action =
+ [
+ { service = "light.turn_on";
+ data = {
+ entity_id = "light.fablab_led";
+ effect = "Twinkle";
+ color_name = "green";
+ };
+ }
+ ];
+ }
+ { alias = "mäßige Luft Fablab";
+ trigger = [
+ #{
+ # platform = "numeric_state";
+ # above = 25;
+ # entity_id = "sensor.fablab_feinstaub_25m";
+ #}
+ {
+ platform = "numeric_state";
+ above = 25;
+ below = 50;
+ entity_id = "sensor.fablab_feinstaub_2_5um";
+ }
+ ];
+ action =
+ [
+ { service = "light.turn_on";
+ data = {
+ entity_id = "light.fablab_led";
+ effect = "Twinkle";
+ color_name = "yellow";
+ };
+ }
+ ];
+ }
+ { alias = "schlechte Luft Fablab";
+ trigger = [
+ {
+ platform = "numeric_state";
+ above = 50;
+ entity_id = "sensor.fablab_feinstaub_2_5um";
+ }
+ ];
+ action =
+ [
+ { service = "light.turn_on";
+ data = {
+ entity_id = "light.fablab_led";
+ effect = "Twinkle";
+ color_name = "red";
+ };
+ }
+ ];
+ }
+ { alias = "Luft Sensor nicht verfügbar";
+ trigger = [
+ {
+ platform = "state";
+ to = "unavailable";
+ entity_id = "sensor.fablab_feinstaub_2_5um";
+ }
+ ];
+ action =
+ [
+ { service = "light.turn_on";
+ data = {
+ entity_id = "light.fablab_led";
+ effect = "Rainbow";
+ color_name = "blue";
+ };
+ }
+ ];
+ }
+ { alias = "Fablab Licht Reboot";
+ trigger = [
+ {
+ platform = "state";
+ from = "unavailable";
+ entity_id = "light.fablab_led";
+ }
+ ];
+ action =
+ [
+ { service = "light.turn_on";
+ data = {
+ entity_id = "light.fablab_led";
+ effect = "Rainbow";
+ color_name = "orange";
+ };
+ }
+ ];
+ }
+ ];
+}
diff --git a/krebs/2configs/shack/glados/multi/wasser.nix b/krebs/2configs/shack/glados/multi/wasser.nix
index 578bb0750..cdfe01405 100644
--- a/krebs/2configs/shack/glados/multi/wasser.nix
+++ b/krebs/2configs/shack/glados/multi/wasser.nix
@@ -1,23 +1,12 @@
let
- tasmota_plug = name: topic:
- { platform = "mqtt";
- inherit name;
- state_topic = "sonoff/stat/${topic}/POWER1";
- command_topic = "sonoff/cmnd/${topic}/POWER1";
- availability_topic = "sonoff/tele/${topic}/LWT";
- payload_on= "ON";
- payload_off= "OFF";
- payload_available= "Online";
- payload_not_available= "Offline";
- retain = false;
- qos = 1;
- };
+ glados = import ../lib;
seconds = 20;
in
{
switch = [
- (tasmota_plug "Wasser" "plug")
+ (glados.tasmota.plug { host = "Wasser"; topic = "plug";} )
];
+
automation =
[
{ alias = "Water the plant for ${toString seconds} seconds";
diff --git a/krebs/2configs/shack/glados/sensors/hass.nix b/krebs/2configs/shack/glados/sensors/hass.nix
index 634758701..8de0ef391 100644
--- a/krebs/2configs/shack/glados/sensors/hass.nix
+++ b/krebs/2configs/shack/glados/sensors/hass.nix
@@ -1,22 +1,5 @@
let
- esphome_temp = name:
- { platform = "mqtt";
- name = "${name} Temperature";
- device_class = "temperature";
- state_topic = "glados/${name}/sensor/temperature/state";
- availability_topic = "glados/${name}/status";
- payload_available = "online";
- payload_not_available = "offline";
- };
- esphome_hum = name:
- { platform = "mqtt";
- device_class = "humidity";
- name = "${name} Humidity";
- state_topic = "glados/${name}/sensor/humidity/state";
- availability_topic = "glados/${name}/status";
- payload_available = "online";
- payload_not_available = "offline";
- };
+ glados = import ../lib;
in
- (map esphome_temp [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ])
- ++ (map esphome_hum [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ])
+ (map (host: glados.esphome.temp {inherit host;}) [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ])
+ ++ (map (host: glados.esphome.hum {inherit host;}) [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ])