From 4ad85faacedc755fd25b7edd0df41234c98876f0 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 7 Jan 2020 16:52:31 +0100 Subject: shack/glados: init hass config --- krebs/2configs/shack/glados/default.nix | 1 + krebs/2configs/shack/glados/lib/default.nix | 46 ++++++++++++++++++++++ .../2configs/shack/glados/multi/schlechte_luft.nix | 19 +++++++++ krebs/2configs/shack/glados/multi/wasser.nix | 17 ++------ krebs/2configs/shack/glados/sensors/hass.nix | 23 ++--------- 5 files changed, 72 insertions(+), 34 deletions(-) create mode 100644 krebs/2configs/shack/glados/lib/default.nix create mode 100644 krebs/2configs/shack/glados/multi/schlechte_luft.nix (limited to 'krebs/2configs') diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index d000af397..2c9a01af3 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" ]; diff --git a/krebs/2configs/shack/glados/lib/default.nix b/krebs/2configs/shack/glados/lib/default.nix new file mode 100644 index 000000000..debe8e5c2 --- /dev/null +++ b/krebs/2configs/shack/glados/lib/default.nix @@ -0,0 +1,46 @@ +let + lib = import ; + prefix = "glados"; +in +{ + esphome = + { + temp = name: + { + platform = "mqtt"; + name = "${name} Temperature"; + device_class = "temperature"; + state_topic = "${prefix}/${name}/sensor/temperature/state"; + availability_topic = "${prefix}/${name}/status"; + payload_available = "online"; + payload_not_available = "offline"; + }; + hum = name: + { + platform = "mqtt"; + device_class = "humidity"; + name = "${name} Humidity"; + state_topic = "${prefix}/${name}/sensor/humidity/state"; + availability_topic = "${prefix}/${name}/status"; + payload_available = "online"; + payload_not_available = "offline"; + }; + }; + 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; + }; + }; +} 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..94cb768b9 --- /dev/null +++ b/krebs/2configs/shack/glados/multi/schlechte_luft.nix @@ -0,0 +1,19 @@ +let + airlevel = name: threshold: color: + { alias = "${name} Air trigger ${color}"; + trigger = [ + ]; + action = + [ + # create spark effect with color + ]; + }; +in +{ + # LED + switch = [ + ]; + automation = + [ + ]; +} diff --git a/krebs/2configs/shack/glados/multi/wasser.nix b/krebs/2configs/shack/glados/multi/wasser.nix index 578bb0750..e3e7eb2a0 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 "Wasser" "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..ced6d9752 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 glados.esphome.temp [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ]) + ++ (map glados.esphome.hum [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ]) -- cgit v1.2.3