Move main config to config.toml
This commit is contained in:
parent
477cc99247
commit
119feee5e5
3 changed files with 42 additions and 12 deletions
|
|
@ -1,20 +1,35 @@
|
|||
import logging
|
||||
import sys
|
||||
import tomllib
|
||||
|
||||
from .mqtt import HAClient
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open("config.toml", "rb") as config_file:
|
||||
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(level=logging.DEBUG)
|
||||
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(
|
||||
"climate.chaudiere",
|
||||
["sensor.esptic_tempo", "sensor.rte_tempo_prochaine_couleur"],
|
||||
config.get("mqtt", dict()),
|
||||
ha_config.get("entity"),
|
||||
ha_config.get("secondary_entities"),
|
||||
mqtt_config=ha_config.get("mqtt"),
|
||||
)
|
||||
|
||||
client.connect()
|
||||
|
||||
client.loop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Reference in a new issue