shack/glados: utilize mergeable home-assistant config

This commit is contained in:
makefu 2020-12-01 23:20:31 +01:00
parent 9f2c161de0
commit c370c87da3
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
14 changed files with 533 additions and 497 deletions

View File

@ -1,6 +1,8 @@
# needs: # needs:
# light.fablab_led # light.fablab_led
[ {
services.home-assistant.config.automation =
[
{ alias = "State on HA start-up"; { alias = "State on HA start-up";
trigger = { trigger = {
platform = "homeassistant"; platform = "homeassistant";
@ -17,5 +19,6 @@
} }
]; ];
} }
] ];
}

View File

@ -6,7 +6,9 @@ let
disko_schalter = "switch.lounge_diskoschalter_relay"; disko_schalter = "switch.lounge_diskoschalter_relay";
player = "media_player.lounge"; player = "media_player.lounge";
in in
[ {
services.home-assistant.config.automation =
[
{ alias = "Party um 21 Uhr"; { alias = "Party um 21 Uhr";
trigger = { trigger = {
platform = "sun"; platform = "sun";
@ -26,4 +28,5 @@ in
} # TODO: also start playlist if nothing is running? } # TODO: also start playlist if nothing is running?
]; ];
} }
] ];
}

View File

@ -13,7 +13,9 @@
let let
glados = import ../lib; glados = import ../lib;
in in
[ {
services.home-assistant.config.automation =
[
{ {
alias = "Bedanken bei Übernahme von Key"; alias = "Bedanken bei Übernahme von Key";
initial_state = true; initial_state = true;
@ -94,4 +96,5 @@ in
} }
]; ];
} }
] ];
}

View File

@ -1,9 +1,5 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
shackopen = import ./multi/shackopen.nix;
wasser = import ./multi/wasser.nix;
badair = import ./multi/schlechte_luft.nix;
rollos = import ./multi/rollos.nix;
in { in {
services.nginx.virtualHosts."hass.shack" = { services.nginx.virtualHosts."hass.shack" = {
serverAliases = [ "glados.shack" ]; serverAliases = [ "glados.shack" ];
@ -21,14 +17,28 @@ in {
''; '';
}; };
}; };
imports = [
./multi/shackopen.nix
./multi/wasser.nix
./multi/schlechte_luft.nix
./multi/rollos.nix
./switch/power.nix
./sensors/power.nix
./sensors/mate.nix
./sensors/darksky.nix
./sensors/spaceapi.nix
./sensors/sensemap.nix
./automation/shack-startup.nix
./automation/party-time.nix
./automation/hass-restart.nix
];
services.home-assistant = services.home-assistant =
{ {
enable = true; enable = true;
package = pkgs.home-assistant.override {
extraPackages = ps: with ps; [
python-forecastio jsonrpc-async jsonrpc-websocket mpd2 pkgs.picotts
];
};
autoExtraComponents = true; autoExtraComponents = true;
config = { config = {
homeassistant = { homeassistant = {
@ -85,9 +95,6 @@ in {
retain = true; retain = true;
}; };
}; };
switch =
(import ./switch/power.nix)
;
light = []; light = [];
media_player = [ media_player = [
{ platform = "mpd"; { platform = "mpd";
@ -100,34 +107,23 @@ in {
} }
]; ];
sensor =
(import ./sensors/power.nix)
++ (import ./sensors/mate.nix)
++ (import ./sensors/darksky.nix { inherit lib;})
++ shackopen.sensor
++ wasser.sensor
;
air_quality = (import ./sensors/sensemap.nix );
binary_sensor =
shackopen.binary_sensor
++ (import ./sensors/spaceapi.nix)
;
camera = []; camera = [];
frontend = { }; frontend = { };
config = { }; config = { };
sun = {};
http = { http = {
base_url = "http://hass.shack"; base_url = "http://hass.shack";
use_x_forwarded_for = true; use_x_forwarded_for = true;
trusted_proxies = "127.0.0.1"; trusted_proxies = "127.0.0.1";
}; };
#conversation = {}; #conversation = {};
# history = {};
#logbook = {}; history = {};
logger.default = "info"; logbook = {};
#recorder = {}; #recorder = {};
logger.default = "info";
tts = [ tts = [
{ platform = "google_translate"; { platform = "google_translate";
service_name = "say"; service_name = "say";
@ -136,15 +132,6 @@ in {
time_memory = 57600; time_memory = 57600;
} }
]; ];
sun = {};
automation = wasser.automation
++ badair.automation
++ rollos.automation
++ (import ./automation/shack-startup.nix)
++ (import ./automation/party-time.nix)
++ (import ./automation/hass-restart.nix);
device_tracker = []; device_tracker = [];
}; };
}; };

View File

@ -11,6 +11,8 @@ let
]; ];
in in
{ {
services.home-assistant.config =
{
automation = automation =
[ [
{ alias = "Rollos fahren Runter"; { alias = "Rollos fahren Runter";
@ -53,4 +55,5 @@ in
]; ];
} }
]; ];
};
} }

View File

@ -4,6 +4,8 @@ let
ledring = "light.fablab_led_ring"; ledring = "light.fablab_led_ring";
in in
{ {
services.home-assistant.config =
{
automation = automation =
[ [
{ alias = "Gute Luft Fablab"; { alias = "Gute Luft Fablab";
@ -103,4 +105,5 @@ in
]; ];
} }
]; ];
};
} }

View File

@ -1,4 +1,6 @@
{ {
services.home-assistant.config =
{
binary_sensor = [ binary_sensor = [
{ platform = "mqtt"; { platform = "mqtt";
name = "Portal Lock"; name = "Portal Lock";
@ -20,4 +22,5 @@
payload_not_available = "offline"; payload_not_available = "offline";
} }
]; ];
};
} }

View File

@ -11,6 +11,8 @@ let
}; };
in in
{ {
services.home-assistant.config =
{
sensor = map ( entity_id: { sensor = map ( entity_id: {
platform = "statistics"; platform = "statistics";
name = "Statistics for ${entity_id}"; name = "Statistics for ${entity_id}";
@ -107,4 +109,5 @@ in
]; ];
} }
]; ];
};
} }

View File

@ -1,5 +1,7 @@
{lib,...}: {lib,...}:
[ {
services.home-assistant.config.sensor =
[
{ platform = "darksky"; { platform = "darksky";
api_key = lib.removeSuffix "\n" api_key = lib.removeSuffix "\n"
(builtins.readFile <secrets/hass/darksky.apikey>); (builtins.readFile <secrets/hass/darksky.apikey>);
@ -18,4 +20,5 @@
units = "si" ; units = "si" ;
scan_interval = "00:15:00"; scan_interval = "00:15:00";
} }
] ];
}

View File

@ -6,11 +6,15 @@ let
name = "Füllstand ${name}"; name = "Füllstand ${name}";
value_template = "{{ value_json.fuellstand }}"; value_template = "{{ value_json.fuellstand }}";
}; };
in [ in
{
services.home-assistant.config.sensor =
[
(fuellstand "Wasser" 1) (fuellstand "Wasser" 1)
(fuellstand "Mate Cola" 2) (fuellstand "Mate Cola" 2)
(fuellstand "Apfelschorle" 3) (fuellstand "Apfelschorle" 3)
(fuellstand "Zitronensprudel" 4) (fuellstand "Zitronensprudel" 4)
(fuellstand "Mate 1" 26) (fuellstand "Mate 1" 26)
(fuellstand "Mate 2" 27) (fuellstand "Mate 2" 27)
] ];
}

View File

@ -20,7 +20,10 @@ let
power_watt = (power_x "Power") ; power_watt = (power_x "Power") ;
power_curr = power_x "Current"; power_curr = power_x "Current";
in in
{
services.home-assistant.config.sensor =
(map power_volt [ "L1" "L2" "L3" ]) (map power_volt [ "L1" "L2" "L3" ])
++ (map (x: ((power_watt x) // { device_class = "power"; })) [ "L1" "L2" "L3" ]) ++ (map (x: ((power_watt x) // { device_class = "power"; })) [ "L1" "L2" "L3" ])
++ (map power_curr [ "L1" "L2" "L3" ]) ++ (map power_curr [ "L1" "L2" "L3" ])
++ [ power_consumed ] ++ [ power_consumed ];
}

View File

@ -1,6 +1,9 @@
[ {
services.home-assistant.config.air_quality =
[
{ {
platform = "opensensemap"; platform = "opensensemap";
station_id = "56a0de932cb6e1e41040a68b"; station_id = "56a0de932cb6e1e41040a68b";
} }
] ];
}

View File

@ -1,4 +1,6 @@
[ {
services.home-assistant.config.binary_sensor =
[
{ {
platform = "rest"; platform = "rest";
resource = "https://spaceapi.afra-berlin.de/v1/status.json"; resource = "https://spaceapi.afra-berlin.de/v1/status.json";
@ -49,4 +51,5 @@
value_template = "false"; value_template = "false";
scan_interval = 2592000; scan_interval = 2592000;
} }
] ];
}

View File

@ -15,12 +15,23 @@ let
power = nodelight "power"; power = nodelight "power";
light = ident: name: { icon = "mdi:lightbulb";} // nodelight "light" ident name; light = ident: name: { icon = "mdi:lightbulb";} // nodelight "light" ident name;
in in
[ {
(power 1 "Hauptschalter") services.home-assistant.config.switch =
(power 2 "Dusche") [
(power 3 "Warmwasser") # These commands we see with a shutdown:
(power 4 "Optionsräume") # power/143/state on
(power 5 "Küche") # power/142/state on
# power/141/state on
# power/142/state off
# power/141/state off
# power/10/state off
# power/main/state off
(power "10" "Hauptschalter")
(power 1 "Dusche") # ???
(power 2 "Warmwasser") # ???
(power 3 "Optionsräume") # ???
(power 4 "Küche") # ???
(light 1 "Decke Lounge 1") (light 1 "Decke Lounge 1")
(light 2 "Decke Lounge 2") (light 2 "Decke Lounge 2")
(light 3 "Decke Lounge 3") (light 3 "Decke Lounge 3")
@ -29,4 +40,5 @@ in
(light 6 "Decke Lounge 6") (light 6 "Decke Lounge 6")
(light 7 "Decke Lounge 7") (light 7 "Decke Lounge 7")
(light 8 "Decke Lounge 8") (light 8 "Decke Lounge 8")
] ];
}