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

53 lines
1.4 KiB
Nix
Raw Normal View History

2020-10-30 23:39:40 +01:00
{ 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 {
2020-11-22 01:58:32 +01:00
services.zigbee2mqttConfiguration = lib.mapAttrs' (name:
2020-10-30 23:39:40 +01:00
{ 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);
};
}