diff --git a/configs/pepe/home-assistant.nix b/configs/pepe/home-assistant.nix index ea4b382..fcf9d32 100644 --- a/configs/pepe/home-assistant.nix +++ b/configs/pepe/home-assistant.nix @@ -37,65 +37,81 @@ in { automation = let # todo : at night only turn trigger essential groups - presents = room_group: present_group: [ + roomPresents = { roomGroup, presentsGroup }: [ { - alias = "presents -> turn on ${room_group} lights"; + alias = "presents -> turn on ${roomGroup} lights"; trigger = { platform = "state"; - entity_id = "group.${present_group}"; + entity_id = "group.${presentsGroup}"; from = "off"; to = "on"; }; action = [ { service = "switch.turn_on"; - entity_id = "group.${room_group}"; + entity_id = "group.${roomGroup}"; } { service = "light.turn_on"; - entity_id = "group.${room_group}"; + entity_id = "group.${roomGroup}"; } ]; } { - alias = "absents -> turn off ${room_group} lights"; + alias = "absents -> turn off ${roomGroup} lights"; trigger = { platform = "state"; - entity_id = "group.${present_group}"; + entity_id = "group.${presentsGroup}"; from = "on"; to = "off"; }; action = [ { service = "switch.turn_off"; - entity_id = "group.${room_group}"; + entity_id = "group.${roomGroup}"; } { service = "light.turn_off"; - entity_id = "group.${room_group}"; + entity_id = "group.${roomGroup}"; } ]; } ]; - in (presents "kitchen_room" "kitchen_room_present") - ++ (presents "kitchen_room_essential" "kitchen_room_essential_present") - ++ (presents "living_room" "living_room_present") - ++ (presents "living_essential_room" "living_room_essential_present") - ++ (presents "floor_room" "floor_room_present") - ++ (presents "floor_room_essential" "floor_room_essential_present") - ++ (presents "bath_room" "bath_room_present") - ++ (presents "bath_room_essential" "bath_room_essential_present") - ++ (presents "bed_room" "bed_room_present") - ++ (presents "bed_room_essential" "bed_room_essential_present") ++ [ - - ]; + in lib.flatten (map roomPresents [ + { + roomGroup = "kitchen_room_lights"; + presentsGroup = "kitchen_room_present"; + } + { + roomGroup = "living_room_lights"; + presentsGroup = "living_room_present"; + } + { + roomGroup = "floor_room_lights"; + presentsGroup = "floor_room_present"; + } + { + roomGroup = "bath_room_lights"; + presentsGroup = "bath_room_present"; + } + { + roomGroup = "bed_room_lights"; + presentsGroup = "bed_room_present"; + } + ]); group = let create_room = { name, description }: { "${name}" = { - name = description; + name = "${description}"; view = false; - entities = [ "group.${name}_essential" ]; + control = "hidden"; + entities = [ ]; + }; + "${name}_lights" = { + name = "${description} Beleuchtung"; + view = false; + entities = [ ]; }; "${name}_present" = { control = "hidden"; @@ -109,11 +125,16 @@ in { view = false; entities = [ ]; }; - "${name}_essential_present" = { - control = "hidden"; - name = "${description} Flüchtig Anwesend"; - view = false; - entities = [ "group.${name}_present" ]; + "view_${name}" = { + name = description; + view = true; + entities = [ + "group.${name}" + "group.${name}_lights" + "group.${name}_present" + "group.${name}_essential" + "group.${name}_essential_present" + ]; }; }; create_rooms = rooms: @@ -146,46 +167,13 @@ in { name = "Räume"; view = true; entities = [ - "group.all_lights" "group.floor_room" - "group.floor_room_essential_present" "group.bed_room" - "group.bed_room_essential_present" "group.living_room" - "group.living_room_essential_present" "group.kitchen_room" - "group.kitchen_room_essential_present" "group.bath_room" - "group.bath_room_essential_present" ]; }; - view_bed_room = { - name = "Schlafzimmer"; - view = true; - entities = [ "group.bed_room" "group.bed_room_essential_present" ]; - }; - view_living_room = { - name = "Wohnzimmer"; - view = true; - entities = - [ "group.living_room" "group.living_room_essential_present" ]; - }; - view_kitchen_room = { - name = "Küche"; - view = true; - entities = - [ "group.kitchen_room" "group.kitchen_room_essential_present" ]; - }; - view_floor_room = { - name = "Flur"; - view = true; - entities = [ "group.floor_room" "group.floor_room_essential_present" ]; - }; - view_bath_room = { - name = "Klo"; - view = true; - entities = [ "group.bath_room" "group.bath_room_essential_present" ]; - }; # overview # -------- diff --git a/configs/pepe/home-assistant/sonoff.nix b/configs/pepe/home-assistant/sonoff.nix index 4cfa916..5cae9db 100644 --- a/configs/pepe/home-assistant/sonoff.nix +++ b/configs/pepe/home-assistant/sonoff.nix @@ -5,38 +5,38 @@ let "pal01" = { label = "Schlafzimmer Lampe Links"; icon = "mdi:lightbulb-on"; - room = "bed_room_essential"; + room = "bed_room_lights"; type = "light"; }; "pal02" = { - label = "Flur Lampe"; + label = "Wohnzimmer Lampe"; icon = "mdi:lightbulb-on"; - room = "living_room_essential"; + room = "living_room_lights"; type = "light"; }; "pal03" = { label = "Wohnzimmer Lampe"; icon = "mdi:lightbulb-on"; - room = "living_room_essential"; + room = "living_room_lights"; type = "light"; }; "pal04" = { label = "Schlafzimmer Lampe Rechts"; icon = "mdi:lightbulb-on"; - room = "bed_room"; + room = "bed_room_lights"; type = "light"; }; "pal05" = { label = "TV"; icon = "mdi:television"; - room = "living_room"; + room = "living_room_lights"; type = "device"; device = "tv"; }; "pal06" = { label = "Küchen Lampe"; icon = "mdi:lightbulb-on"; - room = "kitchen_room_essential"; + room = "kitchen_room_lights"; type = "light"; }; "pal07" = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt/buttons.nix b/configs/pepe/home-assistant/zigbee2mqtt/buttons.nix index fbce4ea..b6a8d2c 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/buttons.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/buttons.nix @@ -12,16 +12,16 @@ let "button_1" = { id = "0x00158d0002b04f65"; # states = { click = "input_boolean.living_room_button"; } # input state to hold (optional) (default "input_boolean.single_${name}") - groups = [ "living_room_present" ]; + groups = [ "living_room" "living_room_present" ]; }; "button_2" = { id = "0x00158d0002b04f09"; - groups = [ "bed_room_present" ]; + groups = [ "bed_room" "bed_room_present" ]; states.single = "input_boolean.bed_room_buttons"; }; "button_3" = { id = "0x00158d0002b00e04"; - groups = [ "bed_room_present" ]; + groups = [ "bed_room" "bed_room_present" ]; states.single = "input_boolean.bed_room_buttons"; }; }; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/doors.nix b/configs/pepe/home-assistant/zigbee2mqtt/doors.nix index 68fed97..5926c84 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/doors.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/doors.nix @@ -6,12 +6,12 @@ let "door_sensor_1" = { id = "0x00158d000312dc52"; }; "door_sensor_2" = { id = "0x00158d000316d5bf"; - groups = [ "floor_room_present" ]; + groups = [ "floor_room" "floor_room_present" ]; }; "door_sensor_3" = { id = "0x00158d0002f9516f"; }; "door_sensor_4" = { id = "0x00158d00031383b9"; - groups = [ "floor_room_present" ]; + groups = [ "floor_room" "floor_room_present" ]; }; "door_sensor_5" = { id = "0x00158d0003120d3e"; }; }; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix index 330094c..f33addd 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix @@ -5,29 +5,26 @@ let allDevices = { "light_1" = { id = "0x7cb03eaa0a0347b5"; - groups = [ "floor_room_essential" ]; + groups = [ "floor_room" "floor_room_essential" "floor_room_lights" ]; }; "light_2" = { id = "0x7cb03eaa0a0387b9"; - groups = [ "floor_room" ]; + groups = [ "floor_room" "floor_room_lights" ]; }; "light_3" = { id = "0x7cb03eaa0a033a86"; - groups = [ "living_room" ]; + groups = [ "living_room" "living_room_lights" ]; }; "light_4" = { id = "0x7cb03eaa0a04aabf"; - groups = [ "bath_room_essential" ]; - }; - "light_5" = { - id = "0x7cb03eaa0a0346e4"; - groups = [ "living_room" ]; + groups = [ "bath_room" "bath_room_essential" "bath_room_lights" ]; }; + "light_5" = { id = "0x7cb03eaa0a0346e4"; }; "light_6" = { id = "0x7cb03eaa0a034b46"; }; "light_7" = { id = "0x7cb03eaa0a033b4f"; }; "light_8" = { id = "0x7cb03eaa0a0384d3"; - groups = [ "bed_room" ]; + groups = [ "bed_room" "bed_room_essential" "bed_room_lights" ]; }; }; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/motion.nix b/configs/pepe/home-assistant/zigbee2mqtt/motion.nix index 75b4a3d..3a84d16 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/motion.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/motion.nix @@ -6,42 +6,42 @@ let "motion_sensor_1" = { id = "0x00158d0002fbd451"; - groups = [ "kitchen_room_present" ]; + groups = [ "kitchen_room" "kitchen_room_present" ]; timeout = 60 * 2; }; "motion_sensor_2" = { id = "0x00158d0002f9a6b8"; - groups = [ "kitchen_room_present" ]; + groups = [ "kitchen_room" "kitchen_room_present" ]; timeout = 60 * 2; }; "motion_sensor_3" = { id = "0x00158d0002f04522"; - groups = [ "living_room_present" ]; + groups = [ "living_room" "living_room_present" ]; timeout = 60 * 3; }; "motion_sensor_4" = { id = "0x00158d0002f9a558"; - groups = [ "living_room_present" ]; + groups = [ "living_room" "living_room_present" ]; timeout = 60 * 3; }; "motion_sensor_5" = { id = "0x00158d0002f9a56f"; - groups = [ "bath_room_essential_present" ]; + groups = [ "bath_room" "bath_room_present" ]; timeout = 60 * 3; }; "motion_sensor_6" = { id = "0x00158d0002f9a5cb"; - groups = [ "floor_room_present" ]; - timeout = 60 * 5; + groups = [ "floor_room" "floor_room_present" ]; + timeout = 60 * 2; }; "motion_sensor_7" = { id = "0x00158d0002f9a6aa"; - groups = [ "bed_room_essential_present" ]; + groups = [ "bed_room" "bed_room_present" ]; timeout = 60 * 1.2; }; "motion_sensor_8" = { id = "0x00158d0002f04637"; - groups = [ "bath_room_essential_present" ]; + groups = [ "bath_room" "bath_room_present" ]; timeout = 60 * 3; }; }; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix b/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix index 62f0bfe..a6e0c7e 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/temperatur.nix @@ -5,11 +5,11 @@ let allDevices = { "temperature_sensor_1" = { id = "0x00158d0002d79220"; - groups = [ "living_room_present" ]; + groups = [ "living_room" ]; }; "temperature_sensor_2" = { id = "0x00158d0002d7913d"; - groups = [ "living_room_present" ]; + groups = [ "living_room" ]; }; };