add home-assistant nix configuration
This commit is contained in:
46
hosts/fw.cloonar.com/modules/home-assistant/pc.nix
Normal file
46
hosts/fw.cloonar.com/modules/home-assistant/pc.nix
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
services.home-assistant.config = {
|
||||
"automation pc_switch" = {
|
||||
alias = "switch pc";
|
||||
hide_entity = true;
|
||||
trigger = {
|
||||
platform = "event";
|
||||
event_type = "button_pressed";
|
||||
event_data = {
|
||||
id = [ 254 235 105 198 ];
|
||||
};
|
||||
};
|
||||
action = {
|
||||
service_template = "switch.turn_on";
|
||||
data_template = {
|
||||
entity_id = "switch.computer";
|
||||
};
|
||||
};
|
||||
};
|
||||
"automation pc power" = {
|
||||
alias = "auto pc power off";
|
||||
hide_entity = true;
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "sensor.computer_power";
|
||||
};
|
||||
condition = {
|
||||
condition = "and";
|
||||
conditions = [
|
||||
{
|
||||
condition = "numeric_state";
|
||||
entity_id = "sensor.computer_power";
|
||||
below = 15;
|
||||
}
|
||||
"{{ (as_timestamp(now()) - as_timestamp(states.switch.computer.last_changed)) > 300 }}"
|
||||
];
|
||||
};
|
||||
action = {
|
||||
service = "switch.turn_off";
|
||||
target = {
|
||||
entity_id = [ "switch.computer" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user