22 lines
493 B
Python
22 lines
493 B
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Settings:
|
|
ha_url: str | None = None
|
|
ha_token: str | None = None
|
|
|
|
@property
|
|
def ha_configured(self) -> bool:
|
|
return bool(self.ha_url and self.ha_token)
|
|
|
|
|
|
def load_settings() -> Settings:
|
|
return Settings(
|
|
ha_url=os.getenv("SILLYHOME_HA_URL") or os.getenv("HA_URL"),
|
|
ha_token=os.getenv("SILLYHOME_HA_TOKEN") or os.getenv("HA_TOKEN"),
|
|
)
|