diff --git a/detective/config.py b/detective/config.py
index 1548e2b..964fabe 100644
--- a/detective/config.py
+++ b/detective/config.py
@@ -83,11 +83,18 @@ def load_hass_config(path):
 def db_url_from_hass_config(path):
     """Find the recorder database url from a HASS config dir."""
     config = load_hass_config(path)
-    default = "sqlite:///{}".format(os.path.join(path, "home-assistant_v2.db"))
+    default_path = os.path.join(path, "home-assistant_v2.db")
+    default_url = "sqlite:///{}".format(default_path)
 
     recorder = config.get("recorder")
 
-    if not recorder:
-        return default
+    if recorder:
+        db_url = recorder.get("db_url")
+        if db_url is not None:
+            return db_url
 
-    return recorder.get("db_url", default)
+    if not os.path.isfile(default_path):
+        raise ValueError(
+            "Unable to determine DB url from hass config at {}".format(path))
+
+    return default_url

db_url_from_hass_config to error out when no recorder section found and DB file doesn't exist
If we can't find a recorder section in `config.db_url_from_hass_config`, we return the SQLite DB. We should only return SQLLite if the file actually exists in the config dir. Else we should error out.
diff --git a/tests/test_config.py b/tests/test_config.py
index 2c64b64..5dd6beb 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -53,7 +53,18 @@ other_secret: test-other-secret
 
 def test_db_url_from_hass_config():
     """Test extracting recorder url from config."""
-    with patch('detective.config.load_hass_config', return_value={}):
+    with patch(
+        'detective.config.load_hass_config', return_value={}
+    ), patch(
+        'os.path.isfile', return_value=False
+    ), pytest.raises(ValueError):
+        config.db_url_from_hass_config('mock-path')
+
+    with patch(
+        'detective.config.load_hass_config', return_value={}
+    ), patch(
+        'os.path.isfile', return_value=True
+    ):
         assert config.db_url_from_hass_config('mock-path') == \
             'sqlite:///mock-path/home-assistant_v2.db'
 

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-timeout
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi==2025.1.31
charset-normalizer==3.4.1
contourpy==1.3.0
cycler==0.12.1
exceptiongroup==1.2.2
fonttools==4.56.0
greenlet==3.1.1
-e git+https://github.com/robmarkcole/HASS-data-detective.git@809ccf7467073dabfd6cd2eec039740a868031ed#egg=HASS_data_detective
idna==3.10
importlib_resources==6.5.2
iniconfig==2.1.0
kiwisolver==1.4.7
matplotlib==3.9.4
numpy==2.0.2
packaging==24.2
pandas==2.2.3
pillow==11.1.0
pluggy==1.5.0
pyparsing==3.2.3
pytest==8.3.5
pytest-timeout==2.3.1
python-dateutil==2.9.0.post0
pytz==2025.2
requests==2.32.3
ruamel.yaml==0.18.10
ruamel.yaml.clib==0.2.12
six==1.17.0
SQLAlchemy==2.0.40
tomli==2.2.1
typing_extensions==4.13.0
tzdata==2025.2
urllib3==2.3.0
zipp==3.21.0

name: HASS-data-detective
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - contourpy==1.3.0
      - cycler==0.12.1
      - exceptiongroup==1.2.2
      - fonttools==4.56.0
      - greenlet==3.1.1
      - idna==3.10
      - importlib-resources==6.5.2
      - iniconfig==2.1.0
      - kiwisolver==1.4.7
      - matplotlib==3.9.4
      - numpy==2.0.2
      - packaging==24.2
      - pandas==2.2.3
      - pillow==11.1.0
      - pluggy==1.5.0
      - pyparsing==3.2.3
      - pytest==8.3.5
      - pytest-timeout==2.3.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - requests==2.32.3
      - ruamel-yaml==0.18.10
      - ruamel-yaml-clib==0.2.12
      - six==1.17.0
      - sqlalchemy==2.0.40
      - tomli==2.2.1
      - typing-extensions==4.13.0
      - tzdata==2025.2
      - urllib3==2.3.0
      - zipp==3.21.0
prefix: /opt/conda/envs/HASS-data-detective

tests/test_config.py::test_db_url_from_hass_config
tests/test_config.py::test_load_hass_config
tests/test_config.py::test_find_hass_config
detective/config.py
detective/config.py