summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/shack/glados/sensors/power.nix
blob: b168f2beb81cbe42f8c5835f90c9b54cabfc759f (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
let
  power_x = name: phase:
  { platform = "mqtt";
    name = "${phase} ${name}";
    state_topic = "/power/total/${phase}/${name}";
    availability_topic = "/power/lwt";
    payload_available = "Online";
    payload_not_available = "Offline";
  };
  power_consumed =
  { platform = "mqtt";
    name = "Power Consumed";
    device_class = "power";
    state_topic = "/power/total/consumed";
    availability_topic = "/power/lwt";
    payload_available = "Online";
    payload_not_available = "Offline";
  };
  power_volt = power_x "Voltage";
  power_watt = (power_x "Power") ;
  power_curr = power_x "Current";
in
   (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 ]