Hi everyone,
I’m creating a custom HAOS add-on to import water meter readings into Home Assistant. My add-on’s Python script needs to access the Home Assistant SQLite database located at /config/home-assistant_v2.db.
Here’s what I’ve tried so far:
- My add-on folder structure:
/config
/addons
/water_importer
importer.py
Dockerfile
config.yaml
- In
config.yamlI have:
name: Water importer
slug: water_importer
version: "1.0"
description: ""
hassio_api: true
hassio_role: admin
arch:
- amd64
- armv7
- aarch64
map:
- config
- In
importer.py, I test access to the DB:
import os
db_path = "/config/home-assistant_v2.db"
print("Exists?", os.path.exists(db_path))
- Output from the add-on logs:
Exists? False
So even though /config/home-assistant_v2.db exists in my Home Assistant host, my add-on cannot see it, and I get sqlite3.OperationalError: unable to open database file when trying to connect.
I have already tried:
- Restarting the add-on (stop/start)
- Correcting indentation in
config.yaml - Using relative paths like
../../config/home-assistant_v2.db
Questions:
- How do I correctly mount
/configinto my HAOS add-on so that Python can access it? - Is there a proper way to reference the Home Assistant DB from inside an add-on?
- Are there common pitfalls with
map:in HAOS custom add-ons that could cause the folder not to appear?
Any help or examples would be greatly appreciated!
Thanks in advance!