From 996c71c1893deac7df89fa50bc76b5cc11c18880 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 30 Jul 2024 15:52:38 +0100 Subject: [PATCH] handle recommendations for insulated room roof --- backend/apis/GoogleSolarApi.py | 5 +++-- recommendations/RoofRecommendations.py | 10 +++++++++- recommendations/SolarPvRecommendations.py | 8 ++------ recommendations/recommendation_utils.py | 8 +++++--- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/backend/apis/GoogleSolarApi.py b/backend/apis/GoogleSolarApi.py index c6bb3dde..579e985d 100644 --- a/backend/apis/GoogleSolarApi.py +++ b/backend/apis/GoogleSolarApi.py @@ -123,7 +123,8 @@ class GoogleSolarApi: :param longitude: The longitude of the location. :param latitude: The latitude of the location. - :param energy_consumption: The energy consumption of the building/unit associated to the longitude and latitude. + :param energy_consumption: The energy consumption of the building/unit associated to the longitude and latitude, + that we wish to size the solar panels up against :param property_instance: The property instance associated to the longitude and latitude. :param required_quality: The required quality of the data (default is "MEDIUM"). :param is_building: Whether the energy consumption is for a building or a unit. @@ -266,7 +267,7 @@ class GoogleSolarApi: cost = cost_instance.solar_pv( wattage=wattage, has_battery=False )["total"] - + roi_summary.append( { "segmentIndex": segment["segmentIndex"], diff --git a/recommendations/RoofRecommendations.py b/recommendations/RoofRecommendations.py index 615289de..56f3721a 100644 --- a/recommendations/RoofRecommendations.py +++ b/recommendations/RoofRecommendations.py @@ -93,11 +93,19 @@ class RoofRecommendations: Check if the room roof is already insulated """ - return ( + full_insulated_room_roof = ( self.property.roof["is_roof_room"] and self.property.roof["insulation_thickness"] in ["average", "above_average"] ) + room_roof_insulated_at_rafters = ( + self.property.roof["is_pitched"] and + self.property.roof["is_at_rafters"] and + self.property.roof["insulation_thickness"] in ["average", "above_average"] + ) + + return full_insulated_room_roof or room_roof_insulated_at_rafters + def recommend(self, phase): if self.property.roof["has_dwelling_above"]: diff --git a/recommendations/SolarPvRecommendations.py b/recommendations/SolarPvRecommendations.py index 66d2ac78..63519d02 100644 --- a/recommendations/SolarPvRecommendations.py +++ b/recommendations/SolarPvRecommendations.py @@ -174,10 +174,6 @@ class SolarPvRecommendations: if already_installed: cost_result = override_costs(cost_result) - # We calculate the photo_supply we're going to simulate the impact with and we round this to the - # nearest 5 - photo_supply = round(roof_coverage_percent / 5) * 5 - self.recommendation.append( { "phase": phase, @@ -192,9 +188,9 @@ class SolarPvRecommendations: # This is required for simulating the SAP impact. solar_pv_percentage is between 0 & 1 so we # scale # back up here - "photo_supply": photo_supply, + "photo_supply": roof_coverage_percent, "has_battery": has_battery, "initial_ac_kwh_per_year": recommendation_config["initial_ac_kwh_per_year"], - "description_simulation": {"photo-supply": photo_supply}, + "description_simulation": {"photo-supply": roof_coverage_percent}, } ) diff --git a/recommendations/recommendation_utils.py b/recommendations/recommendation_utils.py index d14a0d4c..ce32e061 100644 --- a/recommendations/recommendation_utils.py +++ b/recommendations/recommendation_utils.py @@ -205,10 +205,11 @@ def get_wall_u_value( return float(mapped_value) -def get_u_value_from_s9(thickness, s9, is_loft, is_roof_room, is_thatched): +def get_u_value_from_s9(thickness, s9, is_loft, is_roof_room, is_thatched, is_at_rafters): """Get the U-value from table S9 based on the insulation thickness.""" - if is_roof_room: + # If the roof as pitched & insulated at the rafters, it's a room roof + if is_roof_room or is_at_rafters: # We re-map the thickness thickness_map = { "below average": "50", @@ -219,7 +220,7 @@ def get_u_value_from_s9(thickness, s9, is_loft, is_roof_room, is_thatched): thickness = thickness_map[thickness] if thickness in ["below average", "average", "above average", "none", None] or ( - not is_loft and not is_roof_room + not is_loft and not is_roof_room and not is_at_rafters ): return None elif thickness.endswith("+"): @@ -291,6 +292,7 @@ def get_roof_u_value( is_loft=is_loft, is_roof_room=is_roof_room, is_thatched=is_thatched, + is_at_rafters=is_at_rafters ) if u_value is not None: