diff --git a/containers/home-assistant.nix b/containers/home-assistant.nix index b47664e..cf575c2 100644 --- a/containers/home-assistant.nix +++ b/containers/home-assistant.nix @@ -93,6 +93,7 @@ # currency = "EUR"; unit_system = "metric"; time_zone = "\${TIME_ZONE}"; + country = "\${COUNTRY}"; internal_url = "http://localhost:8123/"; whitelist_external_dirs = [ "/mnt/cctv" @@ -109,6 +110,11 @@ (import ./home-assistant/automations/alarm/retriggered.nix) (import ./home-assistant/automations/alarm/motion-detected.nix) (import ./home-assistant/automations/alarm/motion-detected-away.nix) + + (import ./home-assistant/automations/bathroom_light/dim.nix) + (import ./home-assistant/automations/bathroom_light/brighten.nix) + (import ./home-assistant/automations/bathroom_light/on.nix) + (import ./home-assistant/automations/bathroom_light/off.nix) ]; alarm_control_panel = import ./home-assistant/alarm_control_panel.nix; frontend.themes = @@ -157,6 +163,9 @@ [ xmodem psycopg2 aiohttp-cors + bleak-retry-connector + psutil-home-assistant + bluetooth-auto-recovery ]; }; }; diff --git a/containers/home-assistant/automations/alarm/motion-detected-away.nix b/containers/home-assistant/automations/alarm/motion-detected-away.nix index 17fa173..c67e514 100644 --- a/containers/home-assistant/automations/alarm/motion-detected-away.nix +++ b/containers/home-assistant/automations/alarm/motion-detected-away.nix @@ -13,6 +13,16 @@ entity_id = "binary_sensor.sensor_entry_door_contact"; to = "on"; } + { + platform = "state"; + entity_id = "binary_sensor.left_window_contact"; + to = "on"; + } + { + platform = "state"; + entity_id = "binary_sensor.right_window_contact"; + to = "on"; + } ]; condition = { condition = "or"; diff --git a/containers/home-assistant/automations/bathroom_light/brighten.nix b/containers/home-assistant/automations/bathroom_light/brighten.nix new file mode 100644 index 0000000..746beec --- /dev/null +++ b/containers/home-assistant/automations/bathroom_light/brighten.nix @@ -0,0 +1,54 @@ +{ + alias = "Bathroom Light Brighten"; + description = ""; + id = "dff10ca7-a27c-469a-8015-bd6899458c8d"; + + action = [{ + "else" = [{ stop = ""; }]; + "if" = [{ + condition = "trigger"; + id = "brightness_down"; + }]; + "then" = [{ + repeat = { + sequence = [ + { + data = { brightness_step_pct = 10; }; + service = "light.turn_on"; + target = { entity_id = "light.bathroom_lights"; }; + } + { + delay = { + hours = 0; + milliseconds = 200; + minutes = 0; + seconds = 0; + }; + } + ]; + while = [{ + condition = "not"; + conditions = [ ]; + }]; + }; + }]; + }]; + + condition = [ ]; + + trigger = [ + { + entity_id = [ "sensor.0x540f57fffe3c601d_action" ]; + id = "brightness_down"; + platform = "state"; + to = "brightness_move_up"; + } + { + entity_id = [ "sensor.0x540f57fffe3c601d_action" ]; + platform = "state"; + to = "brightness_stop"; + } + ]; + + mode = "restart"; +} diff --git a/containers/home-assistant/automations/bathroom_light/dim.nix b/containers/home-assistant/automations/bathroom_light/dim.nix new file mode 100644 index 0000000..cf3c0f3 --- /dev/null +++ b/containers/home-assistant/automations/bathroom_light/dim.nix @@ -0,0 +1,54 @@ +{ + alias = "Bathroom Light Dim"; + description = ""; + id = "c28cad3b-8435-48b4-9ced-bd5befaf11df"; + + trigger = [ + { + entity_id = [ "sensor.0x540f57fffe3c601d_action" ]; + id = "brightness_down"; + platform = "state"; + to = "brightness_move_down"; + } + { + entity_id = [ "sensor.0x540f57fffe3c601d_action" ]; + platform = "state"; + to = "brightness_stop"; + } + ]; + + condition = [ ]; + + action = [{ + "else" = [{ stop = ""; }]; + "if" = [{ + condition = "trigger"; + id = "brightness_down"; + }]; + "then" = [{ + repeat = { + sequence = [ + { + data = { brightness_step_pct = -10; }; + service = "light.turn_on"; + target = { entity_id = "light.bathroom_lights"; }; + } + { + delay = { + hours = 0; + milliseconds = 200; + minutes = 0; + seconds = 0; + }; + } + ]; + while = [{ + condition = "not"; + conditions = [ ]; + }]; + }; + }]; + }]; + + mode = "restart"; +} diff --git a/containers/home-assistant/automations/bathroom_light/off.nix b/containers/home-assistant/automations/bathroom_light/off.nix new file mode 100644 index 0000000..bea283d --- /dev/null +++ b/containers/home-assistant/automations/bathroom_light/off.nix @@ -0,0 +1,24 @@ +{ + alias = "Light Off"; + description = ""; + id = "5f773a4d-5a52-4483-a49d-9c0944ea0b21"; + + trigger = [{ + device_id = "bf6aed0be7735065cddf5a0c11629661"; + discovery_id = "0x540f57fffe3c601d action_off"; + domain = "mqtt"; + platform = "device"; + subtype = "off"; + type = "action"; + }]; + + condition = [ ]; + + action = [{ + data = { }; + service = "light.turn_off"; + target = { entity_id = "light.bathroom_lights"; }; + }]; + + mode = "single"; +} diff --git a/containers/home-assistant/automations/bathroom_light/on.nix b/containers/home-assistant/automations/bathroom_light/on.nix new file mode 100644 index 0000000..9502320 --- /dev/null +++ b/containers/home-assistant/automations/bathroom_light/on.nix @@ -0,0 +1,24 @@ +{ + alias = "Light On"; + description = ""; + id = "1330a1c7-3f3f-488e-8aba-aea8937236ce"; + + trigger = [{ + device_id = "bf6aed0be7735065cddf5a0c11629661"; + discovery_id = "0x540f57fffe3c601d action_on"; + domain = "mqtt"; + platform = "device"; + subtype = "on"; + type = "action"; + }]; + + condition = [ ]; + + action = [{ + data = { }; + service = "light.turn_on"; + target = { entity_id = "light.bathroom_lights"; }; + }]; + + mode = "single"; +} diff --git a/flake.nix b/flake.nix index 5c35d82..0095ca3 100644 --- a/flake.nix +++ b/flake.nix @@ -98,6 +98,7 @@ pkgs.mkShell { nativeBuildInputs = with pkgs; [ nomad_1_3 consul vault packer jq terraform + nixfmt remarshal (pkgs.buildGoModule { name = "csc"; version = "master";