2019-09-02 11:57:06 +00:00
|
|
|
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";
|
2020-02-20 13:00:17 +00:00
|
|
|
device_class = "power";
|
2019-09-02 11:57:06 +00:00
|
|
|
state_topic = "/power/total/consumed";
|
|
|
|
availability_topic = "/power/lwt";
|
|
|
|
payload_available = "Online";
|
|
|
|
payload_not_available = "Offline";
|
|
|
|
};
|
|
|
|
power_volt = power_x "Voltage";
|
2020-02-20 13:00:17 +00:00
|
|
|
power_watt = (power_x "Power") ;
|
2019-09-02 11:57:06 +00:00
|
|
|
power_curr = power_x "Current";
|
|
|
|
in
|
2020-12-01 22:20:31 +00:00
|
|
|
{
|
|
|
|
services.home-assistant.config.sensor =
|
2019-09-02 11:57:06 +00:00
|
|
|
(map power_volt [ "L1" "L2" "L3" ])
|
2020-02-20 13:00:17 +00:00
|
|
|
++ (map (x: ((power_watt x) // { device_class = "power"; })) [ "L1" "L2" "L3" ])
|
2019-09-02 11:57:06 +00:00
|
|
|
++ (map power_curr [ "L1" "L2" "L3" ])
|
2020-12-01 22:20:31 +00:00
|
|
|
++ [ power_consumed ];
|
|
|
|
}
|