From 190c2ee5c51e934ce9f1839eba56229af6476235 Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Fri, 30 Jan 2026 08:59:36 +0100 Subject: [PATCH] feat: changes to home assistant getting home --- .../fw/modules/home-assistant/coming-home.nix | 27 +++++++++++++++++++ hosts/fw/modules/home-assistant/default.nix | 2 ++ hosts/fw/modules/home-assistant/locks.nix | 20 +++++--------- .../modules/home-assistant/power-saving.nix | 10 +++---- 4 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 hosts/fw/modules/home-assistant/coming-home.nix diff --git a/hosts/fw/modules/home-assistant/coming-home.nix b/hosts/fw/modules/home-assistant/coming-home.nix new file mode 100644 index 0000000..30bc6d2 --- /dev/null +++ b/hosts/fw/modules/home-assistant/coming-home.nix @@ -0,0 +1,27 @@ +{ + services.home-assistant.config = { + rest_command = { + moltbot_home_arrival = { + url = "https://moltbot.cloonar.com/hooks/agent"; + method = "POST"; + headers = { + Authorization = "!secret moltbot_home_arrival"; + Content-Type = "application/json"; + }; + payload = "{\"message\":\"I just arrived home. Read home-reminders.md in my workspace. This file may contain reminders to tell me, or instructions/tasks to perform (like looking something up). Execute any instructions, send me the results along with any simple reminders, then clear the file content (keep the header). If the file is empty, just welcome me home briefly.\",\"name\":\"HomeArrival\",\"deliver\":true,\"channel\":\"whatsapp\",\"to\":\"+436607055308\"}"; + }; + }; + "automation home_arrival" = { + alias = "home_arrival"; + trigger = { + platform = "zone"; + entity_id = "person.dominik"; + zone = "zone.home"; + event = "enter"; + }; + action = { + service = "rest_command.moltbot_home_arrival"; + }; + }; + }; +} diff --git a/hosts/fw/modules/home-assistant/default.nix b/hosts/fw/modules/home-assistant/default.nix index c7e1eac..ef3393f 100644 --- a/hosts/fw/modules/home-assistant/default.nix +++ b/hosts/fw/modules/home-assistant/default.nix @@ -101,6 +101,8 @@ in ./shelly.nix ./sleep.nix ./snapcast.nix + + ./coming-home.nix ]; networking = { diff --git a/hosts/fw/modules/home-assistant/locks.nix b/hosts/fw/modules/home-assistant/locks.nix index a2160b4..edcd5af 100644 --- a/hosts/fw/modules/home-assistant/locks.nix +++ b/hosts/fw/modules/home-assistant/locks.nix @@ -1,8 +1,6 @@ let - devices = [ - "device_tracker.dominiks_iphone" - "device_tracker.dominiks_mp01" - "device_tracker.dominiks_fairphone_6" + persons = [ + "person.dominiks" ]; in { services.home-assistant.extraComponents = [ @@ -14,18 +12,12 @@ in { alias = "house_door"; mode = "restart"; trigger = { - platform = "state"; - entity_id = devices; - from = "not_home"; - to = "home"; + platform = "zone"; + entity_id = "person.dominik"; + zone = "zone.home"; + event = "enter"; }; action = [ - { - service = "script.turn_on"; - target = { - entity_id = "script.turn_on_circuits"; - }; - } { service = "lock.unlock"; target = { diff --git a/hosts/fw/modules/home-assistant/power-saving.nix b/hosts/fw/modules/home-assistant/power-saving.nix index cf645be..1824242 100644 --- a/hosts/fw/modules/home-assistant/power-saving.nix +++ b/hosts/fw/modules/home-assistant/power-saving.nix @@ -23,12 +23,10 @@ "automation arrive home power" = { alias = "arrive home power"; trigger = { - platform = "state"; - entity_id = [ - "device_tracker.dominiks_iphone" - ]; - from = "not_home"; - to = "home"; + platform = "zone"; + entity_id = "person.dominik"; + zone = "zone.home"; + event = "enter"; }; action = [ {