Files
nixos/hosts/fw/modules/home-assistant/sleep.nix
2025-08-01 19:48:49 +02:00

96 lines
2.2 KiB
Nix

{
services.home-assistant.config = {
"automation wakeup" = {
alias = "wakeup";
trigger = {
platform = "time";
at = "input_datetime.wakeup";
};
action = [
{
delay = 1700;
}
{
service = "script.turn_on";
target = {
entity_id = "script.turn_on_circuits";
};
}
];
};
"automation sleep" = {
alias = "sleep";
trigger = [
{
platform = "event";
event_type = "button_pressed";
event_data = {
id = [ 254 207 162 105 ];
which = 1;
onoff = 0;
pushed = 1;
};
}
];
action = [
{
service = "script.turn_on";
target = {
entity_id = "script.turn_off_everything";
};
}
];
};
script = {
turn_off_everything = {
sequence = [
{
service = "light.turn_off";
entity_id = "all";
}
# {
# service = "switch.turn_off";
# entity_id = "switch.78_8c_b5_fe_41_62_port_2_poe";
# }
# {
# service = "switch.turn_off";
# entity_id = "switch.78_8c_b5_fe_41_62_port_3_poe";
# }
# {
# service = "switch.turn_off";
# entity_id = "switch.hallway_circuit";
# }
# TODO: needs to stay on because phone is not loading otherwise
# {
# service = "switch.turn_off";
# entity_id = "switch.bathroom_circuit";
# }
];
};
turn_on_circuits = {
sequence = [
{
service = "switch.turn_on";
entity_id = "switch.bathroom_circuit";
}
{
delay = 60;
}
{
service = "switch.turn_on";
entity_id = "switch.hallway_circuit";
}
{
service = "switch.turn_on";
entity_id = "switch.78_8c_b5_fe_41_62_port_2_poe";
}
{
service = "switch.turn_on";
entity_id = "switch.78_8c_b5_fe_41_62_port_3_poe";
}
];
};
};
};
}