2020-04-08 16:43:09 +02:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
let unstablePkgs = import <nixpkgs-unstable> { };
|
|
|
|
in {
|
|
|
|
|
|
|
|
imports = [
|
|
|
|
#./home-assistant/chaospott.nix
|
|
|
|
#./home-assistant/mpd.nix
|
|
|
|
#./home-assistant/timer.nix
|
2020-04-10 11:36:58 +02:00
|
|
|
./home-assistant/kodi.nix
|
2020-04-12 13:36:15 +02:00
|
|
|
./home-assistant/mqtt.nix
|
|
|
|
./home-assistant/sonoff.nix
|
|
|
|
./home-assistant/weather.nix
|
|
|
|
./home-assistant/workday.nix
|
2020-04-10 13:50:20 +02:00
|
|
|
./home-assistant/zigbee2mqtt.nix
|
2020-04-08 16:43:09 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
services.homeAssistantConfig = {
|
|
|
|
|
|
|
|
# turn on to edit GUI
|
|
|
|
# lovelace = {};
|
|
|
|
|
|
|
|
homeassistant = {
|
|
|
|
latitude = 51.444847;
|
|
|
|
longitude = 6.967006;
|
|
|
|
elevation = 116;
|
|
|
|
|
|
|
|
auth_providers = [{
|
|
|
|
type = "trusted_networks";
|
|
|
|
trusted_networks =
|
|
|
|
[ config.module.cluster.services.tinc."private".networkSubnet ];
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
|
|
|
prometheus.namespace = "hass";
|
|
|
|
|
2020-04-14 17:29:00 +02:00
|
|
|
input_boolean.bed_room_buttons.icon = "mdi:toggle-switch";
|
|
|
|
|
2020-04-14 03:01:11 +02:00
|
|
|
automation = let
|
2020-04-14 11:38:40 +02:00
|
|
|
# todo : at night only turn trigger essential groups
|
2020-04-14 03:01:11 +02:00
|
|
|
presents = room_group: present_group: [
|
|
|
|
{
|
|
|
|
alias = "presents -> turn on ${room_group} lights";
|
|
|
|
trigger = {
|
|
|
|
platform = "state";
|
|
|
|
entity_id = "group.${present_group}";
|
|
|
|
from = "off";
|
|
|
|
to = "on";
|
|
|
|
};
|
2020-04-15 18:08:27 +02:00
|
|
|
action = [
|
|
|
|
{
|
|
|
|
service = "switch.turn_on";
|
|
|
|
entity_id = "group.${room_group}";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
service = "light.turn_on";
|
|
|
|
entity_id = "group.${room_group}";
|
|
|
|
}
|
|
|
|
];
|
2020-04-14 03:01:11 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
alias = "absents -> turn off ${room_group} lights";
|
|
|
|
trigger = {
|
|
|
|
platform = "state";
|
|
|
|
entity_id = "group.${present_group}";
|
|
|
|
from = "on";
|
|
|
|
to = "off";
|
|
|
|
};
|
2020-04-15 18:08:27 +02:00
|
|
|
action = [
|
|
|
|
{
|
|
|
|
service = "switch.turn_off";
|
|
|
|
entity_id = "group.${room_group}";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
service = "light.turn_off";
|
|
|
|
entity_id = "group.${room_group}";
|
|
|
|
}
|
|
|
|
];
|
2020-04-14 03:01:11 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
in (presents "kitchen_room" "kitchen_room_present")
|
2020-04-14 17:49:09 +02:00
|
|
|
++ (presents "kitchen_room_essential" "kitchen_room_essential_present")
|
2020-04-14 03:01:11 +02:00
|
|
|
++ (presents "living_room" "living_room_present")
|
2020-04-14 17:49:09 +02:00
|
|
|
++ (presents "living_essential_room" "living_room_essential_present")
|
2020-04-14 03:01:11 +02:00
|
|
|
++ (presents "floor_room" "floor_room_present")
|
2020-04-14 17:49:09 +02:00
|
|
|
++ (presents "floor_room_essential" "floor_room_essential_present")
|
2020-04-15 18:08:27 +02:00
|
|
|
++ (presents "bath_room" "bath_room_present")
|
|
|
|
++ (presents "bath_room_essential" "bath_room_essential_present")
|
2020-04-14 17:49:09 +02:00
|
|
|
++ (presents "bed_room" "bed_room_present")
|
|
|
|
++ (presents "bed_room_essential" "bed_room_essential_present") ++ [
|
2020-04-08 16:43:09 +02:00
|
|
|
|
|
|
|
];
|
|
|
|
|
2020-04-14 11:38:40 +02:00
|
|
|
group = let
|
2020-04-14 17:49:09 +02:00
|
|
|
create_room = { name, description }: {
|
2020-04-14 11:38:40 +02:00
|
|
|
"${name}" = {
|
|
|
|
name = description;
|
|
|
|
view = false;
|
|
|
|
entities = [ "group.${name}_essential" ];
|
|
|
|
};
|
|
|
|
"${name}_present" = {
|
|
|
|
control = "hidden";
|
|
|
|
name = "${description} Anwesend";
|
|
|
|
view = false;
|
2020-04-15 18:08:27 +02:00
|
|
|
entities = [ ];
|
2020-04-14 11:38:40 +02:00
|
|
|
};
|
|
|
|
"${name}_essential" = {
|
|
|
|
control = "hidden";
|
|
|
|
name = "${description} Minimale Beleuchtung";
|
|
|
|
view = false;
|
2020-04-14 17:49:09 +02:00
|
|
|
entities = [ ];
|
|
|
|
};
|
|
|
|
"${name}_essential_present" = {
|
|
|
|
control = "hidden";
|
|
|
|
name = "${description} Flüchtig Anwesend";
|
|
|
|
view = false;
|
|
|
|
entities = [ "group.${name}_present" ];
|
2020-04-14 11:38:40 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
create_rooms = rooms:
|
|
|
|
lib.foldr (a: b: a // b) { } (map create_room rooms);
|
2020-04-12 21:05:55 +02:00
|
|
|
# rooms
|
|
|
|
# -----
|
2020-04-14 11:38:40 +02:00
|
|
|
in (create_rooms [
|
|
|
|
{
|
|
|
|
name = "floor_room";
|
|
|
|
description = "Flur";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "bed_room";
|
|
|
|
description = "Schlafzimmer";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "living_room";
|
|
|
|
description = "Wohnzimmer";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
name = "kitchen_room";
|
|
|
|
description = "Küche";
|
|
|
|
}
|
2020-04-15 18:08:27 +02:00
|
|
|
{
|
|
|
|
name = "bath_room";
|
|
|
|
description = "Klo";
|
|
|
|
}
|
2020-04-14 11:38:40 +02:00
|
|
|
]) // {
|
2020-04-08 16:43:09 +02:00
|
|
|
view_rooms = {
|
|
|
|
name = "Räume";
|
|
|
|
view = true;
|
|
|
|
entities = [
|
|
|
|
"group.all_lights"
|
2020-04-14 03:01:11 +02:00
|
|
|
"group.floor_room"
|
2020-04-14 17:49:09 +02:00
|
|
|
"group.floor_room_essential_present"
|
2020-04-08 16:43:09 +02:00
|
|
|
"group.bed_room"
|
2020-04-14 17:49:09 +02:00
|
|
|
"group.bed_room_essential_present"
|
2020-04-08 16:43:09 +02:00
|
|
|
"group.living_room"
|
2020-04-14 17:49:09 +02:00
|
|
|
"group.living_room_essential_present"
|
2020-04-12 21:05:55 +02:00
|
|
|
"group.kitchen_room"
|
2020-04-14 17:49:09 +02:00
|
|
|
"group.kitchen_room_essential_present"
|
2020-04-15 18:08:27 +02:00
|
|
|
"group.bath_room"
|
|
|
|
"group.bath_room_essential_present"
|
2020-04-14 17:49:09 +02:00
|
|
|
];
|
|
|
|
};
|
|
|
|
view_bed_room = {
|
|
|
|
name = "Schlafzimmer";
|
|
|
|
view = true;
|
2020-04-15 18:08:27 +02:00
|
|
|
entities = [ "group.bed_room" "group.bed_room_essential_present" ];
|
2020-04-14 17:49:09 +02:00
|
|
|
};
|
|
|
|
view_living_room = {
|
|
|
|
name = "Wohnzimmer";
|
|
|
|
view = true;
|
2020-04-15 18:08:27 +02:00
|
|
|
entities =
|
|
|
|
[ "group.living_room" "group.living_room_essential_present" ];
|
2020-04-14 17:49:09 +02:00
|
|
|
};
|
|
|
|
view_kitchen_room = {
|
|
|
|
name = "Küche";
|
|
|
|
view = true;
|
2020-04-15 18:08:27 +02:00
|
|
|
entities =
|
|
|
|
[ "group.kitchen_room" "group.kitchen_room_essential_present" ];
|
2020-04-14 17:49:09 +02:00
|
|
|
};
|
|
|
|
view_floor_room = {
|
|
|
|
name = "Flur";
|
|
|
|
view = true;
|
2020-04-15 18:08:27 +02:00
|
|
|
entities = [ "group.floor_room" "group.floor_room_essential_present" ];
|
|
|
|
};
|
|
|
|
view_bath_room = {
|
|
|
|
name = "Klo";
|
|
|
|
view = true;
|
|
|
|
entities = [ "group.bath_room" "group.bath_room_essential_present" ];
|
2020-04-08 16:43:09 +02:00
|
|
|
};
|
2020-04-12 21:05:55 +02:00
|
|
|
|
|
|
|
# overview
|
|
|
|
# --------
|
|
|
|
all_sensors = {
|
2020-04-16 00:10:12 +02:00
|
|
|
name = "Alle Sensoren";
|
2020-04-12 21:05:55 +02:00
|
|
|
control = "hidden";
|
|
|
|
};
|
|
|
|
today = {
|
|
|
|
control = "hidden";
|
|
|
|
name = "Today";
|
|
|
|
view = false;
|
|
|
|
};
|
2020-04-08 16:43:09 +02:00
|
|
|
view_overview = {
|
|
|
|
name = "Übersicht";
|
|
|
|
view = true;
|
2020-04-14 17:49:09 +02:00
|
|
|
entities = [ "group.today" ];
|
2020-04-12 19:57:49 +02:00
|
|
|
};
|
2020-04-12 21:05:55 +02:00
|
|
|
|
|
|
|
# other stuff
|
|
|
|
# -----------
|
|
|
|
tv = {
|
|
|
|
name = "TV";
|
|
|
|
view = false;
|
|
|
|
};
|
|
|
|
all_lights = {
|
2020-04-14 03:01:11 +02:00
|
|
|
name = "Alle Lampen";
|
2020-04-12 21:05:55 +02:00
|
|
|
view = false;
|
|
|
|
};
|
|
|
|
unknown = {
|
2020-04-12 19:57:49 +02:00
|
|
|
control = "hidden";
|
2020-04-12 21:05:55 +02:00
|
|
|
name = "Not Used";
|
|
|
|
view = false;
|
2020-04-12 21:42:11 +02:00
|
|
|
entities = [ ];
|
2020-04-08 16:43:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
script.turn_all_off.sequence = [ ];
|
2020-04-12 21:42:11 +02:00
|
|
|
script.turn_all_lights_off.sequence = [ ];
|
2020-04-08 16:43:09 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
services.home-assistant = {
|
|
|
|
enable = true;
|
|
|
|
package = unstablePkgs.home-assistant.override {
|
|
|
|
python3 = unstablePkgs.python37;
|
|
|
|
extraPackages = python: [
|
|
|
|
# todo : check which is still needed
|
|
|
|
python.netdisco
|
|
|
|
python.xmltodict
|
|
|
|
python.mpd2
|
|
|
|
|
|
|
|
# for mqtt
|
|
|
|
python.hbmqtt
|
|
|
|
python.paho-mqtt
|
|
|
|
|
|
|
|
# needed for platform workday
|
|
|
|
#(python.buildPythonPackage rec {
|
|
|
|
# pname = "holidays";
|
|
|
|
# version = "0.9.10";
|
|
|
|
# src = python.fetchPypi {
|
|
|
|
# inherit pname version;
|
|
|
|
# sha256 =
|
|
|
|
# "9f06d143eb708e8732230260636938f2f57114e94defd8fa2082408e0d422d6f";
|
|
|
|
# };
|
|
|
|
# doCheck = false;
|
|
|
|
# buildInputs = [ pkgs.dateutils ];
|
|
|
|
# propagatedBuildInputs = [ python."python-dateutil" python."six" ];
|
|
|
|
# meta = with pkgs.stdenv.lib; {
|
|
|
|
# homepage = "https://github.com/dr-prodigy/python-holidays";
|
|
|
|
# license = licenses.mit;
|
|
|
|
# description = "Generate and work with holidays in Python";
|
|
|
|
# maintainers = with maintainers; [ mrVanDalo ];
|
|
|
|
# };
|
|
|
|
#})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-04-09 01:19:00 +02:00
|
|
|
# host nginx setup
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
virtualHosts = {
|
|
|
|
"iot.pepe.private" = {
|
2020-04-09 16:51:39 +02:00
|
|
|
serverAliases = [ "hass.pepe.private" "home.pepe.private" ];
|
|
|
|
locations."/" = { proxyPass = "http://pepe.private:8123"; };
|
2020-04-09 01:19:00 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-08 16:43:09 +02:00
|
|
|
}
|