diff --git a/server-modules/home-assistant/default.nix b/server-modules/home-assistant/default.nix index 84b96e46..9e3b2450 100644 --- a/server-modules/home-assistant/default.nix +++ b/server-modules/home-assistant/default.nix @@ -11,6 +11,11 @@ "h" "d" ]; + + motionRooms = [ + "toilet" + "entry" + ]; in { sops.secrets = { @@ -60,6 +65,27 @@ in { automation = "!include automations.yaml"; script = "!include scripts.yaml"; frontend.themes = nixyTheme; + # Timestamp of the last motion detection (trigger-based, survives restarts) + template = + map (room: { + trigger = [ + { + trigger = "state"; + entity_id = "binary_sensor.${room}_motion"; + to = "on"; + } + ]; + sensor = [ + { + name = "${room} last motion"; + unique_id = "${room}_last_motion"; + device_class = "timestamp"; + icon = "mdi:motion-sensor"; + state = "{{ now().isoformat() }}"; + } + ]; + }) + motionRooms; alarm_control_panel = [ { platform = "manual"; diff --git a/server-modules/home-assistant/plugins.nix b/server-modules/home-assistant/plugins.nix index 99098ecb..4f321c81 100644 --- a/server-modules/home-assistant/plugins.nix +++ b/server-modules/home-assistant/plugins.nix @@ -63,5 +63,6 @@ in { multiday-calendar-card pkgs.home-assistant-custom-lovelace-modules.bubble-card pkgs.home-assistant-custom-lovelace-modules.auto-entities + pkgs.home-assistant-custom-lovelace-modules.mushroom ]; }