import os
import logging

SQLALCHEMY_DATABASE_URI = os.environ.get(
    "DATABASE_URL",
    "sqlite:///batteries.db",
)

_secret_key = os.environ.get("SECRET_KEY")
if not _secret_key:
    logging.warning(
        "SECRET_KEY not set — using insecure default. "
        "Set SECRET_KEY env var before running in production."
    )
SECRET_KEY = _secret_key or "dev-secret-change-in-prod"

SQLALCHEMY_TRACK_MODIFICATIONS = False

# Home Assistant integration (all optional — app works normally when absent)
HOMEASSISTANT_URL           = os.environ.get("HOMEASSISTANT_URL")
HOMEASSISTANT_API_KEY       = os.environ.get("HOMEASSISTANT_API_KEY")
HOMEASSISTANT_POLL_INTERVAL = int(os.environ.get("HOMEASSISTANT_POLL_INTERVAL", "300"))
