From 2b8fef6473d55b4603de530fa1572b7be2bf64fe Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sun, 3 May 2020 06:55:38 +0200 Subject: [PATCH 1/2] hass.io: add bright setup --- configs/pepe/home-assistant.nix | 52 ++++++++++++++++++- configs/pepe/home-assistant/sonoff.nix | 9 ++-- .../home-assistant/zigbee2mqtt/lights.nix | 19 +++++-- 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/configs/pepe/home-assistant.nix b/configs/pepe/home-assistant.nix index 7548692..c4aabb3 100644 --- a/configs/pepe/home-assistant.nix +++ b/configs/pepe/home-assistant.nix @@ -218,7 +218,6 @@ in { ]; } ]; - in lib.flatten (map roomPresents (lib.flatten (map (name: [ { roomGroup = "${name}_lights"; @@ -232,6 +231,12 @@ in { situation = "essential"; brightness = 30; } + { + roomGroup = "${name}_bright"; + roomOffGroup = "${name}_lights"; + presentsGroup = "${name}_present"; + situation = "bright"; + } ]) allRooms))) ++ [ # control situation with buttons @@ -268,6 +273,8 @@ in { }; } ] ++ (lib.flatten (map situationSwitch (lib.flatten (map (name: [ + + # essential <-> dark { presentsGroup = "${name}_present"; fromSituation = "dark"; @@ -283,6 +290,40 @@ in { fromRoomGroup = "${name}_essential"; toRoomGroup = "${name}_lights"; } + + # bright <-> dark + { + presentsGroup = "${name}_present"; + fromSituation = "dark"; + toSituation = "bright"; + fromRoomGroup = "${name}_lights"; + toRoomGroup = "${name}_bright"; + } + { + presentsGroup = "${name}_present"; + fromSituation = "bright"; + toSituation = "dark"; + fromRoomGroup = "${name}_bright"; + toRoomGroup = "${name}_lights"; + } + + # bright <-> essential + { + presentsGroup = "${name}_present"; + fromSituation = "bright"; + toSituation = "essential"; + fromRoomGroup = "${name}_bright"; + toRoomGroup = "${name}_essential"; + brightness = 30; + } + { + presentsGroup = "${name}_present"; + fromSituation = "essential"; + toSituation = "bright"; + fromRoomGroup = "${name}_essential"; + toRoomGroup = "${name}_bright"; + } + ]) allRooms)))); group = let @@ -310,14 +351,21 @@ in { view = false; entities = [ ]; }; + "${name}_bright" = { + control = "hidden"; + name = "${description} Tages Beleuchtung"; + view = false; + entities = [ ]; + }; "view_${name}" = { name = description; view = true; entities = [ "group.${name}" + "group.${name}_bright" + "group.${name}_essential" "group.${name}_lights" "group.${name}_present" - "group.${name}_essential" ]; }; }; diff --git a/configs/pepe/home-assistant/sonoff.nix b/configs/pepe/home-assistant/sonoff.nix index 2048f7d..ba9515b 100644 --- a/configs/pepe/home-assistant/sonoff.nix +++ b/configs/pepe/home-assistant/sonoff.nix @@ -5,7 +5,7 @@ let "pal01" = { label = "Schlafzimmer Lampe Links"; icon = "mdi:lightbulb"; - groups = [ "all_lights" "bed_room_lights" "bed_room" ]; + groups = [ "all_lights" "bed_room_lights" "bed_room_bright" "bed_room" ]; }; "pal02" = { label = "Nummer 2"; @@ -19,7 +19,7 @@ let "pal04" = { label = "Schlafzimmer Lampe Rechts"; icon = "mdi:lightbulb"; - groups = [ "all_lights" "bed_room_lights" "bed_room" ]; + groups = [ "all_lights" "bed_room_lights" "bed_room_bright" "bed_room" ]; }; "pal05" = { label = "TV"; @@ -32,9 +32,10 @@ let icon = "mdi:lightbulb"; groups = [ "all_lights" - "kitchen_room_lights" - "kitchen_room_essential" "kitchen_room" + "kitchen_room_bright" + "kitchen_room_essential" + "kitchen_room_lights" ]; }; "pal07" = { label = "Nummer 7"; }; diff --git a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix index dd4d406..2d80961 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix @@ -5,7 +5,10 @@ let allDevices = { "light_1" = { id = "0x7cb03eaa0a0347b5"; - groups = [ "floor_room" "floor_room_essential" "floor_room_lights" ]; + groups = [ + "floor_room" + "floor_room_bright" "floor_room_essential" "floor_room_lights" + ]; }; "light_2" = { id = "0x7cb03eaa0a0387b9"; @@ -13,18 +16,26 @@ let }; "light_3" = { id = "0x7cb03eaa0a033a86"; - groups = [ "living_room" "living_room_essential" "living_room_lights" ]; + groups = [ + "living_room" + "living_room_essential" "living_room_lights" + ]; }; "light_4" = { id = "0x7cb03eaa0a04aabf"; - groups = [ "bath_room" "bath_room_essential" "bath_room_lights" ]; + groups = [ + "bath_room" + "bath_room_bright" + "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" "bed_room_essential" "bed_room_lights" ]; + groups = + [ "bed_room" "bed_room_essential" "bed_room_lights" "bed_room_bright" ]; }; }; From b02627eda977f1dca4ab8f5a97d78c6ece52f4f1 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Sun, 3 May 2020 06:56:16 +0200 Subject: [PATCH 2/2] reformat --- configs/pepe/home-assistant/zigbee2mqtt/lights.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix index 2d80961..02375f0 100644 --- a/configs/pepe/home-assistant/zigbee2mqtt/lights.nix +++ b/configs/pepe/home-assistant/zigbee2mqtt/lights.nix @@ -7,7 +7,9 @@ let id = "0x7cb03eaa0a0347b5"; groups = [ "floor_room" - "floor_room_bright" "floor_room_essential" "floor_room_lights" + "floor_room_bright" + "floor_room_essential" + "floor_room_lights" ]; }; "light_2" = { @@ -16,17 +18,15 @@ let }; "light_3" = { id = "0x7cb03eaa0a033a86"; - groups = [ - "living_room" - "living_room_essential" "living_room_lights" - ]; + groups = [ "living_room" "living_room_essential" "living_room_lights" ]; }; "light_4" = { id = "0x7cb03eaa0a04aabf"; groups = [ "bath_room" "bath_room_bright" - "bath_room_essential" "bath_room_lights" + "bath_room_essential" + "bath_room_lights" ]; }; "light_5" = { id = "0x7cb03eaa0a0346e4"; };