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:
# light.fablab_led
[
{
services.home-assistant.config.automation =
[
{ alias = "State on HA start-up";
trigger = {
platform = "homeassistant";
@ -17,5 +19,6 @@
}
];
}
]
];
}

View File

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

View File

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

View File

@ -1,9 +1,5 @@
{ config, pkgs, lib, ... }:
let
shackopen = import ./multi/shackopen.nix;
wasser = import ./multi/wasser.nix;
badair = import ./multi/schlechte_luft.nix;
rollos = import ./multi/rollos.nix;
in {
services.nginx.virtualHosts."hass.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 =
{
enable = true;
package = pkgs.home-assistant.override {
extraPackages = ps: with ps; [
python-forecastio jsonrpc-async jsonrpc-websocket mpd2 pkgs.picotts
];
};
autoExtraComponents = true;
config = {
homeassistant = {
@ -85,9 +95,6 @@ in {
retain = true;
};
};
switch =
(import ./switch/power.nix)
;
light = [];
media_player = [
{ 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 = [];
frontend = { };
config = { };
sun = {};
http = {
base_url = "http://hass.shack";
use_x_forwarded_for = true;
trusted_proxies = "127.0.0.1";
};
#conversation = {};
# history = {};
#logbook = {};
logger.default = "info";
history = {};
logbook = {};
#recorder = {};
logger.default = "info";
tts = [
{ platform = "google_translate";
service_name = "say";
@ -136,15 +132,6 @@ in {
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 = [];
};
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,10 @@ let
power_watt = (power_x "Power") ;
power_curr = power_x "Current";
in
{
services.home-assistant.config.sensor =
(map power_volt [ "L1" "L2" "L3" ])
++ (map (x: ((power_watt x) // { device_class = "power"; })) [ "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";
station_id = "56a0de932cb6e1e41040a68b";
}
]
];
}

View File

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

View File

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