From 4c99a9308b74ab03b599283ee0531259bc4a9afb Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 1 Aug 2023 11:49:26 +0100 Subject: [PATCH] adding solar hot water and wind turbine features --- backend/Property.py | 38 ++++++++++++++++++++++++++++++++++++++ backend/app/plan/router.py | 6 +++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/backend/Property.py b/backend/Property.py index eb16189e..7e32bd76 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -41,6 +41,8 @@ class Property(BaseUtility): self.energy = None self.ventilation = None self.solar_pv = None + self.solar_hot_water = None + self.wind_turbine = None if epc_client: self.epc_client = epc_client @@ -144,6 +146,40 @@ class Property(BaseUtility): "solar_pv": solar_pv, } + def set_solar_hot_water(self): + """ + Extracts and formats data about the home's solar hot water + We are just formatting the solar-water-heating-flag in the epc data + :return: + """ + + value_map = { + "Y": True, + "N": False, + "": None, + } + + self.solar_hot_water = { + "solar_hot_water": value_map[self.data["solar-water-heating-flag"]], + } + + def set_wind_turbine(self): + """ + Extracts and formats data about the home's wind turbine + We are just formatting the wind-turbine-flag in the epc data + :return: + """ + + wind_turbine_count = self.data["wind-turbine-count"] + if wind_turbine_count == "": + wind_turbine_count = None + else: + wind_turbine_count = int(wind_turbine_count) + + self.wind_turbine = { + "wind_turbine": wind_turbine_count, + } + def get_components(self, cleaned): """ Given the cleaning that has been performed, we'll use this to identify the property @@ -161,6 +197,8 @@ class Property(BaseUtility): self.set_energy() self.set_ventilation() self.set_solar_pv() + self.set_solar_hot_water() + self.set_wind_turbine() for description, attribute in cleaned.items(): diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 2a12abd1..22fd9956 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -259,9 +259,9 @@ async def trigger_plan(body: PlanTriggerRequest): "lighting": p.lighting["cleaned_description"], "lighting_rating": rating_lookup[p.data["lighting-energy-eff"]], "ventilation": p.ventilation["ventilation"], - "solar_pv": p.solar_pv["cleaned_description"], - "solar_hot_water": p.solar_hot_water["cleaned_description"], - "wind_turbine": p.wind_turbine["cleaned_description"], + "solar_pv": p.solar_pv["solar_pv"], + "solar_hot_water": p.solar_hot_water["solar_hot_water"], + "wind_turbine": p.wind_turbine["wind_turbine"], "floor_height": p.data["floor-height"], "heat_loss_corridor": p.data["heat-loss-corridor"], "unheated_corridor_length": p.data["unheated-corridor-length"],