summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/shack/glados/default.nix
blob: 51c2ad94f1961a9f7cd9d09b5cebe0194c3d0f85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{ config, pkgs, lib, ... }:
let
  unstable = import (pkgs.fetchFromGitHub {
    owner = "nixos";
    repo = "nixpkgs";
    rev = (lib.importJSON ../../../nixpkgs-unstable.json).rev;
    sha256 = (lib.importJSON ../../../nixpkgs-unstable.json).sha256;
  }) {};
in {
  services.nginx.virtualHosts."hass.shack" = {
    serverAliases = [ "glados.shack" ];
    locations."/" = {
      proxyPass = "http://localhost:8123";
      extraConfig = ''
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host             $host;
          proxy_set_header X-Real-IP        $remote_addr;

          proxy_buffering off;
        '';
    };
  };
  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;
    autoExtraComponents = true;
    package = unstable.home-assistant.overrideAttrs (old: {
      doInstallCheck = false;
    });
    config = {
      homeassistant = {
        name = "Glados";
        time_zone = "Europe/Berlin";
        latitude = "48.8265";
        longitude = "9.0676";
        elevation = 303;
        auth_providers = [
          { type = "homeassistant";}
          { type = "trusted_networks";
            trusted_networks = [
              "127.0.0.1/32"
              "10.42.0.0/16"
              "::1/128"
              "fd00::/8"
            ];
          }
        ];
      };
      # https://www.home-assistant.io/components/influxdb/
      influxdb = {
        database = "glados";
        host = "influx.shack";
        component_config_glob = {
          "sensor.*particulate_matter_2_5um_concentration".override_measurement = "2_5um particles";
          "sensor.*particulate_matter_10_0um_concentration".override_measurement ="10um particles";
        };
        tags = {
          instance = "wolf";
          source = "glados";
        };
      };
      esphome = {};
      api = {};
      mqtt = {
        broker = "localhost";
        port = 1883;
        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";
          qos = 1;
          retain = true;
        };
        will_message = {
          topic = "glados/hass/status/LWT";
          payload = "Offline";
          qos = 1;
          retain = true;
        };
      };
      light =  [];
      media_player = [
        { platform = "mpd";
          name = "lounge";
          host = "lounge.mpd.shack";
        }
        { platform = "mpd";
          name = "kiosk";
          #host = "lounge.kiosk.shack";
          host = "kiosk.shack";
        }
      ];

      camera = [];
      frontend = { };
      config = { };
      sun = {};
      http = {
        base_url = "http://hass.shack";
        use_x_forwarded_for = true;
        trusted_proxies = [ "127.0.0.1" "::1" ];
      };
      #conversation = {};

      history = {};
      logbook = {};
      #recorder = {};

      logger.default = "info";

      tts = [
        { platform = "google_translate";
          service_name = "say";
          language = "de";
          cache = true;
          time_memory = 57600;
          base_url = "http://hass.shack";
        }
      ];
      device_tracker = [];
    };
  };
}