pepe: home-assistant refactoring
This commit is contained in:
parent
55bf10631d
commit
aad74d7393
2 changed files with 67 additions and 45 deletions
|
@ -59,27 +59,54 @@ in {
|
|||
];
|
||||
|
||||
group = {
|
||||
# rooms
|
||||
# -----
|
||||
bed_room = {
|
||||
name = "Schlafzimmer";
|
||||
view = false;
|
||||
};
|
||||
tv = {
|
||||
name = "TV";
|
||||
view = false;
|
||||
};
|
||||
living_room = {
|
||||
name = "Wohnzimmer";
|
||||
view = false;
|
||||
};
|
||||
kitchen = {
|
||||
kitchen_room = {
|
||||
name = "Küche";
|
||||
view = false;
|
||||
};
|
||||
view_rooms = {
|
||||
name = "Räume";
|
||||
view = true;
|
||||
entities = [
|
||||
"group.all_lights"
|
||||
"group.bed_room"
|
||||
"group.living_room"
|
||||
"group.kitchen_room"
|
||||
];
|
||||
};
|
||||
|
||||
# overview
|
||||
# --------
|
||||
all_sensors = {
|
||||
name = "Sensor Overview";
|
||||
control = "hidden";
|
||||
};
|
||||
today = {
|
||||
control = "hidden";
|
||||
name = "Today";
|
||||
view = false;
|
||||
};
|
||||
view_overview = {
|
||||
name = "Übersicht";
|
||||
view = true;
|
||||
entities = [ "group.today" "group.all_sensors" ];
|
||||
};
|
||||
|
||||
# other stuff
|
||||
# -----------
|
||||
tv = {
|
||||
name = "TV";
|
||||
view = false;
|
||||
};
|
||||
all_lights = {
|
||||
name = "All Lights";
|
||||
view = false;
|
||||
|
@ -89,26 +116,6 @@ in {
|
|||
name = "Not Used";
|
||||
view = false;
|
||||
};
|
||||
view_rooms = {
|
||||
name = "Räume";
|
||||
view = true;
|
||||
entities = [
|
||||
"group.all_lights"
|
||||
"group.bed_room"
|
||||
"group.living_room"
|
||||
"group.kitchen"
|
||||
"group.tv"
|
||||
];
|
||||
};
|
||||
view_overview = {
|
||||
name = "Übersicht";
|
||||
view = true;
|
||||
entities = [ "group.today" "group.all_sensors" ];
|
||||
};
|
||||
all_sensors = {
|
||||
name = "Sensor Overview";
|
||||
control = "hidden";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -3,28 +3,41 @@ let
|
|||
|
||||
sonoffSwitches = {
|
||||
"pal01" = {
|
||||
label = "Schlafzimmer";
|
||||
label = "Schlafzimmer Lampe";
|
||||
icon = "mdi:lightbulb-on";
|
||||
room = "bed_room";
|
||||
type = "light";
|
||||
};
|
||||
"pal02" = {
|
||||
label = "Schlafzimmer";
|
||||
label = "Schlafzimmer Lampe";
|
||||
icon = "mdi:lightbulb-on";
|
||||
room = "bed_room";
|
||||
type = "light";
|
||||
};
|
||||
"pal03" = {
|
||||
label = "Wohnzimmer";
|
||||
label = "Wohnzimmer Lampe";
|
||||
icon = "mdi:lightbulb-on";
|
||||
room = "living_room";
|
||||
type = "light";
|
||||
};
|
||||
"pal04" = {
|
||||
label = "Wohnzimmer";
|
||||
label = "Wohnzimmer Lampe";
|
||||
icon = "mdi:lightbulb-on";
|
||||
room = "living_room";
|
||||
type = "light";
|
||||
};
|
||||
"pal05" = {
|
||||
label = "TV";
|
||||
icon = "mdi:television";
|
||||
room = "living_room";
|
||||
type = "device";
|
||||
device = "tv";
|
||||
};
|
||||
"pal06" = {
|
||||
label = "Küche";
|
||||
label = "Küchen Lampe";
|
||||
icon = "mdi:lightbulb-on";
|
||||
room = "kitchen_room";
|
||||
type = "light";
|
||||
};
|
||||
"pal07" = {
|
||||
label = "Nummer 7";
|
||||
|
@ -107,22 +120,24 @@ in {
|
|||
|
||||
# append to groups
|
||||
# ----------------
|
||||
group = {
|
||||
bed_room = { entities = builtins.map toSwitch [ "pal01" "pal02" ]; };
|
||||
living_room = { entities = builtins.map toSwitch [ "pal03" "pal04" ]; };
|
||||
tv = { entities = builtins.map toSwitch [ "pal05" ]; };
|
||||
kitchen = { entities = builtins.map toSwitch [ "pal06" ]; };
|
||||
unknown = { entities = builtins.map toSwitch [ "pal07" "pal08" ]; };
|
||||
all_lights = {
|
||||
entities = builtins.map toSwitch [
|
||||
"pal01"
|
||||
"pal02"
|
||||
"pal03"
|
||||
"pal04"
|
||||
"pal05"
|
||||
"pal06"
|
||||
];
|
||||
|
||||
group = let
|
||||
flatSonoffSwitches =
|
||||
lib.mapAttrsToList (name: values: { name = name; } // values)
|
||||
sonoffSwitches;
|
||||
allRooms' =
|
||||
lib.groupBy ({ room ? "unknown", ... }: room) flatSonoffSwitches;
|
||||
allRooms = lib.mapAttrs (_: devices: {
|
||||
entities = map ({ name, ... }: "switch.${name}") devices;
|
||||
}) allRooms';
|
||||
allLights' = lib.filter ({ type ? "unknown", ... }: type == "light")
|
||||
flatSonoffSwitches;
|
||||
allLights = {
|
||||
all_lights.entities = map ({ name, ... }: "switch.${name}") allLights';
|
||||
};
|
||||
in allRooms // allLights // {
|
||||
# this is a quick hack. it should not be the norm to define this stuff down here
|
||||
tv = { entities = builtins.map toSwitch [ "pal05" ]; };
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue