pepe: home-assistant refactoring

This commit is contained in:
Ingolf Wagner 2020-04-12 21:05:55 +02:00
parent 55bf10631d
commit aad74d7393
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 67 additions and 45 deletions

View file

@ -59,27 +59,54 @@ in {
]; ];
group = { group = {
# rooms
# -----
bed_room = { bed_room = {
name = "Schlafzimmer"; name = "Schlafzimmer";
view = false; view = false;
}; };
tv = {
name = "TV";
view = false;
};
living_room = { living_room = {
name = "Wohnzimmer"; name = "Wohnzimmer";
view = false; view = false;
}; };
kitchen = { kitchen_room = {
name = "Küche"; name = "Küche";
view = false; 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 = { today = {
control = "hidden"; control = "hidden";
name = "Today"; name = "Today";
view = false; view = false;
}; };
view_overview = {
name = "Übersicht";
view = true;
entities = [ "group.today" "group.all_sensors" ];
};
# other stuff
# -----------
tv = {
name = "TV";
view = false;
};
all_lights = { all_lights = {
name = "All Lights"; name = "All Lights";
view = false; view = false;
@ -89,26 +116,6 @@ in {
name = "Not Used"; name = "Not Used";
view = false; 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";
};
}; };

View file

@ -3,28 +3,41 @@ let
sonoffSwitches = { sonoffSwitches = {
"pal01" = { "pal01" = {
label = "Schlafzimmer"; label = "Schlafzimmer Lampe";
icon = "mdi:lightbulb-on"; icon = "mdi:lightbulb-on";
room = "bed_room";
type = "light";
}; };
"pal02" = { "pal02" = {
label = "Schlafzimmer"; label = "Schlafzimmer Lampe";
icon = "mdi:lightbulb-on"; icon = "mdi:lightbulb-on";
room = "bed_room";
type = "light";
}; };
"pal03" = { "pal03" = {
label = "Wohnzimmer"; label = "Wohnzimmer Lampe";
icon = "mdi:lightbulb-on"; icon = "mdi:lightbulb-on";
room = "living_room";
type = "light";
}; };
"pal04" = { "pal04" = {
label = "Wohnzimmer"; label = "Wohnzimmer Lampe";
icon = "mdi:lightbulb-on"; icon = "mdi:lightbulb-on";
room = "living_room";
type = "light";
}; };
"pal05" = { "pal05" = {
label = "TV"; label = "TV";
icon = "mdi:television"; icon = "mdi:television";
room = "living_room";
type = "device";
device = "tv";
}; };
"pal06" = { "pal06" = {
label = "Küche"; label = "Küchen Lampe";
icon = "mdi:lightbulb-on"; icon = "mdi:lightbulb-on";
room = "kitchen_room";
type = "light";
}; };
"pal07" = { "pal07" = {
label = "Nummer 7"; label = "Nummer 7";
@ -107,22 +120,24 @@ in {
# append to groups # append to groups
# ---------------- # ----------------
group = {
bed_room = { entities = builtins.map toSwitch [ "pal01" "pal02" ]; }; group = let
living_room = { entities = builtins.map toSwitch [ "pal03" "pal04" ]; }; flatSonoffSwitches =
tv = { entities = builtins.map toSwitch [ "pal05" ]; }; lib.mapAttrsToList (name: values: { name = name; } // values)
kitchen = { entities = builtins.map toSwitch [ "pal06" ]; }; sonoffSwitches;
unknown = { entities = builtins.map toSwitch [ "pal07" "pal08" ]; }; allRooms' =
all_lights = { lib.groupBy ({ room ? "unknown", ... }: room) flatSonoffSwitches;
entities = builtins.map toSwitch [ allRooms = lib.mapAttrs (_: devices: {
"pal01" entities = map ({ name, ... }: "switch.${name}") devices;
"pal02" }) allRooms';
"pal03" allLights' = lib.filter ({ type ? "unknown", ... }: type == "light")
"pal04" flatSonoffSwitches;
"pal05" allLights = {
"pal06" 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" ]; };
}; };
}; };