🏠 My personal smart home setup, powered by Home Assistant
The flat runs a small state machine that tracks input_select.current_room and turns lights off only on real transitions, never on a single "no motion" reading. A master kill switch (input_boolean.presence_enabled) can disable the whole model, e.g., when guests are over.
The full rule set, scenario matrix, and tuning knobs live in docs/presence-model.md. It's the source of truth – every row of the matrix has a matching test in tests/.
In-process pytest suite that loads the real automations.yaml and packages/presence.yaml into a Home Assistant test instance, drives fake state changes through HA's actual automation engine, advances virtual time without real sleeps, and asserts the resulting entity states.
$ cd tests
$ uv sync # install the dev group into a virtualenv
$ uv run pytest # run the suite
$ uv run pytest -k motion # run a single test by keywordmise will install Python and uv on first entry into the repo if they aren't already present.
To add a new test: add the scenario to the matrix in docs/presence-model.md if it isn't there, write a test that drives the events and asserts the expected end state using the helpers in tests/helpers.py, and reference the matrix row in the test's docstring so the doc and the suite stay paired.
This project contains code generated by Large Language Models (LLMs), under human supervision and proofreading.