initial api work

This commit is contained in:
ari committed 2022-01-04 21:42:25 -05:00
1 parent 00505c0faa
commit fbbfee8873
15 files changed
+206 -222

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import os
from decouple import config
from pathlib import Path
from .loader import HassConfig
def find_hass_config() -> HassConfig:
"""Try to find HASS config."""
if "HASSIO_TOKEN" in os.environ:
return HassConfig(Path("/config"))
"""Put together the default configuration directory based on the OS."""
data_dir = Path(config("APPDATA", None) if os.name == "nt" else os.path.expanduser("~"))
config_dir = data_dir / ".homeassistant"
if config_dir.is_dir():
return HassConfig(config_dir)
raise ValueError(
"Unable to automatically find the location of Home Assistant " "config. Please pass it in."
)