diff --git a/configs/pepe/home-assistant/zigbee2mqtt/heater.nix b/configs/pepe/home-assistant/zigbee2mqtt/heater.nix index 2f79691..ba440a6 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/heater.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/heater.nix @@ -22,6 +22,14 @@ in { friendly_name = name; transition = 1; debounce = 0.5; + filtered_attributes = [ + "battery_low" + "eurotronic_host_flags" + "eurotronic_system_mode" + "occupied_heating_setpoint" + "pi_heating_demand" + "unoccupied_heating_setpoint" + ]; }; }) allDevices; @@ -47,6 +55,15 @@ in { unit_of_measurement = "lqi"; value_template = "{{ value_json.linkquality }}"; } + { + platform = "mqtt"; + name = "temperature_${name}"; + state_topic = "zigbee2mqtt/${name}"; + availability_topic = "zigbee2mqtt/bridge/state"; + unit_of_measurement = "°C"; + device_class = "temperature"; + value_template = "{{ value_json.local_temperature }}"; + } ]) allDevices); }; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/leds.nix b/configs/pepe/home-assistant/zigbee2mqtt/leds.nix index 20072a9..d331c92 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/leds.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/leds.nix @@ -25,83 +25,18 @@ in { 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; - # }; + 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; }; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/motion.nix b/configs/pepe/home-assistant/zigbee2mqtt/motion.nix index 7d70c6c..f99edd1 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/motion.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/motion.nix @@ -4,38 +4,14 @@ let # https://www.zigbee2mqtt.io/devices/RTCGQ01LM.html allDevices = { - "motion_sensor_1" = { - id = "0x00158d0002fbd451"; - groups = [ "kitchen_room" "kitchen_room_present" ]; - }; - "motion_sensor_2" = { - id = "0x00158d0002f9a6b8"; - groups = [ "bed_room" "bed_room_present" ]; - }; - "motion_sensor_3" = { - id = "0x00158d0002f04522"; - groups = [ "living_room" "living_room_present" ]; - }; - "motion_sensor_4" = { - id = "0x00158d0002f9a558"; - groups = [ "living_room" "living_room_present" ]; - }; - "motion_sensor_5" = { - id = "0x00158d0002f9a56f"; - groups = [ "bath_room" "bath_room_present" ]; - }; - "motion_sensor_6" = { - id = "0x00158d0002f9a5cb"; - groups = [ ]; - }; - "motion_sensor_7" = { - id = "0x00158d0002f9a6aa"; - groups = [ "bed_room" "bed_room_present" ]; - }; - "motion_sensor_8" = { - id = "0x00158d0002f04637"; - groups = [ "bath_room" "bath_room_present" ]; - }; + "motion_sensor_1" = { id = "0x00158d0002fbd451"; }; + "motion_sensor_2" = { id = "0x00158d0002f9a6b8"; }; + "motion_sensor_3" = { id = "0x00158d0002f04522"; }; + "motion_sensor_4" = { id = "0x00158d0002f9a558"; }; + "motion_sensor_5" = { id = "0x00158d0002f9a56f"; }; + "motion_sensor_6" = { id = "0x00158d0002f9a5cb"; }; + "motion_sensor_7" = { id = "0x00158d0002f9a6aa"; }; + "motion_sensor_8" = { id = "0x00158d0002f04637"; }; }; in { @@ -52,6 +28,21 @@ in { }) allDevices; services.homeAssistantConfig = { + + # define meta information sensors + binary_sensor = lib.flatten (lib.mapAttrsToList (name: + { ... }: [{ + name = "${name}"; + platform = "mqtt"; + state_topic = "zigbee2mqtt/${name}"; + availability_topic = "zigbee2mqtt/bridge/state"; + value_template = "{{ value_json.occupancy }}"; + #icon = "mdi:battery-10"; + payload_on = true; + payload_off = false; + device_class = "motion"; + }]) allDevices); + # define meta information sensors sensor = lib.flatten (lib.mapAttrsToList (name: { ... }: [ diff --git a/configs/pepe/home-assistant/zigbee2mqtt/repeater.nix b/configs/pepe/home-assistant/zigbee2mqtt/repeater.nix index 69112d1..398469b 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/repeater.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/repeater.nix @@ -5,100 +5,14 @@ let allDevices = { "repeater1" = { id = "0x680ae2fffe6e7dc1"; }; "repeater2" = { id = "0x680ae2fffe8e240d"; }; + "repeater3" = { id = "0x680ae2fffe404f60"; }; + "repeater4" = { id = "0x680ae2fffe8e2e71"; }; }; in { - services.zigbee2mqtt.devices = lib.mapAttrs' (name: { id, ... }: { name = id; - value = { - retain = false; - friendly_name = name; - transition = 1; - }; + value = { friendly_name = name; }; }) 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; - # }; - - }; - }