From b11d9b2fb9a2c99b3484bea8e0493a07b677e433 Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Sat, 31 Jan 2026 15:04:23 +0100 Subject: [PATCH] feat: ha add morning active automation --- hosts/fw/modules/home-assistant/default.nix | 1 + .../modules/home-assistant/morning-active.nix | 76 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 hosts/fw/modules/home-assistant/morning-active.nix diff --git a/hosts/fw/modules/home-assistant/default.nix b/hosts/fw/modules/home-assistant/default.nix index ef3393f..4f70b8f 100644 --- a/hosts/fw/modules/home-assistant/default.nix +++ b/hosts/fw/modules/home-assistant/default.nix @@ -103,6 +103,7 @@ in ./snapcast.nix ./coming-home.nix + ./morning-active.nix ]; networking = { diff --git a/hosts/fw/modules/home-assistant/morning-active.nix b/hosts/fw/modules/home-assistant/morning-active.nix new file mode 100644 index 0000000..9e7f846 --- /dev/null +++ b/hosts/fw/modules/home-assistant/morning-active.nix @@ -0,0 +1,76 @@ +{ + services.home-assistant.config = { + # Track if morning hook already triggered today + input_boolean = { + morning_active_triggered = { + name = "Morning Active Triggered"; + icon = "mdi:weather-sunny"; + }; + }; + + # REST command to call Moltbot + rest_command = { + moltbot_morning_active = { + url = "https://moltbot.cloonar.com/hooks/agent"; + method = "POST"; + headers = { + Authorization = "!secret moltbot_home_arrival"; # reuse same token + Content-Type = "application/json"; + }; + payload = ''{"message":"Morning briefing. Give a brief, friendly summary: 1) Today's weather for Vienna 2) Calendar events for today (check CalDAV) 3) Any pending reminders. Keep it concise, no fluff. Just the info.","name":"MorningBriefing","deliver":true,"channel":"whatsapp","to":"+436607055308"}''; + }; + }; + + # Main automation: detect morning activity + "automation morning_active" = { + alias = "morning_active"; + trigger = [ + { + platform = "state"; + entity_id = "light.toilet_lights"; + to = "on"; + } + # Future: add kitchen motion sensor here + # { + # platform = "state"; + # entity_id = "binary_sensor.kitchen_motion"; + # to = "on"; + # } + ]; + condition = [ + { + condition = "time"; + after = "05:00:00"; + before = "12:00:00"; + } + { + condition = "state"; + entity_id = "input_boolean.morning_active_triggered"; + state = "off"; + } + ]; + action = [ + { + service = "input_boolean.turn_on"; + target.entity_id = "input_boolean.morning_active_triggered"; + } + { + service = "rest_command.moltbot_morning_active"; + } + ]; + }; + + # Reset automation: reset triggered state at 3:00 AM + "automation morning_active_reset" = { + alias = "morning_active_reset"; + trigger = { + platform = "time"; + at = "03:00:00"; + }; + action = { + service = "input_boolean.turn_off"; + target.entity_id = "input_boolean.morning_active_triggered"; + }; + }; + }; +}