mirror of
https://git.sr.ht/~magic_rb/cluster
synced 2024-11-24 00:56:16 +01:00
Add initial CCTV to home assistant
Signed-off-by: main <magic_rb@redalder.org> Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
parent
48b9a5c073
commit
5b85429327
|
@ -58,6 +58,13 @@
|
|||
coreutils git ffmpeg bash runit
|
||||
];
|
||||
};
|
||||
ensureSomething.create."media" = {
|
||||
type = "directory";
|
||||
mode = "755";
|
||||
owner = "home-assistant";
|
||||
dst = "/media";
|
||||
persistent = true;
|
||||
};
|
||||
};
|
||||
|
||||
services.home-assistant = {
|
||||
|
@ -87,18 +94,40 @@
|
|||
unit_system = "metric";
|
||||
time_zone = "\${TIME_ZONE}";
|
||||
internal_url = "http://localhost:8123/";
|
||||
whitelist_external_dirs = [
|
||||
"/mnt/cctv"
|
||||
];
|
||||
media_dirs = {
|
||||
local = "/mnt/cctv";
|
||||
};
|
||||
};
|
||||
automation = "!include automations.yaml";
|
||||
"automation static" = [
|
||||
(import ./home-assistant/automations/alarm/pending.nix)
|
||||
(import ./home-assistant/automations/alarm/disarmed.nix)
|
||||
(import ./home-assistant/automations/alarm/triggered.nix)
|
||||
(import ./home-assistant/automations/alarm/retriggered.nix)
|
||||
(import ./home-assistant/automations/alarm/motion-detected.nix)
|
||||
(import ./home-assistant/automations/alarm/motion-detected-away.nix)
|
||||
];
|
||||
alarm_control_panel = import ./home-assistant/alarm_control_panel.nix;
|
||||
frontend.themes =
|
||||
{ };
|
||||
sensor = [
|
||||
{
|
||||
platform = "time_date";
|
||||
display_options = [
|
||||
"time"
|
||||
"date"
|
||||
"date_time"
|
||||
"date_time_utc"
|
||||
"date_time_iso"
|
||||
"time_date"
|
||||
"time_utc"
|
||||
"beat"
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
package =
|
||||
(pkgs.home-assistant.override
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
code = "\${ALARM_CODE}";
|
||||
code_arm_required = false; # Don't need code to arm.
|
||||
disarm_after_trigger = false; # Leave alarm armed after triggering.
|
||||
arming_time = 30; # Time to leave the house after arming.
|
||||
delay_time = 60; # Time to turn off after entering the house.
|
||||
trigger_time = 600; # How long the alarm goes off for.
|
||||
arming_time = 0; # Time to leave the house after arming.
|
||||
delay_time = 30; # Time to turn off after entering the house.
|
||||
trigger_time = 3600; # How long the alarm goes off for.
|
||||
disarmed = {
|
||||
trigger_time = 0; # Can't be triggered when disarmed.
|
||||
};
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
{
|
||||
data = {
|
||||
message = "Alarm Disarmed";
|
||||
data = {
|
||||
channel = "Motion";
|
||||
importance = "high";
|
||||
};
|
||||
};
|
||||
service = "notify.mobile_app_redrum";
|
||||
}
|
||||
|
|
|
@ -2,11 +2,18 @@
|
|||
alias = "Alarm - Trigger when motion detected - Away";
|
||||
id = "b16e988f-2ee0-4596-a14d-0fda1a95ac2d";
|
||||
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "binary_sensor.motion_sensor_occupancy";
|
||||
to = "on";
|
||||
};
|
||||
trigger = [
|
||||
{
|
||||
platform = "state";
|
||||
entity_id = "binary_sensor.motion_sensor_occupancy";
|
||||
to = "on";
|
||||
}
|
||||
{
|
||||
platform = "state";
|
||||
entity_id = "binary_sensor.sensor_entry_door_contact";
|
||||
to = "on";
|
||||
}
|
||||
];
|
||||
condition = {
|
||||
condition = "or";
|
||||
conditions = [
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
{
|
||||
alias = "Alarm - Trigger when motion detected - Home/Away";
|
||||
alias = "Alarm - Trigger when motion detected - Home";
|
||||
id = "972bccd8-a68c-48fc-ac90-ebbeb87c64b9";
|
||||
|
||||
trigger = {
|
||||
platform = "state";
|
||||
entity_id = "binary_sensor.sensor_entry_door_contact";
|
||||
to = "on";
|
||||
};
|
||||
trigger = [
|
||||
{
|
||||
platform = "state";
|
||||
entity_id = "binary_sensor.sensor_entry_door_contact";
|
||||
to = "on";
|
||||
}
|
||||
];
|
||||
condition = {
|
||||
condition = "or";
|
||||
conditions = [
|
||||
|
@ -15,11 +17,6 @@
|
|||
entity_id = "alarm_control_panel.home_alarm";
|
||||
state = "armed_home";
|
||||
}
|
||||
{
|
||||
condition = "state";
|
||||
entity_id = "alarm_control_panel.home_alarm";
|
||||
state = "armed_away";
|
||||
}
|
||||
];
|
||||
};
|
||||
action = [
|
||||
|
|
|
@ -12,7 +12,13 @@
|
|||
];
|
||||
action = [
|
||||
{
|
||||
data = { message = "Alarm Pending - Intruder Detected!"; };
|
||||
data = {
|
||||
message = "Alarm Pending - Intruder Detected!";
|
||||
data = {
|
||||
channel = "Motion";
|
||||
importance = "high";
|
||||
};
|
||||
};
|
||||
service = "notify.mobile_app_redrum";
|
||||
}
|
||||
];
|
||||
|
|
35
containers/home-assistant/automations/alarm/retriggered.nix
Normal file
35
containers/home-assistant/automations/alarm/retriggered.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
alias = "Alarm - ReTriggered";
|
||||
id = "2f4942bc-3538-4888-bc52-84171e0b040f";
|
||||
|
||||
trigger = [
|
||||
{
|
||||
platform = "state";
|
||||
entity_id = "binary_sensor.motion_sensor_occupancy";
|
||||
to = "on";
|
||||
}
|
||||
];
|
||||
|
||||
condition = {
|
||||
condition = "or";
|
||||
conditions = [
|
||||
{
|
||||
condition = "state";
|
||||
entity_id = "alarm_control_panel.home_alarm";
|
||||
state = "triggered";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
action = [
|
||||
{
|
||||
service = "camera.record";
|
||||
target.entity_id = "camera.mirror_camera";
|
||||
data = {
|
||||
lookback = 30;
|
||||
duration = 30;
|
||||
filename = "/mnt/cctv/cctv-{{ states('sensor.date_time_iso') }}.mp4";
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
|
@ -10,9 +10,22 @@
|
|||
}
|
||||
];
|
||||
action = [
|
||||
{
|
||||
service = "camera.record";
|
||||
target.entity_id = "camera.mirror_camera";
|
||||
data = {
|
||||
lookback = 30;
|
||||
duration = 30;
|
||||
filename = "/mnt/cctv/cctv-{{ states('sensor.date_time_iso') }}.mp4";
|
||||
};
|
||||
}
|
||||
{
|
||||
data = {
|
||||
message = "Alarm Triggered - Motion Detected!";
|
||||
data = {
|
||||
channel = "Motion";
|
||||
importance = "high";
|
||||
};
|
||||
};
|
||||
service = "notify.mobile_app_redrum";
|
||||
}
|
||||
|
|
|
@ -209,6 +209,12 @@ EOF
|
|||
access_mode = "single-node-writer"
|
||||
}
|
||||
|
||||
volume "cctv" {
|
||||
type = "host"
|
||||
read_only = false
|
||||
source = "cctv"
|
||||
}
|
||||
|
||||
service {
|
||||
name = "home-assistant"
|
||||
port = "8123"
|
||||
|
@ -284,6 +290,12 @@ EOF
|
|||
read_only = false
|
||||
}
|
||||
|
||||
volume_mount {
|
||||
volume = "cctv"
|
||||
destination = "/mnt/cctv"
|
||||
read_only = false
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOF
|
||||
{{ with secret "kv/data/home-assistant" }}
|
||||
|
|
Loading…
Reference in a new issue