From cc13843e675f094290f51992ddcbbe8efcbabe3f Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Sun, 17 Aug 2025 18:03:00 +0100 Subject: [PATCH] updated trickle vent rec --- recommendations/VentilationRecommendations.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/recommendations/VentilationRecommendations.py b/recommendations/VentilationRecommendations.py index c0ccd891..a8aa0ca3 100644 --- a/recommendations/VentilationRecommendations.py +++ b/recommendations/VentilationRecommendations.py @@ -18,7 +18,8 @@ class VentilationRecommendations(Definitions): self.property = property_instance self.recommendation = None - self.materials = [part for part in materials if part["type"] == "mechanical_ventilation"] + self.mechanical_ventilation_materials = [part for part in materials if part["type"] == "mechanical_ventilation"] + self.trickle_vent_materials = [part for part in materials if part["type"] == "trickle_vent"] def recommend(self, phase): """ @@ -33,13 +34,10 @@ class VentilationRecommendations(Definitions): if self.property.has_ventilation: return - if len(self.materials) != 1: - raise NotImplementedError("Only handled the case of having one venilation option") - # We recommend installing 2 units n_units = 2 - parts = self.materials.copy() + parts = self.mechanical_ventilation_materials.copy() already_installed = "cavity_wall_insulation" in self.property.already_installed @@ -103,6 +101,10 @@ class VentilationRecommendations(Definitions): else trickle_vents_recommendation_config["description"] ) + cheapest_trickle_vent = min( + self.trickle_vent_materials, key=lambda x: x["total_cost"] + ) + return [ { "phase": None, @@ -118,7 +120,7 @@ class VentilationRecommendations(Definitions): "kwh_savings": 0, "co2_equivalent_savings": 0, "energy_cost_savings": 0, - "total": trickle_vents_recommendation_config["cost"], + "total": cheapest_trickle_vent["total_cost"] * self.property.number_of_windows, # We use a very simple and rough estimate of 4 hours per unit "labour_hours": trickle_vents_recommendation_config.get("labour_hours", 8), "labour_days": trickle_vents_recommendation_config.get("labour_days", 1), # Assume 8 hour day