From bc1f5ae7ac2cf0c12e5bfd3f4f1f0e64a2584620 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Tue, 20 Oct 2020 21:37:46 +0200 Subject: [PATCH] light-control: wip --- .../home-assistant/zigbee2mqtt/lights.nix | 115 +++++++++--------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix index 32b9e6b..e5017e3 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix @@ -45,69 +45,70 @@ in { }; }) allDevices; - #services.homeAssistantConfig = { + services.homeAssistantConfig = { - # light = lib.mapAttrsToList (name: - # { ... }: { - # platform = "mqtt"; - # name = name; - # state_topic = "zigbee2mqtt/${name}"; - # availability_topic = "zigbee2mqtt/bridge/state"; - # command_topic = "zigbee2mqtt/${name}/set"; - # value_template = "{{ value_json.click }}"; - # brightness = true; - # color_temp = true; - # schema = "json"; - # }) allDevices; + light = lib.mapAttrsToList (name: + { ... }: { + platform = "mqtt"; + name = name; + state_topic = "zigbee2mqtt/${name}"; + availability_topic = "zigbee2mqtt/bridge/state"; + command_topic = "zigbee2mqtt/${name}/set"; + value_template = "{{ value_json.click }}"; + brightness = true; + color_temp = true; + schema = "json"; + }) allDevices; - # sensor = with lib; - # mapAttrsToList (name: - # { ... }: { - # name = "link_${name}"; - # platform = "mqtt"; - # state_topic = "zigbee2mqtt/${name}"; - # availability_topic = "zigbee2mqtt/bridge/state"; - # icon = "mdi:signal"; - # value_template = "{{ value_json.linkquality}}"; - # }) allDevices; + # sensor = with lib; + # mapAttrsToList (name: + # { ... }: { + # name = "link_${name}"; + # platform = "mqtt"; + # state_topic = "zigbee2mqtt/${name}"; + # availability_topic = "zigbee2mqtt/bridge/state"; + # icon = "mdi:signal"; + # 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; + # 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 + # # 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; + # # 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; + # # 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; - # }; - #}; + # in sortedInGroups // lightGroups // { + # all_lights.entities = + # lib.mapAttrsToList (name: { ... }: "light.${name}") allDevices; + # }; + + }; }