From f338f094a08facc8a961bf20b373cb93212e15a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20VALENTIN?= Date: Thu, 31 Aug 2023 00:52:51 +0200 Subject: [PATCH] Fix value of kwh --- app/VERSION | 2 +- app/models/export_home_assistant.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/VERSION b/app/VERSION index f8d96aa7..7c81ede6 100755 --- a/app/VERSION +++ b/app/VERSION @@ -1 +1 @@ -0.9.2.b4 \ No newline at end of file +0.9.2.b5 \ No newline at end of file diff --git a/app/models/export_home_assistant.py b/app/models/export_home_assistant.py index c3850d20..b8aec60d 100644 --- a/app/models/export_home_assistant.py +++ b/app/models/export_home_assistant.py @@ -29,8 +29,8 @@ def truncate(f, n): def convert_price(price): if type(price) == str: - price = float(price.replace(",", ".")) - return "{:.4f}".format(price / 100) + price = price.replace(",", ".") + return float(price) class HomeAssistant: @@ -394,14 +394,14 @@ def myelectricaldata_usage_point_id(self, measurement_direction): dailyweek_HP.append(convert_kw(hp)) dailyweek_HC.append(convert_kw(hc)) cost_hp = ( - convert_kw_to_euro(tempo_data["blue_hp"], tempo_config["blue_hp"]) - + convert_kw_to_euro(tempo_data["white_hp"], tempo_config["white_hp"]) - + convert_kw_to_euro(tempo_data["red_hp"], tempo_config["red_hp"]) + convert_kw_to_euro(tempo_data["blue_hp"], convert_price(tempo_config["blue_hp"])) + + convert_kw_to_euro(tempo_data["white_hp"], convert_price(tempo_config["white_hp"])) + + convert_kw_to_euro(tempo_data["red_hp"], convert_price(tempo_config["red_hp"])) ) cost_hc = ( - convert_kw_to_euro(tempo_data["blue_hc"], tempo_config["blue_hc"]) - + convert_kw_to_euro(tempo_data["white_hc"], tempo_config["white_hc"]) - + convert_kw_to_euro(tempo_data["red_hc"], tempo_config["red_hc"]) + convert_kw_to_euro(tempo_data["blue_hc"], convert_price(tempo_config["blue_hc"])) + + convert_kw_to_euro(tempo_data["white_hc"], convert_price(tempo_config["white_hc"])) + + convert_kw_to_euro(tempo_data["red_hc"], convert_price(tempo_config["red_hc"])) ) dailyweek_costHP.append(cost_hp) dailyweek_costHC.append(cost_hc)