80 lines
2.4 KiB
Nix
80 lines
2.4 KiB
Nix
{ pkgs, lib, ... }:
|
|
let
|
|
|
|
# https://www.zigbee2mqtt.io/devices/SPZB0001.html
|
|
allDevices = {
|
|
"office_heater_1" = { id = "0x00158d00032f5ee4"; }; # office
|
|
"office_heater_2" = { id = "0x00158d00032f5f9f"; }; # office (kitchen)
|
|
"bedroom_heater_1" = { id = "0x00158d00032f6d1e"; }; # bed room
|
|
"storage_heater_1" = { 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.zigbee2mqttConfiguration = lib.mapAttrs' (name:
|
|
{ id, ... }: {
|
|
name = id;
|
|
value = {
|
|
legacy = false;
|
|
retain = false;
|
|
friendly_name = name;
|
|
transition = 1;
|
|
debounce = 0.5;
|
|
filtered_attributes = [
|
|
"battery_low"
|
|
"eurotronic_host_flags"
|
|
"eurotronic_system_mode"
|
|
#"occupied_heating_setpoint"
|
|
#"pi_heating_demand"
|
|
#"unoccupied_heating_setpoint"
|
|
];
|
|
};
|
|
}) 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 }}";
|
|
}
|
|
{
|
|
platform = "mqtt";
|
|
name = "temperature_${name}";
|
|
state_topic = "zigbee2mqtt/${name}";
|
|
availability_topic = "zigbee2mqtt/bridge/state";
|
|
unit_of_measurement = "°C";
|
|
device_class = "temperature";
|
|
value_template = "{{ value_json.local_temperature }}";
|
|
}
|
|
{
|
|
platform = "mqtt";
|
|
name = "pi_heating_demand_${name}";
|
|
state_topic = "zigbee2mqtt/${name}";
|
|
availability_topic = "zigbee2mqtt/bridge/state";
|
|
unit_of_measurement = "%";
|
|
value_template = "{{ value_json.pi_heating_demand }}";
|
|
}
|
|
]) allDevices);
|
|
|
|
};
|
|
|
|
}
|