summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/shack/glados/lib/default.nix
blob: debe8e5c2d60f69ef7af5b61e2c3908b4a98e6d5 (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
let
  lib =  import <nixpkgs/lib>;
  prefix = "glados";
in
{
  esphome =
  {
    temp = name:
    {
      platform = "mqtt";
      name = "${name} Temperature";
      device_class = "temperature";
      state_topic = "${prefix}/${name}/sensor/temperature/state";
      availability_topic = "${prefix}/${name}/status";
      payload_available = "online";
      payload_not_available = "offline";
    };
    hum = name:
    {
      platform = "mqtt";
      device_class = "humidity";
      name = "${name} Humidity";
      state_topic = "${prefix}/${name}/sensor/humidity/state";
      availability_topic = "${prefix}/${name}/status";
      payload_available = "online";
      payload_not_available = "offline";
    };
  };
  tasmota =
  {
    plug = name: topic:
    {
      platform = "mqtt";
      inherit name;
      state_topic = "sonoff/stat/${topic}/POWER1";
      command_topic = "sonoff/cmnd/${topic}/POWER1";
      availability_topic = "sonoff/tele/${topic}/LWT";
      payload_on= "ON";
      payload_off= "OFF";
      payload_available= "Online";
      payload_not_available= "Offline";
      retain = false;
      qos = 1;
    };
  };
}