light-control: add leds

This commit is contained in:
Ingolf Wagner 2020-10-21 00:24:16 +02:00
parent bc1f5ae7ac
commit e8e57b750a
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 110 additions and 3 deletions

View file

@ -1,12 +1,13 @@
{ pkgs, lib, config, ... }: {
imports = [
./mqtt.nix
./zigbee2mqtt/service.nix
./zigbee2mqtt/buttons.nix
./zigbee2mqtt/doors.nix
./zigbee2mqtt/leds.nix
./zigbee2mqtt/lights.nix
./zigbee2mqtt/motion.nix
./zigbee2mqtt/buttons.nix
./zigbee2mqtt/service.nix
./zigbee2mqtt/temperatur.nix
./zigbee2mqtt/doors.nix
];
services.zigbee2mqtt = {

View file

@ -0,0 +1,106 @@
{ pkgs, lib, ... }:
let
# https://www.zigbee2mqtt.io/devices/GL-C-007-1ID.html
allDevices = {
"led_1" = { id = "0x00124b001f7a5be9"; };
"led_2" = { id = "0x00124b001ee958b3"; };
};
# -t "zigbee2mqtt/led_1/set" -m '{"state":"ON","brightness":255,"color":{"hex":"#00FFFF"}}'
# -t "zigbee2mqtt/led_1/set" -m '{"state":"OFF"}'
in {
services.zigbee2mqtt.devices = lib.mapAttrs' (name:
{ id, ... }: {
name = id;
value = {
retain = false;
friendly_name = name;
#osram_set_transition = 2; # time in seconds (integer or float)
};
}) 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;
# };
};
}