Skip to content

Commit

Permalink
home-assistant: migrate configuration to rpi5
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMagee committed Dec 27, 2024
1 parent 68464eb commit 727197e
Show file tree
Hide file tree
Showing 19 changed files with 1,519 additions and 2 deletions.
145 changes: 145 additions & 0 deletions hosts/rpi5/services/home-assistant/abode.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
services.home-assistant = {
extraComponents = [ "abode" ];

config = {
binary_sensor = [
{
platform = "group";
name = "Doors";
entities = [
"binary_sensor.front_door"
"binary_sensor.balcony_door"
"binary_sensor.garage_door"
];
}
{
platform = "group";
name = "Windows";
entities = [ "binary_sensor.front_window" ];
}
];

automation = [
{
alias = "Notify on alarm change";
id = "alarm_state_change";
triggers = [
{
trigger = "state";
entity_id = "alarm_control_panel.abode_alarm";
not_from = [
"unknown"
"unavailable"
];
to = null;
}
];
condition = {
not = [
{
condition = "state";
entity_id = "alarm_control_panel.abode_alarm";
state = "unavailable";
}
];
};

actions = [
{
action = "notify.everyone";
data = {
title = "Alarm";
message = ''
{%- if is_state("alarm_control_panel.abode_alarm", "armed_away") -%}
No-one is home. The alarm is armed
{%- elif is_state("alarm_control_panel.abode_alarm", "disarmed") -%}
Alarm disabled
{%- elif is_state("alarm_control_panel.abode_alarm", "armed_home") -%}
The alarm is armed home.
{%- endif %}
'';
};
}
];
}
{
alias = "Arm alarm at night";
id = "arm_alarm_night";
triggers = [
{
trigger = "time";
at = "22:00:00";
}
];
conditions = [
{
condition = "state";
entity_id = [
"person.jamie"
"person.kat"
];
state = "home";
}
];
actions = [
{
action = "alarm_control_panel.alarm_arm_home";
entity_id = "alarm_control_panel.abode_alarm";
}
];
}
{
alias = "Arm alarm when no-one home";
id = "arm_alarm_no_one_home";
triggers = [
{
trigger = "state";
entity_id = "zone.home";
to = "0";
for = {
minutes = 1;
};
}
];
actions = [
{
action = "alarm_control_panel.alarm_arm_away";
entity_id = "alarm_control_panel.abode_alarm";
}
];
}
{
alias = "Disarm alarm in the morning";
id = "disarm_alarm_morning";
triggers = [
{
trigger = "time";
at = "sensor.kat_s_pixel_next_alarm";
}
{
trigger = "time";
at = "sensor.jamie_pixel_8a_next_alarm";
}
];
conditions = [
{
condition = "zone";
entity_id = [
"person.jamie"
"person.kat"
];
zone = "zone.home";
}
];
actions = [
{
action = "alarm_control_panel.alarm_disarm";
entity_id = "alarm_control_panel.abode_alarm";
}
];
}
];
};
};
}
14 changes: 14 additions & 0 deletions hosts/rpi5/services/home-assistant/backup.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
services.home-assistant.config.automation = [
{
alias = "Backup Home Assistant daily";
triggers = {
trigger = "time";
at = "03:00:00";
};
actions = {
action = "backup.create";
};
}
];
}
186 changes: 186 additions & 0 deletions hosts/rpi5/services/home-assistant/blinds.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{ lib, ... }:
{
services.home-assistant.config = {
cover = [
{
platform = "group";
name = "All blinds";
entities = [
"cover.homelab_zone_living_room_big_shade"
"cover.homelab_zone_living_room_small_shade"
"cover.homelab_zone_kitchen_shade"
"cover.homelab_zone_bedroom_big_shade"
"cover.homelab_zone_bedroom_small_shade"
"cover.homelab_zone_office_shade"
"cover.homelab_zone_bathroom_big_shade"
"cover.homelab_zone_bathroom_small_shade"
"cover.homelab_zone_upstairs_hallway_shade"
];
}
{
platform = "group";
name = "Downstairs blinds";
entities = [
"cover.homelab_zone_living_room_big_shade"
"cover.homelab_zone_living_room_small_shade"
"cover.homelab_zone_kitchen_shade"
];
}
{
platform = "group";
name = "Upstairs blinds";
entities = [
"cover.homelab_zone_bedroom_big_shade"
"cover.homelab_zone_bedroom_small_shade"
"cover.homelab_zone_office_shade"
"cover.homelab_zone_bathroom_big_shade"
"cover.homelab_zone_bathroom_small_shade"
"cover.homelab_zone_upstairs_hallway_shade"
];
}
{
platform = "group";
name = "Bedroom blinds";
entities = [
"cover.homelab_zone_bedroom_big_shade"
"cover.homelab_zone_bedroom_small_shade"
];
}
{
platform = "group";
name = "Bathroom blinds";
entities = [
"cover.homelab_zone_bathroom_big_shade"
"cover.homelab_zone_bathroom_small_shade"
];
}
];

scene = [
{
name = "Downstairs blinds daytime";
icon = "mdi:blinds";
entities = {
"cover.homelab_zone_living_room_big_shade" = {
current_position = 2;
state = "open";
};
"cover.homelab_zone_living_room_small_shade" = {
current_position = 2;
state = "open";
};
"cover.homelab_zone_kitchen_shade" = {
current_position = 4;
state = "open";
};
};
}
{
name = "Upstairs blinds daytime";
icon = "mdi:blinds";
entities =
lib.genAttrs
[
"cover.homelab_zone_office_shade"
"cover.homelab_zone_bathroom_big_shade"
"cover.homelab_zone_bathroom_small_shade"
"cover.homelab_zone_upstairs_hallway_shade"
]
(_: {
current_position = 100;
state = "open";
});
}
{
name = "Morning blinds";
icon = "mdi:blinds";
entities =
lib.genAttrs
[
"cover.homelab_zone_bathroom_big_shade"
"cover.homelab_zone_bathroom_small_shade"
"cover.homelab_zone_upstairs_hallway_shade"
]
(_: {
current_position = 100;
state = "open";
});
}
];

automation = [
{
alias = "Close blinds at sunset";
id = "close_blinds_sunset";
triggers = [
{
trigger = "sun";
event = "sunset";
}
{
trigger = "time";
at = "18:00:00";
}
];
actions = [
{
action = "cover.close_cover";
entity_id = "cover.all_blinds";
}
];
}
{
alias = "Close blinds when no-one home";
id = "close_blinds_no_one_home";
triggers = [
{
trigger = "state";
entity_id = "zone.home";
to = "0";
for = {
minutes = 1;
};
}
];
actions = [
{
action = "cover.close_cover";
entity_id = "cover.all_blinds";
}
];
}
{
alias = "Open blinds in the morning";
id = "open_blinds_morning";
triggers = [
{
trigger = "time";
at = "sensor.kat_s_pixel_next_alarm";
}
{
trigger = "time";
at = "sensor.jamie_pixel_8a_next_alarm";
}
];
conditions = [
{
condition = "zone";
entity_id = [
"person.jamie"
"person.kat"
];
zone = "zone.home";
}
];
actions = [
{
action = "scene.turn_on";
target = {
entity_id = "scene.morning_blinds";
};
}
];
}
];
};
}
8 changes: 8 additions & 0 deletions hosts/rpi5/services/home-assistant/cloud.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
services.home-assistant = {
extraComponents = [ "cloud" ];
config = {
cloud = { };
};
};
}
26 changes: 26 additions & 0 deletions hosts/rpi5/services/home-assistant/default-config.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
services.home-assistant.config = {
# https://www.home-assistant.io/integrations/default_config/
assist_pipeline = { };
backup = { };
# bluetooth = { };
config = { };
conversation = { };
dhcp = { };
energy = { };
# go2rtc = { };
history = { };
homeassistant_alerts = { };
image_upload = { };
logbook = { };
media_source = { };
mobile_app = { };
my = { };
ssdp = { };
stream = { };
sun = { };
usb = { };
webhook = { };
zeroconf = { };
};
}
Loading

0 comments on commit 727197e

Please sign in to comment.