summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/ham/default.nix
blob: ae0c46baa0ec8e5634c12ccdbb834bc19dd7f81c (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
{ pkgs, lib, config, ... }:

# Ideas:
## wake-on-lan server
##
let
  hlib = (import ./lib);
  prefix = hlib.prefix;
  tasmota = hlib.tasmota;
  firetv_stick = "192.168.1.24";
  hassdir = "/var/lib/hass";
  zigbee = import ./multi/zigbee2mqtt.nix;
  flurlicht = import ./multi/flurlicht.nix;
  kurzzeitwecker = import ./multi/kurzzeitwecker.nix;
#   switch
#   automation
#   binary_sensor
#   sensor
#   input_select
#   timer
in {
  imports = [
    ./mqtt.nix
  ];

  services.home-assistant = {
    config = {
      input_select = zigbee.input_select; # dict
      timer = zigbee.timer // kurzzeitwecker.timer; # dict
      homeassistant = {
        name = "Home"; time_zone = "Europe/Berlin";
        latitude = "48.7687";
        longitude = "9.2478";
        elevation = 247;
      };
      discovery = {};
      conversation = {};
      history = {};
      logbook = {};
      tts = [
        { platform = "google_translate";
          language = "de";
          time_memory = 57600;
          service_name =  "google_say";
        }
      ];

      telegram_bot = [
        # secrets file: {
        #  "platform": "broadcast",
        #  "api_key": "", # talk to Botfather /newbot
        #  "allowed_chat_ids": [ ID ] # curl -X GET #  https://api.telegram.org/bot<YOUR_API_TOKEN>/getUpdates
        #}
        (builtins.fromJSON
          (builtins.readFile <secrets/hass/telegram-bot.json>))
      ];
      notify = [
        {
          platform = "kodi";
          name = "wohnzimmer";
          host = firetv_stick;
        }
        {
          platform = "telegram";
          name = "telegrambot";
          chat_id = builtins.elemAt
            (builtins.fromJSON (builtins.readFile
              <secrets/hass/telegram-bot.json>)).allowed_chat_ids 0;
            }
          ];
      sun.elevation = 247;
      recorder = {};
      media_player = [
        { platform = "kodi";
          host = firetv_stick;
        }
        { platform = "androidtv";
          name = "FireTV Stick";
          device_class = "firetv";
          # adb_server_ip = firetv_stick;
          host = firetv_stick;
        }
      ];
      mqtt = {
        broker = "localhost";
        port = 1883;
        client_id = "home-assistant";
        username = "hass";
        password = lib.removeSuffix "\n" (builtins.readFile <secrets/mqtt/hass>);
        keepalive = 60;
        protocol = 3.1;
        birth_message = {
          topic = "${prefix}/hass/tele/LWT";
          payload = "Online";
          qos = 1;
          retain = true;
        };
        will_message = {
          topic = "${prefix}/hass/tele/LWT";
          payload = "Offline";
          qos = 1;
          retain = true;
        };
      };
      luftdaten = {
        show_on_map = true;
        sensor_id = 679;
        sensors.monitored_conditions = [ "P1" "P2" ];
      };
      binary_sensor =
         flurlicht.binary_sensor;
      sensor = [
        { platform = "speedtest";
          monitored_conditions = [ "ping" "download" "upload" ];
        }
        # https://www.home-assistant.io/cookbook/automation_for_rainy_days/
      ]
      ++ ((import ./sensor/outside.nix) {inherit lib;})
      ++ zigbee.sensor ;
      frontend = { };
      light = flurlicht.light;
      group =
        { default_view =
          { view = "yes";
            entities = [
              "group.flur"
              "group.schlafzimmer"
              "group.draussen"
              "group.wohnzimmer"
              "group.arbeitszimmer"
            ];
          };
          flur = [
            "light.flurlicht"
            "binary_sensor.flur_bewegung"
            "automation.dunkel_bei_sonnenuntergang"
            "automation.hell_bei_sonnenaufgang"
          ];
          wohnzimmer = [
            "media_player.kodi"
            "media_player.firetv_stick"
          ];
          draussen = [
            "sensor.dark_sky_temperature"
            "sensor.dark_sky_hourly_summary"
            "sensor.dark_sky_humidity"
            "sensor.dark_sky_pressure"
            "sensor.muehlhausen_pm10"
            "sensor.muehlhausen_pm25"
          ];
          schlafzimmer = [
            "sensor.schlafzimmer_temperatur"
            "sensor.schlafzimmer_luftdruck"
            "sensor.schlafzimmer_luftfeuchtigkeit"
            "switch.lichterkette_schlafzimmer"
          ];
          arbeitszimmer = [
            "switch.strom_staubsauger"
            "sensor.arbeitszimmer_temperatur"
            "sensor.arbeitszimmer_luftfeuchtigkeit"
          ];
        };
      http = { };
      switch = [];
      automation =
         flurlicht.automation
      ++ kurzzeitwecker.automation
      ++ zigbee.automation;
      script = kurzzeitwecker.script; # dict
    };
    enable = true;
    configDir = hassdir;
  };

}