nixos-config/configs/pepe/home-assistant/zigbee2mqtt/heater.nix

55 lines
1.5 KiB
Nix
Raw Normal View History

2020-10-30 00:36:00 +01:00
{ 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;
2020-11-01 23:59:51 +01:00
debounce = 0.5;
2020-10-30 00:36:00 +01:00
};
}) allDevices;
services.homeAssistantConfig = {
2020-10-30 23:39:40 +01:00
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);
2020-10-30 00:36:00 +01:00
};
}