nixos-config/configs/pepe/home-assistant/zigbee2mqtt/repeater.nix
2020-10-30 00:36:00 +01:00

104 lines
3 KiB
Nix

{ pkgs, lib, ... }:
let
# https://www.zigbee2mqtt.io/devices/SPZB0001.html
allDevices = {
"repeater1" = { id = "0x680ae2fffe6e7dc1"; };
"repeater2" = { id = "0x680ae2fffe8e240d"; };
};
in {
services.zigbee2mqtt.devices = lib.mapAttrs' (name:
{ id, ... }: {
name = id;
value = {
retain = false;
friendly_name = name;
transition = 1;
};
}) allDevices;
services.homeAssistantConfig = {
#light = lib.flatten (lib.mapAttrsToList (name:
# { ... }: [
# {
# name = "rgb_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# brightness = true;
# color_temp = true;
# xy = true;
# schema = "json";
# command_topic = "zigbee2mqtt/${name}/rgb/set";
# brightness_scale = 254;
# state_topic_postfix = "rgb";
# }
# {
# name = "white_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# brightness = true;
# schema = "json";
# command_topic = "zigbee2mqtt/${name}/white/set";
# brightness_scale = 254;
# state_topic_postfix = "white";
# }
# ]) allDevices);
#sensor = with lib;
# mapAttrsToList (name:
# { ... }: {
# 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;
# binary_sensor = lib.mapAttrsToList (name:
# { ... }: {
# name = "update_${name}";
# platform = "mqtt";
# state_topic = "zigbee2mqtt/${name}";
# availability_topic = "zigbee2mqtt/bridge/state";
# payload_on = true;
# payload_off = false;
# value_template = "{{ value_json.update_available }}";
# }) allDevices;
# # create groups
# # -------------
# group = let
# # to have nice panels for every device
# lightGroups = lib.mapAttrs (name:
# { ... }: {
# entities = [
# "light.${name}"
# "sensor.link_${name}"
# "binary_sensor.update_${name}"
# ];
# }) allDevices;
# # sort lights into given groups.
# sortedInGroups = let
# groupEntries = lib.zipAttrs (lib.flatten (lib.mapAttrsToList (name:
# { groups ? [ ], ... }:
# map (groupName: { "${groupName}" = "light.${name}"; }) groups)
# allDevices));
# in lib.mapAttrs (name: entities: { inherit entities; }) groupEntries;
# in sortedInGroups // lightGroups // {
# all_lights.entities =
# lib.mapAttrsToList (name: { ... }: "light.${name}") allDevices;
# };
};
}