pepe: control situations
This commit is contained in:
parent
b7b7f1f2b3
commit
afd0a285cd
3 changed files with 128 additions and 43 deletions
|
@ -33,72 +33,154 @@ in {
|
|||
|
||||
prometheus.namespace = "hass";
|
||||
|
||||
input_select.situation = {
|
||||
icon = "mdi:brightness-auto";
|
||||
options = [ "on" "off" "essential" ];
|
||||
};
|
||||
input_boolean.bed_room_buttons.icon = "mdi:toggle-switch";
|
||||
input_boolean.situation_toggle.icon = "mdi:toggle-switch";
|
||||
|
||||
automation = let
|
||||
# todo : at night only turn trigger essential groups
|
||||
roomPresents = { roomGroup, presentsGroup }: [
|
||||
{
|
||||
alias = "presents -> turn on ${roomGroup} lights";
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "group.${presentsGroup}";
|
||||
from = "off";
|
||||
to = "on";
|
||||
};
|
||||
action = [
|
||||
{
|
||||
service = "switch.turn_on";
|
||||
entity_id = "group.${roomGroup}";
|
||||
}
|
||||
{
|
||||
service = "light.turn_on";
|
||||
entity_id = "group.${roomGroup}";
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
alias = "absents -> turn off ${roomGroup} lights";
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "group.${presentsGroup}";
|
||||
from = "on";
|
||||
to = "off";
|
||||
};
|
||||
action = [
|
||||
{
|
||||
service = "switch.turn_off";
|
||||
entity_id = "group.${roomGroup}";
|
||||
}
|
||||
{
|
||||
service = "light.turn_off";
|
||||
entity_id = "group.${roomGroup}";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
roomPresents =
|
||||
{ roomGroup, presentsGroup, situation, brightness ? 255 }: [
|
||||
{
|
||||
alias = "presents -> turn on ${roomGroup} lights";
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "group.${presentsGroup}";
|
||||
from = "off";
|
||||
to = "on";
|
||||
};
|
||||
condition = {
|
||||
condition = "state";
|
||||
entity_id = "input_select.situation";
|
||||
state = situation;
|
||||
};
|
||||
action = [
|
||||
{
|
||||
service = "switch.turn_on";
|
||||
data.entity_id = "group.${roomGroup}";
|
||||
}
|
||||
{
|
||||
service = "light.turn_on";
|
||||
data = {
|
||||
entity_id = "group.${roomGroup}";
|
||||
brightness = brightness;
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
alias = "absents -> turn off ${roomGroup} lights";
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "group.${presentsGroup}";
|
||||
from = "on";
|
||||
to = "off";
|
||||
};
|
||||
action = [
|
||||
{
|
||||
service = "switch.turn_off";
|
||||
data.entity_id = "group.${roomGroup}";
|
||||
}
|
||||
{
|
||||
service = "light.turn_off";
|
||||
data.entity_id = "group.${roomGroup}";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
in lib.flatten (map roomPresents [
|
||||
{
|
||||
roomGroup = "kitchen_room_lights";
|
||||
presentsGroup = "kitchen_room_present";
|
||||
situation = "on";
|
||||
}
|
||||
{
|
||||
roomGroup = "living_room_lights";
|
||||
presentsGroup = "living_room_present";
|
||||
situation = "on";
|
||||
}
|
||||
{
|
||||
roomGroup = "floor_room_lights";
|
||||
presentsGroup = "floor_room_present";
|
||||
situation = "on";
|
||||
}
|
||||
{
|
||||
roomGroup = "bath_room_lights";
|
||||
presentsGroup = "bath_room_present";
|
||||
situation = "on";
|
||||
}
|
||||
{
|
||||
roomGroup = "bed_room_lights";
|
||||
presentsGroup = "bed_room_present";
|
||||
situation = "on";
|
||||
}
|
||||
]);
|
||||
{
|
||||
roomGroup = "kitchen_room_essentials";
|
||||
presentsGroup = "kitchen_room_present";
|
||||
situation = "essential";
|
||||
brightness = 30;
|
||||
}
|
||||
{
|
||||
roomGroup = "living_room_essential";
|
||||
presentsGroup = "living_room_present";
|
||||
situation = "essential";
|
||||
brightness = 30;
|
||||
}
|
||||
{
|
||||
roomGroup = "floor_room_essential";
|
||||
presentsGroup = "floor_room_present";
|
||||
situation = "essential";
|
||||
brightness = 30;
|
||||
}
|
||||
{
|
||||
roomGroup = "bath_room_essential";
|
||||
presentsGroup = "bath_room_present";
|
||||
situation = "essential";
|
||||
brightness = 30;
|
||||
}
|
||||
{
|
||||
roomGroup = "bed_room_essential";
|
||||
presentsGroup = "bed_room_present";
|
||||
situation = "essential";
|
||||
brightness = 30;
|
||||
}
|
||||
]) ++ [
|
||||
{
|
||||
alias = "set essential";
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "input_boolean.situation_toggle";
|
||||
from = "off";
|
||||
to = "on";
|
||||
};
|
||||
action = {
|
||||
service = "input_select.select_option";
|
||||
data = {
|
||||
entity_id = "input_select.situation";
|
||||
option = "essential";
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
alias = "unset essential";
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "input_boolean.situation_toggle";
|
||||
from = "on";
|
||||
to = "off";
|
||||
};
|
||||
action = {
|
||||
service = "input_select.select_option";
|
||||
data = {
|
||||
entity_id = "input_select.situation";
|
||||
option = "on";
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
group = let
|
||||
create_room = { name, description }: {
|
||||
|
@ -133,7 +215,6 @@ in {
|
|||
"group.${name}_lights"
|
||||
"group.${name}_present"
|
||||
"group.${name}_essential"
|
||||
"group.${name}_essential_present"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
@ -185,6 +266,7 @@ in {
|
|||
control = "hidden";
|
||||
name = "Today";
|
||||
view = false;
|
||||
entities = [ "input_select.situation" ];
|
||||
};
|
||||
view_overview = {
|
||||
name = "Übersicht";
|
||||
|
|
|
@ -13,16 +13,19 @@ let
|
|||
id = "0x00158d0002b04f65";
|
||||
# states = { click = "input_boolean.living_room_button"; } # input state to hold (optional) (default "input_boolean.single_${name}")
|
||||
groups = [ "living_room" "living_room_present" ];
|
||||
states.double = "input_boolean.situation_toggle";
|
||||
};
|
||||
"button_2" = {
|
||||
id = "0x00158d0002b04f09";
|
||||
groups = [ "bed_room" "bed_room_present" ];
|
||||
states.single = "input_boolean.bed_room_buttons";
|
||||
states.double = "input_boolean.situation_toggle";
|
||||
};
|
||||
"button_3" = {
|
||||
id = "0x00158d0002b00e04";
|
||||
groups = [ "bed_room" "bed_room_present" ];
|
||||
states.single = "input_boolean.bed_room_buttons";
|
||||
states.double = "input_boolean.situation_toggle";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ let
|
|||
};
|
||||
"light_3" = {
|
||||
id = "0x7cb03eaa0a033a86";
|
||||
groups = [ "living_room" "living_room_lights" ];
|
||||
groups = [ "living_room" "living_room_essential" "living_room_lights" ];
|
||||
};
|
||||
"light_4" = {
|
||||
id = "0x7cb03eaa0a04aabf";
|
||||
|
|
Loading…
Reference in a new issue