oin/oin_thermostat/__main__.py

35 lines
732 B
Python

import logging
import sys
import tomllib
from .mqtt import HAClient
logger = logging.getLogger(__name__)
config_path = "config.toml"
def main():
with open(config_path, "rb") as config_file:
config = tomllib.load(config_file)
logging.basicConfig(**config.get("logging", dict()))
ha_config = config.get("homeassistant")
if ha_config is None:
logger.error(f"Missing home assistant config in <{config_path}>")
logger.error(f"\t{config}")
sys.exit(1)
client = HAClient(
ha_config.get("entity"),
ha_config.get("secondary_entities"),
mqtt_config=ha_config.get("mqtt"),
)
client.connect()
client.loop()
if __name__ == "__main__":
main()