diff options
author | makefu <github@syntax-fehler.de> | 2020-02-20 14:00:17 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2020-02-20 14:00:17 +0100 |
commit | 64c224a711a1147b1be562ddd5ce1778ff5a6b1c (patch) | |
tree | b139a475f04278bc5438bddd05baae707d90e891 /krebs/2configs/shack | |
parent | a62f71b00bdb4028595d7edae0e2a25942ad1e56 (diff) |
shack/glados: add darksky,mate,spaceap,rollos
Diffstat (limited to 'krebs/2configs/shack')
-rw-r--r-- | krebs/2configs/shack/glados/default.nix | 20 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/lib/default.nix | 143 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/multi/rollos.nix | 13 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/multi/schlechte_luft.nix | 26 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/darksky.nix | 21 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/hass.nix | 5 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/mate.nix | 16 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/power.nix | 7 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/spaceapi.nix | 52 | ||||
-rw-r--r-- | krebs/2configs/shack/glados/sensors/unifi.nix | 6 |
10 files changed, 124 insertions, 185 deletions
diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index d8ee199cc..3f3b1cac5 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -39,7 +39,7 @@ in { ''; })).override { extraPackages = ps: with ps; [ - python-forecastio jsonrpc-async jsonrpc-websocket mpd2 picotts + python-forecastio jsonrpc-async jsonrpc-websocket mpd2 pkgs.picotts ]; }; autoExtraComponents = true; @@ -76,6 +76,8 @@ in { client_id = "home-assistant"; keepalive = 60; protocol = 3.1; + discovery = true; #enable esphome discovery + discovery_prefix = "homeassistant"; birth_message = { topic = "glados/hass/status/LWT"; payload = "Online"; @@ -90,7 +92,7 @@ in { }; }; switch = wasser.switch; - light = badair.light; + light = []; media_player = [ { platform = "mpd"; name = "lounge"; @@ -103,13 +105,17 @@ in { ]; sensor = - (import ./sensors/hass.nix) - ++ (import ./sensors/power.nix) + (import ./sensors/power.nix) + ++ (import ./sensors/mate.nix) + ++ (import ./sensors/darksky.nix { inherit lib;}) ++ shackopen.sensor - ++ badair.sensor; - airquality = (import ./sensors/sensemap.nix ); + ; + air_quality = (import ./sensors/sensemap.nix ); - binary_sensor = shackopen.binary_sensor; + binary_sensor = + shackopen.binary_sensor + ++ (import ./sensors/spaceapi.nix) + ; camera = []; diff --git a/krebs/2configs/shack/glados/lib/default.nix b/krebs/2configs/shack/glados/lib/default.nix index 6ab1edf85..6d2b7749b 100644 --- a/krebs/2configs/shack/glados/lib/default.nix +++ b/krebs/2configs/shack/glados/lib/default.nix @@ -46,149 +46,6 @@ in entity = "kiosk"; }; }; - 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"; - }; - rollo = {host, topic ? "rollo" }: - { - optimistic = true; - platform = "mqtt"; - name = "${host} Rollo"; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - command_topic = "${prefix}/${host}/sensor/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - position_topic = "${prefix}/${host}/cover/${topic}/position/state"; - set_position_topic = "${prefix}/${host}/cover/${topic}/position/command"; - }; - # 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; - }; - monoled = {host, topic ? "blue_led", name ? host "MonoLED ${host}"}: - { - platform = "mqtt"; - inherit name; - schema = "json"; - brightness = true; - effect = true; - effect_list = [ # TODO: may be different - "Strobe" - "Twinkle" - "None" - ]; - state_topic = "${prefix}/${host}/light/${topic}/state"; - command_topic = "${prefix}/${host}/light/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - }; - btn = {host, topic ? "button", name ? "${host} ${topic}"}: #binary_sensor - { - platform = "mqtt"; - name = "${host} Button"; - state_topic = "${prefix}/${host}/binary_sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - relay = {host, name ? "${host} ${topic}", topic ? "relay" }: #switch - { - inherit name; - platform = "mqtt"; - state_topic = "${prefix}/${host}/switch/${topic}/state"; - command_topic = "${prefix}/${host}/switch/${topic}/command"; - availability_topic = "${prefix}/${host}/status"; - }; - # 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"; - }; - ip = {host, name ? "${host} IP", topic ? "ip_address" }: - { - platform = "mqtt"; - inherit name; - state_topic = "${prefix}/${host}/sensor/${topic}/state"; - availability_topic = "${prefix}/${host}/status"; - }; - wifi = {host, name ? "${host} Wifi Signal", topic ? "wifi_signal" }: - { - platform = "mqtt"; - unit_of_measurement = "dB"; - icon = "mdi:wifi"; - 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}: diff --git a/krebs/2configs/shack/glados/multi/rollos.nix b/krebs/2configs/shack/glados/multi/rollos.nix new file mode 100644 index 000000000..1febad525 --- /dev/null +++ b/krebs/2configs/shack/glados/multi/rollos.nix @@ -0,0 +1,13 @@ +let + glados = import ../lib; +in +{ + # LED + light = [ + ]; + sensor = [ + ]; + automation = + [ + ]; +} diff --git a/krebs/2configs/shack/glados/multi/schlechte_luft.nix b/krebs/2configs/shack/glados/multi/schlechte_luft.nix index c02287d56..529454a41 100644 --- a/krebs/2configs/shack/glados/multi/schlechte_luft.nix +++ b/krebs/2configs/shack/glados/multi/schlechte_luft.nix @@ -2,32 +2,6 @@ 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.ip { host = "fablab_feinstaub";}) - (glados.esphome.wifi { host = "fablab_feinstaub";}) - (glados.esphome.temp { host = "fablab_feinstaub";}) - (glados.esphome.dust_25m { host = "fablab_feinstaub";}) - (glados.esphome.dust_100m { host = "fablab_feinstaub";}) - - (glados.esphome.ip { host = "fablab_led";}) - (glados.esphome.wifi { host = "fablab_led";}) - - (glados.esphome.ip { host = "rz_feinstaub";}) - (glados.esphome.wifi { host = "rz_feinstaub";}) - (glados.esphome.temp { host = "rz_feinstaub";}) - (glados.esphome.hum { host = "rz_feinstaub";}) - (glados.esphome.dust_25m { host = "rz_feinstaub";}) - (glados.esphome.dust_100m { host = "rz_feinstaub";}) - ]; automation = [ { alias = "Gute Luft Fablab"; diff --git a/krebs/2configs/shack/glados/sensors/darksky.nix b/krebs/2configs/shack/glados/sensors/darksky.nix new file mode 100644 index 000000000..c8725b868 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/darksky.nix @@ -0,0 +1,21 @@ +{lib,...}: +[ + { 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 + "humidity" + "pressure" + "uv_index" + ]; + units = "si" ; + scan_interval = "00:15:00"; + } +] diff --git a/krebs/2configs/shack/glados/sensors/hass.nix b/krebs/2configs/shack/glados/sensors/hass.nix deleted file mode 100644 index 8de0ef391..000000000 --- a/krebs/2configs/shack/glados/sensors/hass.nix +++ /dev/null @@ -1,5 +0,0 @@ -let - glados = import ../lib; -in - (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" ]) diff --git a/krebs/2configs/shack/glados/sensors/mate.nix b/krebs/2configs/shack/glados/sensors/mate.nix new file mode 100644 index 000000000..1bb0e71eb --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/mate.nix @@ -0,0 +1,16 @@ +let + fuellstand = name: id: { + platform = "rest"; + resource = "https://ora5.tutschonwieder.net/ords/lick_prod/v1/get/fuellstand/1/${toString id}"; + method = "GET"; + name = "Füllstand ${name}"; + value_template = "{{ value_json.fuellstand }}"; + }; +in [ + (fuellstand "Wasser" 1) + (fuellstand "Mate Cola" 2) + (fuellstand "Apfelschorle" 3) + (fuellstand "Zitronensprudel" 4) + (fuellstand "Mate 1" 26) + (fuellstand "Mate 2" 27) +] diff --git a/krebs/2configs/shack/glados/sensors/power.nix b/krebs/2configs/shack/glados/sensors/power.nix index 1aa250a19..b168f2beb 100644 --- a/krebs/2configs/shack/glados/sensors/power.nix +++ b/krebs/2configs/shack/glados/sensors/power.nix @@ -2,7 +2,6 @@ let power_x = name: phase: { platform = "mqtt"; name = "${phase} ${name}"; - # device_class = "power"; state_topic = "/power/total/${phase}/${name}"; availability_topic = "/power/lwt"; payload_available = "Online"; @@ -11,17 +10,17 @@ let power_consumed = { platform = "mqtt"; name = "Power Consumed"; - #device_class = "power"; + device_class = "power"; state_topic = "/power/total/consumed"; availability_topic = "/power/lwt"; payload_available = "Online"; payload_not_available = "Offline"; }; power_volt = power_x "Voltage"; - power_watt = power_x "Power"; + power_watt = (power_x "Power") ; power_curr = power_x "Current"; in (map power_volt [ "L1" "L2" "L3" ]) -++ (map power_watt [ "L1" "L2" "L3" ]) +++ (map (x: ((power_watt x) // { device_class = "power"; })) [ "L1" "L2" "L3" ]) ++ (map power_curr [ "L1" "L2" "L3" ]) ++ [ power_consumed ] diff --git a/krebs/2configs/shack/glados/sensors/spaceapi.nix b/krebs/2configs/shack/glados/sensors/spaceapi.nix new file mode 100644 index 000000000..11cab11c9 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/spaceapi.nix @@ -0,0 +1,52 @@ +[ + { + platform = "rest"; + resource = "https://spaceapi.afra-berlin.de/v1/status.json"; + method = "GET"; + name = "Door AFRA Berlin"; + device_class = "door"; + value_template = "{{ value_json.open }}"; + } + { + platform = "rest"; + resource = "http://club.entropia.de/spaceapi"; + method = "GET"; + name = "Door Entropia"; + device_class = "door"; + value_template = "{{ value_json.open }}"; + } + { + platform = "rest"; + resource = "http://www.c-base.org/status.json"; + method = "GET"; + name = "Door C-Base Berlin"; + device_class = "door"; + value_template = "{{ value_json.open }}"; + } + { + platform = "rest"; + resource = "https://status.raumzeitlabor.de/api/full.json"; + method = "GET"; + name = "Door RZL"; + device_class = "door"; + value_template = "{{ value_json.status }}"; + } + { + platform = "rest"; + resource = "https://datenobservatorium.de/"; + method = "GET"; + name = "Door Datenobservatorium"; + device_class = "door"; + value_template = "false"; + scan_interval = 2592000; + } + { + platform = "rest"; + resource = "https://infuanfu.de/"; + method = "GET"; + name = "Door Infuanfu"; + device_class = "door"; + value_template = "false"; + scan_interval = 2592000; + } +] diff --git a/krebs/2configs/shack/glados/sensors/unifi.nix b/krebs/2configs/shack/glados/sensors/unifi.nix new file mode 100644 index 000000000..f64e3feb6 --- /dev/null +++ b/krebs/2configs/shack/glados/sensors/unifi.nix @@ -0,0 +1,6 @@ +{ + controllers = { + host = "unifi.shack"; + site = "shackspace"; + }; +} |