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

86 lines
2.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 = {
2021-03-20 13:28:40 +01:00
"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
2020-10-30 00:36:00 +01:00
};
# -t "zigbee2mqtt/heater3/set" -m '{"system_mode":"auto","current_heating_setpoint":23}'
# -t "zigbee2mqtt/heater3/set" -m '{"system_mode":"off"}'
2021-11-01 09:20:42 +01:00
in
{
2020-10-30 00:36:00 +01:00
2021-11-01 09:20:42 +01:00
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;
2020-10-30 00:36:00 +01:00
services.homeAssistantConfig = {
2021-11-01 09:20:42 +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 }}";
}
{
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);
2020-10-30 00:36:00 +01:00
};
}