From 483d377b6d9786f66cc585510cd5078fc5a159b5 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Mon, 9 Dec 2024 16:12:38 +0100 Subject: [PATCH] Use TypedDict to avoir using Any --- config.toml | 2 +- oin_thermostat/mqtt.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config.toml b/config.toml index 498e003..0c37600 100644 --- a/config.toml +++ b/config.toml @@ -1,5 +1,5 @@ [logging] -level = "DEBUG" +# level = "DEBUG" [homeassistant] entity = "climate.chaudiere" diff --git a/oin_thermostat/mqtt.py b/oin_thermostat/mqtt.py index e6279ac..82ecfc6 100644 --- a/oin_thermostat/mqtt.py +++ b/oin_thermostat/mqtt.py @@ -1,7 +1,7 @@ import json import logging from collections.abc import Callable -from typing import Any +from typing import Any, TypedDict import paho.mqtt.client as mqtt from paho.mqtt.enums import CallbackAPIVersion, MQTTErrorCode @@ -12,6 +12,14 @@ from .select import Selector logger = logging.getLogger(__name__) +class HAOptions(TypedDict): + dev: dict[str, str] + o: dict[str, str] + availability_topic: str + state_topic: str + cmps: dict[str, dict[str, str]] + + class HAClient: def __init__( self, @@ -38,7 +46,7 @@ class HAClient: self.selector = Selector(self.send_data) @property - def ha_options(self) -> dict[str, Any]: + def ha_options(self) -> HAOptions: return { "dev": { "ids": "oin",