light-control: add leds
This commit is contained in:
parent
bc1f5ae7ac
commit
e8e57b750a
2 changed files with 110 additions and 3 deletions
|
@ -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 = {
|
||||
|
|
106
configs/pepe/home-assistant/zigbee2mqtt/leds.nix
Normal file
106
configs/pepe/home-assistant/zigbee2mqtt/leds.nix
Normal 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;
|
||||
# };
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue