516 lines
13 KiB
Nix
516 lines
13 KiB
Nix
{
|
||
services.home-assistant.extraComponents = [
|
||
"deconz"
|
||
"shelly"
|
||
"sun"
|
||
"nanoleaf"
|
||
];
|
||
|
||
services.home-assistant.config = {
|
||
homeassistant = {
|
||
customize_domain = {
|
||
light = {
|
||
assumed_state = false;
|
||
};
|
||
};
|
||
};
|
||
customize_domain = {
|
||
light = {
|
||
assumed_state = false;
|
||
};
|
||
};
|
||
"automation light_sunrise" = {
|
||
alias = "light_sunrise";
|
||
trigger = {
|
||
platform = "sun";
|
||
event = "sunrise";
|
||
};
|
||
action = {
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "{{ states.light | selectattr(\"state\",\"eq\",\"on\") | map(attribute=\"entity_id\") | list }}";
|
||
};
|
||
data = {
|
||
brightness_pct = 254;
|
||
color_temp = 250;
|
||
};
|
||
};
|
||
};
|
||
"automation light_sunset" = {
|
||
alias = "light_sunset";
|
||
trigger = {
|
||
platform = "sun";
|
||
event = "sunset";
|
||
};
|
||
action = {
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "{{ states.light | selectattr(\"state\",\"eq\",\"on\") | map(attribute=\"entity_id\") | list }}";
|
||
};
|
||
data = {
|
||
brightness_pct = 30;
|
||
color_temp = 450;
|
||
};
|
||
};
|
||
};
|
||
"automation light_on" = {
|
||
alias = "light_on";
|
||
trigger = {
|
||
platform = "state";
|
||
entity_id = [
|
||
"light.bedroom_lights"
|
||
"light.kitchen_lights"
|
||
"light.livingroom_lights"
|
||
"light.hallway_lights"
|
||
"light.bathroom_lights"
|
||
"light.toilet_lights"
|
||
"light.storage_lights"
|
||
];
|
||
to = "on";
|
||
};
|
||
action = [
|
||
{
|
||
choose = [
|
||
{
|
||
conditions = [ "{{ is_state('automation.light_sunset', 'off') }}" ];
|
||
sequence = [
|
||
{
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "{{ trigger.entity_id }}";
|
||
};
|
||
data = {
|
||
brightness_pct = 100;
|
||
color_temp = 250;
|
||
};
|
||
}
|
||
];
|
||
}
|
||
{
|
||
conditions = [ "{{ state_attr('sun.sun', 'elevation') < 5 and trigger.entity_id == 'light.toilet_lights' }}" ];
|
||
sequence = [
|
||
{
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "{{ trigger.entity_id }}";
|
||
};
|
||
data = {
|
||
brightness_pct = 20;
|
||
color_temp = 450;
|
||
};
|
||
}
|
||
];
|
||
}
|
||
{
|
||
conditions = [ "{{ state_attr('sun.sun', 'elevation') < 5 and trigger.entity_id == 'light.hallway_lights' }}" ];
|
||
sequence = [
|
||
{
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "{{ trigger.entity_id }}";
|
||
};
|
||
data = {
|
||
brightness_pct = 30;
|
||
rgbw_color = [ 255 126 0 255 ];
|
||
};
|
||
}
|
||
];
|
||
}
|
||
{
|
||
conditions = [ "{{ state_attr('sun.sun', 'elevation') < 5 and trigger.entity_id == 'light.bathroom_lights' }}" ];
|
||
sequence = [
|
||
{
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "{{ trigger.entity_id }}";
|
||
};
|
||
data = {
|
||
brightness_pct = 30;
|
||
rgbw_color = [ 255 126 0 255 ];
|
||
};
|
||
}
|
||
];
|
||
}
|
||
{
|
||
conditions = [ "{{ state_attr('sun.sun', 'elevation') < 5 and trigger.entity_id == 'light.livingroom_lights' }}" ];
|
||
sequence = [
|
||
{
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "{{ trigger.entity_id }}";
|
||
};
|
||
data = {
|
||
brightness_pct = 30;
|
||
color_temp = 450;
|
||
};
|
||
}
|
||
];
|
||
}
|
||
{
|
||
conditions = [ "{{ state_attr('sun.sun', 'elevation') < 5 and trigger.entity_id == 'light.bedroom_lights' }}" ];
|
||
sequence = [
|
||
{
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "light.bedroom_lights";
|
||
};
|
||
data = {
|
||
brightness_pct = 20;
|
||
rgbw_color = [ 255 126 0 255 ];
|
||
};
|
||
}
|
||
];
|
||
}
|
||
{
|
||
conditions = [ "{{ state_attr('sun.sun', 'elevation') < 5 and trigger.entity_id == 'light.kitchen_lights' }}" ];
|
||
sequence = [
|
||
{
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "light.kitchen_lights";
|
||
};
|
||
data = {
|
||
brightness_pct = 30;
|
||
color_temp = 450;
|
||
};
|
||
}
|
||
];
|
||
}
|
||
{
|
||
conditions = [ "{{ state_attr('sun.sun', 'elevation') > 4 }}" ];
|
||
sequence = [
|
||
{
|
||
service = "light.turn_on";
|
||
target = {
|
||
entity_id = "{{ trigger.entity_id }}";
|
||
};
|
||
data = {
|
||
brightness_pct = 100;
|
||
color_temp = 250;
|
||
};
|
||
}
|
||
];
|
||
}
|
||
];
|
||
}
|
||
];
|
||
};
|
||
"automation bathroom light small" = {
|
||
alias = "bathroom light small";
|
||
mode = "restart";
|
||
trigger = {
|
||
platform = "state";
|
||
entity_id = [
|
||
"light.bathroom_switch_channel_1"
|
||
];
|
||
from = "on";
|
||
to = "off";
|
||
};
|
||
action = [
|
||
{
|
||
service = "switch.turn_off";
|
||
target = {
|
||
entity_id = "switch.bathroom_small";
|
||
};
|
||
}
|
||
];
|
||
};
|
||
"automation bathroom light" = {
|
||
alias = "bathroom light";
|
||
mode = "restart";
|
||
trigger = {
|
||
platform = "state";
|
||
entity_id = [
|
||
"light.bathroom_switch_channel_1"
|
||
];
|
||
from = "off";
|
||
to = "on";
|
||
};
|
||
action = [
|
||
{
|
||
delay = 3600;
|
||
}
|
||
{
|
||
service = "light.turn_off";
|
||
target = {
|
||
entity_id = "light.bathroom_switch_channel_1";
|
||
};
|
||
}
|
||
];
|
||
};
|
||
"automation bed_led" = {
|
||
alias = "bed_led";
|
||
mode = "restart";
|
||
trigger = {
|
||
platform = "state";
|
||
entity_id = [
|
||
"light.bedroom_led"
|
||
];
|
||
from = "off";
|
||
to = "on";
|
||
};
|
||
action = [
|
||
{
|
||
delay = 10800;
|
||
}
|
||
{
|
||
service = "light.turn_off";
|
||
target = {
|
||
entity_id = "{{ trigger.entity_id }}";
|
||
};
|
||
}
|
||
];
|
||
};
|
||
"automation hallway_motion" = {
|
||
alias = "Hallway Motion";
|
||
trigger = {
|
||
platform = "state";
|
||
entity_id = "binary_sensor.hallway_motion_motion";
|
||
};
|
||
action = {
|
||
service_template = "light.turn_{{ trigger.to_state.state }}";
|
||
target = {
|
||
entity_id = "light.hallway_lights";
|
||
};
|
||
};
|
||
};
|
||
"automation bedroom light" = {
|
||
alias = "bedroom light";
|
||
trigger = [
|
||
{
|
||
platform = "event";
|
||
event_type = "button_pressed";
|
||
event_data = {
|
||
id = [ 254 207 162 105 ];
|
||
which = 1;
|
||
onoff = 1;
|
||
pushed = 1;
|
||
};
|
||
}
|
||
{
|
||
platform = "event";
|
||
event_type = "shelly.click";
|
||
event_data = {
|
||
device = "shellybutton1-E8DB84AA136D";
|
||
click_type = "double";
|
||
};
|
||
}
|
||
];
|
||
action = [
|
||
{
|
||
service = "light.toggle";
|
||
target = {
|
||
entity_id = "light.bedroom_lights";
|
||
};
|
||
}
|
||
];
|
||
};
|
||
"automation bed light" = {
|
||
alias = "bed light";
|
||
trigger = [
|
||
{
|
||
platform = "event";
|
||
event_type = "button_pressed";
|
||
event_data = {
|
||
id = [ 254 207 162 105 ];
|
||
which = 0;
|
||
onoff = 1;
|
||
pushed = 1;
|
||
};
|
||
}
|
||
{
|
||
platform = "event";
|
||
event_type = "shelly.click";
|
||
event_data = {
|
||
device = "shellybutton1-E8DB84AA136D";
|
||
click_type = "triple";
|
||
};
|
||
}
|
||
];
|
||
action = [
|
||
{
|
||
service = "light.toggle";
|
||
target = {
|
||
entity_id = "light.bedroom_bed";
|
||
};
|
||
}
|
||
];
|
||
};
|
||
"automation reading 1 light" = {
|
||
alias = "reading 1 light";
|
||
trigger = [
|
||
{
|
||
platform = "event";
|
||
event_type = "button_pressed";
|
||
event_data = {
|
||
id = [ 254 207 162 105 ];
|
||
which = 0;
|
||
onoff = 0;
|
||
pushed = 1;
|
||
};
|
||
}
|
||
];
|
||
action = [
|
||
{
|
||
service = "light.toggle";
|
||
target = {
|
||
entity_id = "light.bed_reading_1";
|
||
};
|
||
}
|
||
];
|
||
};
|
||
"automation bed_button_2" = {
|
||
alias = "bed_button_2";
|
||
trigger = {
|
||
platform = "event";
|
||
event_type = "shelly.click";
|
||
event_data = {
|
||
device = "shellybutton1-E8DB84AA136D";
|
||
};
|
||
};
|
||
action = [
|
||
{
|
||
choose = [
|
||
{
|
||
conditions = [ "{{ trigger.event.data.click_type == \"single\" }}" ];
|
||
sequence = [
|
||
{
|
||
service = "light.toggle";
|
||
entity_id = "light.bed_reading_2";
|
||
}
|
||
];
|
||
}
|
||
];
|
||
}
|
||
];
|
||
};
|
||
light = [
|
||
{
|
||
platform = "switch";
|
||
name = "Livingroom Switch";
|
||
entity_id = "switch.livingroom_switch";
|
||
}
|
||
{
|
||
platform = "group";
|
||
name = "Livingroom Lights";
|
||
all = true;
|
||
entities = [
|
||
"light.livingroom_switch"
|
||
"light.living_room"
|
||
];
|
||
}
|
||
{
|
||
platform = "switch";
|
||
name = "Kitchen Switch";
|
||
entity_id = "switch.kitchen_switch";
|
||
}
|
||
{
|
||
platform = "group";
|
||
name = "Kitchen Lights";
|
||
all = true;
|
||
entities = [
|
||
"light.kitchen_switch"
|
||
"light.kitchen"
|
||
];
|
||
}
|
||
{
|
||
platform = "switch";
|
||
name = "Bedroom Switch";
|
||
entity_id = "switch.bedroom_switch";
|
||
}
|
||
{
|
||
platform = "group";
|
||
name = "Bedroom Lights";
|
||
all = true;
|
||
entities = [
|
||
"light.bedroom_switch"
|
||
"light.bedroom_bulb_1"
|
||
"light.bedroom_bulb_2"
|
||
"light.bedroom_bulb_3"
|
||
"light.bedroom_bulb_4"
|
||
];
|
||
}
|
||
{
|
||
platform = "group";
|
||
name = "Bathroom Lights";
|
||
all = true;
|
||
entities = [
|
||
"light.bathroom_switch"
|
||
"light.bathroom_bulb_1"
|
||
"light.bathroom_bulb_2"
|
||
];
|
||
}
|
||
{
|
||
platform = "group";
|
||
name = "Hallway Lights";
|
||
all = true;
|
||
entities = [
|
||
"light.hallway_light_switch_mini_switch"
|
||
"light.hallway_bulb_1"
|
||
"light.hallway_bulb_2"
|
||
];
|
||
}
|
||
{
|
||
platform = "template";
|
||
lights = {
|
||
hallway_group_proxy = {
|
||
friendly_name = "Hallway Lights (Proxy)";
|
||
# follow the real group’s on/off state
|
||
value_template = "{{ is_state('light.hallway_lights','on') }}";
|
||
turn_on = {
|
||
service = "light.turn_on";
|
||
data = { entity_id = "light.hallway_lights"; };
|
||
};
|
||
turn_off = {
|
||
service = "light.turn_off";
|
||
data = { entity_id = "light.hallway_lights"; };
|
||
};
|
||
# brightness support
|
||
set_level = {
|
||
service = "light.turn_on";
|
||
data_template = {
|
||
entity_id = "light.hallway_lights";
|
||
brightness = "{{ brightness }}";
|
||
};
|
||
};
|
||
# color temperature support (if you have CT-capable bulbs)
|
||
set_temperature = {
|
||
service = "light.turn_on";
|
||
data_template = {
|
||
entity_id = "light.hallway_lights";
|
||
color_temp = "{{ color_temp }}";
|
||
};
|
||
};
|
||
# RGB color support
|
||
set_color = {
|
||
service = "light.turn_on";
|
||
data_template = {
|
||
entity_id = "light.hallway_lights";
|
||
rgb_color = [ "{{ red }}" "{{ green }}" "{{ blue }}" ];
|
||
};
|
||
};
|
||
# always report as “available”
|
||
availability_template = "true";
|
||
# declare which color modes you need
|
||
supported_color_modes = [ "brightness" "color_temp" "rgb" ];
|
||
};
|
||
};
|
||
}
|
||
{
|
||
platform = "switch";
|
||
name = "Toilet Switch";
|
||
entity_id = "switch.toilet";
|
||
}
|
||
{
|
||
platform = "group";
|
||
name = "Toilet Lights";
|
||
all = true;
|
||
entities = [
|
||
"light.toilet_switch"
|
||
"light.toilet_bulb"
|
||
];
|
||
}
|
||
];
|
||
};
|
||
}
|