diff --git a/configs/pepe/home-assistant.nix b/configs/pepe/home-assistant.nix index c5ef633..127dfb3 100644 --- a/configs/pepe/home-assistant.nix +++ b/configs/pepe/home-assistant.nix @@ -34,7 +34,7 @@ in { prometheus.namespace = "hass"; automation = let - + # todo : at night only turn trigger essential groups presents = room_group: present_group: [ { alias = "presents -> turn on ${room_group} lights"; @@ -62,9 +62,7 @@ in { entity_id = "group.${room_group}"; }; } - ]; - in (presents "kitchen_room" "kitchen_room_present") ++ (presents "living_room" "living_room_present") ++ (presents "floor_room" "floor_room_present") @@ -72,45 +70,46 @@ in { ]; - group = { + group = let + create_room = { name, description }: { + "${name}" = { + name = description; + view = false; + entities = [ "group.${name}_essential" ]; + }; + "${name}_present" = { + control = "hidden"; + name = "${description} Anwesend"; + view = false; + }; + "${name}_essential" = { + control = "hidden"; + name = "${description} Minimale Beleuchtung"; + view = false; + }; + }; + create_rooms = rooms: + lib.foldr (a: b: a // b) { } (map create_room rooms); # rooms # ----- - floor_room = { - name = "Flur"; - view = false; - }; - floor_room_present = { - control = "hidden"; - name = "Flur Anwesend"; - view = false; - }; - bed_room = { - name = "Schlafzimmer"; - view = false; - }; - bed_room_present = { - control = "hidden"; - name = "Schlafzimmer Anwesend"; - view = false; - }; - living_room = { - name = "Wohnzimmer"; - view = false; - }; - living_room_present = { - control = "hidden"; - name = "Wohnzimmer Anwesend"; - view = false; - }; - kitchen_room = { - name = "Küche"; - view = false; - }; - kitchen_room_present = { - control = "hidden"; - name = "Küche Anwesend"; - view = false; - }; + in (create_rooms [ + { + name = "floor_room"; + description = "Flur"; + } + { + name = "bed_room"; + description = "Schlafzimmer"; + } + { + name = "living_room"; + description = "Wohnzimmer"; + } + { + name = "kitchen_room"; + description = "Küche"; + } + ]) // { view_rooms = { name = "Räume"; view = true; diff --git a/configs/pepe/home-assistant/sonoff.nix b/configs/pepe/home-assistant/sonoff.nix index bc9fe04..8949084 100644 --- a/configs/pepe/home-assistant/sonoff.nix +++ b/configs/pepe/home-assistant/sonoff.nix @@ -5,19 +5,19 @@ let "pal01" = { label = "Schlafzimmer Lampe Links"; icon = "mdi:lightbulb-on"; - room = "bed_room"; + room = "bed_room_essential"; type = "light"; }; "pal02" = { label = "Flur Lampe"; icon = "mdi:lightbulb-on"; - room = "floor_room"; + room = "floor_room_essential"; type = "light"; }; "pal03" = { label = "Wohnzimmer Lampe"; icon = "mdi:lightbulb-on"; - room = "living_room"; + room = "living_room_essential"; type = "light"; }; "pal04" = { @@ -36,7 +36,7 @@ let "pal06" = { label = "Küchen Lampe"; icon = "mdi:lightbulb-on"; - room = "kitchen_room"; + room = "kitchen_room_essential"; type = "light"; }; "pal07" = { diff --git a/configs/pepe/home-assistant/zigbee2mqtt.nix b/configs/pepe/home-assistant/zigbee2mqtt.nix index 68abe0f..80a410d 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt.nix @@ -57,7 +57,10 @@ let id = "0x00158d0002f9a5cb"; room = "floor_room_present"; }; - "motion_sensor_7" = { id = "0x00158d0002f9a6aa"; }; + "motion_sensor_7" = { + id = "0x00158d0002f9a6aa"; + room = "bed_room_present"; + }; "motion_sensor_8" = { id = "0x00158d0002f04637"; }; }; door = {