hass: instantly change situation changes now
This commit is contained in:
parent
8bad618631
commit
0e2afa4fd1
1 changed files with 89 additions and 4 deletions
|
@ -52,7 +52,9 @@ in {
|
||||||
|
|
||||||
automation = let
|
automation = let
|
||||||
|
|
||||||
# todo : at night only turn trigger essential groups
|
allRooms =
|
||||||
|
[ "living_room" "floor_room" "bath_room" "bed_room" "kitchen_room" ];
|
||||||
|
|
||||||
roomPresents = {
|
roomPresents = {
|
||||||
# group of the room that should be turned on
|
# group of the room that should be turned on
|
||||||
roomGroup,
|
roomGroup,
|
||||||
|
@ -117,6 +119,74 @@ in {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
situationSwitch = { fromRoomGroup, toRoomGroup, presentsGroup
|
||||||
|
, fromSituation, toSituation,
|
||||||
|
# brightness for dimable lights
|
||||||
|
brightness ? 255 }: [
|
||||||
|
{
|
||||||
|
alias =
|
||||||
|
"${fromSituation} -> ${toSituation} for ${fromRoomGroup} -> ${toRoomGroup} on";
|
||||||
|
trigger = {
|
||||||
|
platform = "state";
|
||||||
|
entity_id = "input_select.situation";
|
||||||
|
from = fromSituation;
|
||||||
|
to = toSituation;
|
||||||
|
};
|
||||||
|
condition = {
|
||||||
|
condition = "state";
|
||||||
|
entity_id = "group.${presentsGroup}";
|
||||||
|
state = "on";
|
||||||
|
};
|
||||||
|
action = [
|
||||||
|
{
|
||||||
|
service = "switch.turn_off";
|
||||||
|
data.entity_id = "group.${fromRoomGroup}";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
service = "light.turn_off";
|
||||||
|
data.entity_id = "group.${fromRoomGroup}";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
service = "switch.turn_on";
|
||||||
|
data.entity_id = "group.${toRoomGroup}";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
service = "light.turn_on";
|
||||||
|
data = {
|
||||||
|
entity_id = "group.${toRoomGroup}";
|
||||||
|
brightness = brightness;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
alias =
|
||||||
|
"${fromSituation} -> ${toSituation} for ${fromRoomGroup} -> ${toRoomGroup} off";
|
||||||
|
trigger = {
|
||||||
|
platform = "state";
|
||||||
|
entity_id = "input_select.situation";
|
||||||
|
from = fromSituation;
|
||||||
|
to = toSituation;
|
||||||
|
};
|
||||||
|
condition = {
|
||||||
|
condition = "state";
|
||||||
|
entity_id = "group.${presentsGroup}";
|
||||||
|
state = "off";
|
||||||
|
};
|
||||||
|
action = [
|
||||||
|
{
|
||||||
|
service = "switch.turn_off";
|
||||||
|
data.entity_id = "group.${fromRoomGroup}";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
service = "light.turn_off";
|
||||||
|
data.entity_id = "group.${fromRoomGroup}";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
in lib.flatten (map roomPresents (lib.flatten (map (name: [
|
in lib.flatten (map roomPresents (lib.flatten (map (name: [
|
||||||
{
|
{
|
||||||
roomGroup = "${name}_lights";
|
roomGroup = "${name}_lights";
|
||||||
|
@ -130,8 +200,7 @@ in {
|
||||||
situation = "essential";
|
situation = "essential";
|
||||||
brightness = 30;
|
brightness = 30;
|
||||||
}
|
}
|
||||||
]) [ "living_room" "floor_room" "bath_room" "bed_room" "kitchen_room" ])))
|
]) allRooms))) ++ [
|
||||||
++ [
|
|
||||||
|
|
||||||
# control situation with buttons
|
# control situation with buttons
|
||||||
{
|
{
|
||||||
|
@ -166,7 +235,23 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
] ++ (lib.flatten (map situationSwitch (lib.flatten (map (name: [
|
||||||
|
{
|
||||||
|
presentsGroup = "${name}_present";
|
||||||
|
fromSituation = "dark";
|
||||||
|
toSituation = "essential";
|
||||||
|
fromRoomGroup = "${name}_lights";
|
||||||
|
toRoomGroup = "${name}_essential";
|
||||||
|
brightness = 30;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
presentsGroup = "${name}_present";
|
||||||
|
fromSituation = "essential";
|
||||||
|
toSituation = "dark";
|
||||||
|
fromRoomGroup = "${name}_essential";
|
||||||
|
toRoomGroup = "${name}_lights";
|
||||||
|
}
|
||||||
|
]) allRooms))));
|
||||||
|
|
||||||
group = let
|
group = let
|
||||||
create_room = { name, description }: {
|
create_room = { name, description }: {
|
||||||
|
|
Loading…
Reference in a new issue