From c1ffbc5d819ceb029cc08843a397f9157beb8337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20VALENTIN?= Date: Thu, 29 Feb 2024 21:37:24 +0100 Subject: [PATCH] fix: fix sensor class --- src/models/export_home_assistant_ws.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/models/export_home_assistant_ws.py b/src/models/export_home_assistant_ws.py index 375ef256..68b0dac6 100644 --- a/src/models/export_home_assistant_ws.py +++ b/src/models/export_home_assistant_ws.py @@ -56,7 +56,7 @@ def load_config(self): if self.config is not None: if "url" in self.config: self.url = self.config["url"] - if "ssl" in self.config and self.config["ssl"]: + if self.config.get("ssl"): url_prefix = "wss" else: url_prefix = "ws" @@ -85,7 +85,7 @@ def connect(self): if check_ssl and "gateway" in check_ssl: sslopt = {"cert_reqs": ssl.CERT_NONE} self.ws = websocket.WebSocket(sslopt=sslopt) - logging.info(f"Connexion au WebSocket Home Assistant %s", self.url) + logging.info("Connexion au WebSocket Home Assistant %s", self.url) self.ws.connect( self.url, timeout=5, @@ -257,7 +257,7 @@ def import_data(self): # noqa: C901 statistic_id = f"{statistic_id}_hp_{measurement_direction}" cost = value * self.usage_point_id_config.consumption_price_hp / 1000 tag = "hp" - elif plan == "TEMPO": + elif plan.upper() == "TEMPO": if 600 <= hour_minute < 2200: hour_type = "HP" else: @@ -382,7 +382,7 @@ def import_data(self): # noqa: C901 uniq_id=statistic_id, unit_of_measurement="EURO", state=truncate(data["sum"]), - device_class="energy", + device_class="monetary", numPDL=self.usage_point_id, ) @@ -520,7 +520,7 @@ def import_data(self): # noqa: C901 uniq_id=statistic_id, unit_of_measurement="EURO", state=truncate(data["sum"]), - device_class="energy", + device_class="monetary", numPDL=self.usage_point_id, ) except Exception as _e: