From 1ff1a25e893e706683f6d9d9c1fc1cceaab55da3 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 16 Apr 2020 00:10:12 +0200 Subject: [PATCH] pepe: improved hass --- configs/pepe/home-assistant.nix | 2 +- .../home-assistant/zigbee2mqtt/lights.nix | 7 ++++-- .../home-assistant/zigbee2mqtt/motion.nix | 12 +++++++++- .../home-assistant/zigbee2mqtt/temperatur.nix | 22 +++++++++---------- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/configs/pepe/home-assistant.nix b/configs/pepe/home-assistant.nix index e87ea7a..ea4b382 100644 --- a/configs/pepe/home-assistant.nix +++ b/configs/pepe/home-assistant.nix @@ -190,7 +190,7 @@ in { # overview # -------- all_sensors = { - name = "Sensor Overview"; + name = "Alle Sensoren"; control = "hidden"; }; today = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix index 3fb4f23..330094c 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix @@ -88,8 +88,11 @@ in { lightGroups = lib.mapAttrs (name: { ... }: { control = "hidden"; - entities = - [ "light.${name}" "sensor.link_${name}" "binary_sensor.update_${name}" ]; + entities = [ + "light.${name}" + "sensor.link_${name}" + "binary_sensor.update_${name}" + ]; }) allDevices; # sort lights into given groups. diff --git a/configs/pepe/home-assistant/zigbee2mqtt/motion.nix b/configs/pepe/home-assistant/zigbee2mqtt/motion.nix index 685318d..75b4a3d 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/motion.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/motion.nix @@ -7,45 +7,55 @@ let "motion_sensor_1" = { id = "0x00158d0002fbd451"; groups = [ "kitchen_room_present" ]; + timeout = 60 * 2; }; "motion_sensor_2" = { id = "0x00158d0002f9a6b8"; groups = [ "kitchen_room_present" ]; + timeout = 60 * 2; }; "motion_sensor_3" = { id = "0x00158d0002f04522"; groups = [ "living_room_present" ]; + timeout = 60 * 3; }; "motion_sensor_4" = { id = "0x00158d0002f9a558"; groups = [ "living_room_present" ]; + timeout = 60 * 3; }; "motion_sensor_5" = { id = "0x00158d0002f9a56f"; groups = [ "bath_room_essential_present" ]; + timeout = 60 * 3; }; "motion_sensor_6" = { id = "0x00158d0002f9a5cb"; groups = [ "floor_room_present" ]; + timeout = 60 * 5; }; "motion_sensor_7" = { id = "0x00158d0002f9a6aa"; groups = [ "bed_room_essential_present" ]; + timeout = 60 * 1.2; }; "motion_sensor_8" = { id = "0x00158d0002f04637"; groups = [ "bath_room_essential_present" ]; + timeout = 60 * 3; }; }; in { services.zigbee2mqtt.devices = lib.mapAttrs' (name: - { id, ... }: { + { id, timeout ? 90, ... }: { name = id; value = { retain = false; friendly_name = name; + # should not be set below 60 seconds + occupancy_timeout = timeout; }; }) allDevices; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix b/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix index 90910b5..62f0bfe 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix @@ -47,15 +47,15 @@ in { device_class = "humidity"; value_template = "{{ value_json.humidity }}"; } - { - platform = "mqtt"; - name = "pressure_${name}"; - state_topic = "zigbee2mqtt/${name}"; - availability_topic = "zigbee2mqtt/bridge/state"; - unit_of_measurement = "hPa"; - device_class = "pressure"; - value_template = "{{ value_json.pressure }}"; - } + #{ + # platform = "mqtt"; + # name = "pressure_${name}"; + # state_topic = "zigbee2mqtt/${name}"; + # availability_topic = "zigbee2mqtt/bridge/state"; + # unit_of_measurement = "hPa"; + # device_class = "pressure"; + # value_template = "{{ value_json.pressure }}"; + #} { name = "battery_${name}"; platform = "mqtt"; @@ -87,7 +87,7 @@ in { entities = [ "sensor.${name}" "sensor.humidity_${name}" - "sensor.pressure_${name}" + #"sensor.pressure_${name}" "sensor.battery_${name}" "sensor.link_${name}" @@ -105,7 +105,7 @@ in { in sortedInGroups // sensorGroups // { all_sensors.entities = - lib.mapAttrsToList (name: { ... }: "binary_sensor.${name}") allDevices; + lib.mapAttrsToList (name: { ... }: "sensor.${name}") allDevices; }; };