From 7ed4002d0438f374cf2141364007a718065cf0e8 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 4 Jun 2024 18:11:36 +0100 Subject: [PATCH] finished optimisation and output --- backend/app/plan/router.py | 2 ++ recommendations/HeatingRecommender.py | 17 +++++++++++------ recommendations/Mds.py | 7 ++++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index ee36ea80..f6c01715 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -999,6 +999,7 @@ async def build_mds(body: MdsRequest): res = results[results["uprn"] == p.uprn] wall = p.walls heating = p.main_heating + heating_controls = p.main_heating_controls wall_recommendation = [ x for x in res["measures"].values[0] if x in ["internal_wall_insulation", "external_wall_insulation", "cavity_wall_insulation"] @@ -1044,6 +1045,7 @@ async def build_mds(body: MdsRequest): "address": p.address, "postcode": p.postcode, "heating": heating["clean_description"], + "heating_controls": heating_controls["clean_description"], "recommendation": hhr_recommendation, "possible_measures": possible_measures, "selected_measures": res["measures"].values[0], diff --git a/recommendations/HeatingRecommender.py b/recommendations/HeatingRecommender.py index 11a7b663..ac8c4973 100644 --- a/recommendations/HeatingRecommender.py +++ b/recommendations/HeatingRecommender.py @@ -62,6 +62,8 @@ class HeatingRecommender: if self.is_high_heat_retention_valid(): # Recommend high heat retention storage heaters + # TODO: We need to allow for the possibility that the property aleady has storage heaters, but just + # needs the controls self.recommend_hhr_storage_heaters(phase=phase, system_change=True, heating_controls_only=False) # if the property has mains heating with boiler and radiators, we recommend optimal heating controls @@ -341,17 +343,19 @@ class HeatingRecommender: """ already_has_hhr = "Electric storage heaters" in self.property.main_heating["clean_description"] + + # Some electric storage heaters will show that the controls are "Manual charge controls" which are indicative + # of the old model of electric storage heaters, originating from 1961. + # Newer HHR storage heaters will charge up over night but will retain the heat durin the day for when warmth + # is actually needed, unlike traditional storage heaters that charge up at night and release heat during the day + # which isn't always ideal for the occupants. already_has_hhr_contols = ( self.property.main_heating_controls[ "clean_description" ].lower() == self.high_heat_retention_contols_desc.lower() ) - # Conditions for not needing this recommendation - # Modern hhr storage heaters will have the specific controls so we can check for this - already_installed_hh_retention = already_has_hhr and already_has_hhr_contols - - return already_installed_hh_retention + return already_has_hhr and already_has_hhr_contols def recommend_hhr_storage_heaters(self, phase, system_change, heating_controls_only, _return=False): """ @@ -374,8 +378,9 @@ class HeatingRecommender: if self.property.main_heating_controls["clean_description"] != self.high_heat_retention_contols_desc: controls_recommender.recommend(heating_description="Electric storage heaters, radiators") + has_hhr = self.is_hhr_already_installed() # Conditions for not recommending electric storage heaters - if self.is_hhr_already_installed(): + if has_hhr: # No recommendation needed return diff --git a/recommendations/Mds.py b/recommendations/Mds.py index 27f6f871..4c417447 100644 --- a/recommendations/Mds.py +++ b/recommendations/Mds.py @@ -173,9 +173,14 @@ class Mds: continue if measure == "high_heat_retention_storage_heaters": + + # For the moment, we recommend storage heaters if the property doesn't already + # and don't make it contngent on controls + already_has_hhr = self.heating_recommender.is_hhr_already_installed() + if ( self.heating_recommender.is_high_heat_retention_valid() and - not self.heating_recommender.is_hhr_already_installed() + not already_has_hhr ): pruned_measures.append(measure) continue