nixos-config/configs/pepe/home-assistant/zigbee2mqtt/heater.nix
2020-11-01 23:59:51 +01:00

54 lines
1.5 KiB
Nix

{ pkgs, lib, ... }:
let
# https://www.zigbee2mqtt.io/devices/SPZB0001.html
allDevices = {
"heater1" = { id = "0x00158d00032f5ee4"; }; # office
"heater2" = { id = "0x00158d00032f5f9f"; }; # office (kitchen)
"heater3" = { id = "0x00158d00032f6d1e"; }; # bed room
"heater4" = { id = "0x00158d00032f604d"; }; # abstell raum
};
# -t "zigbee2mqtt/heater3/set" -m '{"system_mode":"auto","current_heating_setpoint":23}'
# -t "zigbee2mqtt/heater3/set" -m '{"system_mode":"off"}'
in {
services.zigbee2mqtt.devices = lib.mapAttrs' (name:
{ id, ... }: {
name = id;
value = {
retain = false;
friendly_name = name;
transition = 1;
debounce = 0.5;
};
}) allDevices;
services.homeAssistantConfig = {
sensor = lib.flatten (lib.mapAttrsToList (name:
{ ... }: [
{
name = "battery_${name}";
platform = "mqtt";
state_topic = "zigbee2mqtt/${name}";
availability_topic = "zigbee2mqtt/bridge/state";
unit_of_measurement = "%";
icon = "mdi:battery-10";
value_template = "{{ value_json.battery }}";
}
{
name = "link_${name}";
platform = "mqtt";
state_topic = "zigbee2mqtt/${name}";
availability_topic = "zigbee2mqtt/bridge/state";
icon = "mdi:signal";
unit_of_measurement = "lqi";
value_template = "{{ value_json.linkquality }}";
}
]) allDevices);
};
}