53 lines
1.4 KiB
Nix
53 lines
1.4 KiB
Nix
|
{ pkgs, lib, ... }:
|
||
|
let
|
||
|
|
||
|
# https://www.zigbee2mqtt.io/devices/E1757.html
|
||
|
allDevices = {
|
||
|
"fyrtur1" = { id = "0x680ae2fffe64fa40"; }; # office
|
||
|
"fyrtur2" = { id = "0x680ae2fffe6e9f41"; }; # bed room
|
||
|
"fyrtur3" = { id = "0x680ae2fffe8f6411"; }; # office (close to kitchen)
|
||
|
"fyrtur4" = { id = "0x680ae2fffe91d234"; }; # kitchen
|
||
|
};
|
||
|
|
||
|
# -t "zigbee2mqtt/fyrtur1/set" -m '{"position":100}'
|
||
|
# -t "zigbee2mqtt/fyrtur1/set" -m '{"position":15}'
|
||
|
in {
|
||
|
|
||
|
services.zigbee2mqtt.devices = lib.mapAttrs' (name:
|
||
|
{ id, ... }: {
|
||
|
name = id;
|
||
|
value = {
|
||
|
retain = false;
|
||
|
friendly_name = name;
|
||
|
transition = 0.1;
|
||
|
};
|
||
|
}) 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);
|
||
|
|
||
|
};
|
||
|
|
||
|
}
|