mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
173 lines
8 KiB
Python
173 lines
8 KiB
Python
from backend.Property import Property
|
|
from recommendations.FloorRecommendations import FloorRecommendations
|
|
from recommendations.WallRecommendations import WallRecommendations
|
|
from recommendations.RoofRecommendations import RoofRecommendations
|
|
from recommendations.VentilationRecommendations import VentilationRecommendations
|
|
from recommendations.FireplaceRecommendations import FireplaceRecommendations
|
|
from recommendations.LightingRecommendations import LightingRecommendations
|
|
from recommendations.SolarPvRecommendations import SolarPvRecommendations
|
|
from recommendations.WindowsRecommendations import WindowsRecommendations
|
|
from recommendations.HeatingRecommender import HeatingRecommender
|
|
from recommendations.HotwaterRecommendations import HotwaterRecommendations
|
|
from recommendations.SecondaryHeating import SecondaryHeating
|
|
from recommendations.Recommendations import Recommendations
|
|
|
|
|
|
class Mds:
|
|
"""
|
|
Handles the contruction of the MDS report
|
|
"""
|
|
|
|
def __init__(self, property_instance: Property, materials):
|
|
self.property_instance = property_instance
|
|
|
|
self.floor_recommender = FloorRecommendations(property_instance=property_instance, materials=materials)
|
|
self.wall_recommender = WallRecommendations(property_instance=property_instance, materials=materials)
|
|
self.roof_recommender = RoofRecommendations(property_instance=property_instance, materials=materials)
|
|
self.ventilation_recomender = VentilationRecommendations(
|
|
property_instance=property_instance, materials=materials
|
|
)
|
|
self.fireplace_recommender = FireplaceRecommendations(property_instance=property_instance)
|
|
self.lighting_recommender = LightingRecommendations(property_instance=property_instance, materials=materials)
|
|
self.windows_recommender = WindowsRecommendations(property_instance=property_instance, materials=materials)
|
|
self.solar_recommender = SolarPvRecommendations(property_instance=property_instance)
|
|
self.heating_recommender = HeatingRecommender(property_instance=property_instance)
|
|
self.hotwater_recommender = HotwaterRecommendations(property_instance=property_instance)
|
|
self.secondary_heating_recommender = SecondaryHeating(property_instance=property_instance)
|
|
|
|
def build(self):
|
|
if self.property_instance.measures is None:
|
|
raise NotImplementedError("No measures in the property - implement me")
|
|
|
|
measures = self.property_instance.measures
|
|
|
|
measure_config_list = [list(m.keys())[0] for m in measures]
|
|
|
|
not_implemented_measures = [
|
|
"party_wall_insulation",
|
|
"ground_source_heat_pump",
|
|
"shared_ground_loops",
|
|
"communal_heat_networks",
|
|
"district_heating_networks",
|
|
"solar_thermal",
|
|
"draught_proofing",
|
|
"ev_charging",
|
|
"battery",
|
|
]
|
|
# Check if we have a not implemented measure
|
|
if any([m in not_implemented_measures for m in measure_config_list]):
|
|
raise NotImplementedError("Not implemented measure in the property - implement me")
|
|
|
|
mds_recommendations = []
|
|
errors = []
|
|
|
|
# TODO: Could use a decarator to reduce the boilerplate code - insert_recommendation_id and then the append
|
|
|
|
if "external_wall_insulation" in measure_config_list:
|
|
recs = self.wall_recommender.mds_recommend_ewi(phase=0)
|
|
if not recs:
|
|
raise Exception("No recommendations for external wall insulation")
|
|
recs = self.insert_recommendation_id(recs, measures, "external_wall_insulation")
|
|
mds_recommendations.append(recs)
|
|
|
|
if "cavity_wall_insulation" in measure_config_list:
|
|
recs = self.wall_recommender.mds_recommend_cavity_wall_insulation(phase=0)
|
|
recs = self.insert_recommendation_id(recs, measures, "cavity_wall_insulation")
|
|
mds_recommendations.append(recs)
|
|
|
|
if "loft_insulation" in measure_config_list:
|
|
# Check if the roof is suitable for loft insulation
|
|
if self.property_instance.roof['is_roof_room']:
|
|
errors.append("Roof is a room")
|
|
else:
|
|
recs = self.roof_recommender.mds_loft_insulation(phase=0)
|
|
if not recs:
|
|
raise Exception("No recommendations for loft insulation")
|
|
recs = self.insert_recommendation_id(recs, measures, "loft_insulation")
|
|
mds_recommendations.append(recs)
|
|
|
|
if "internal_wall_insulation" in measure_config_list:
|
|
raise Exception("check me out 4")
|
|
self.wall_recommender.recommend(phase=0)
|
|
|
|
if "suspended_floor_insulation" in measure_config_list:
|
|
raise Exception("check me out 5")
|
|
self.floor_recommender.recommend(phase=0)
|
|
|
|
if "solid_floor_insulation" in measure_config_list:
|
|
raise Exception("check me out 6")
|
|
self.floor_recommender.recommend(phase=0)
|
|
|
|
if "air_source_heat_pump" in measure_config_list:
|
|
recs = self.heating_recommender.recommend_air_source_heat_pump(
|
|
phase=0, has_cavity_or_loft_recommendations=False, _return=True
|
|
)
|
|
recs = self.insert_recommendation_id(recs, measures, "air_source_heat_pump")
|
|
mds_recommendations.append(recs)
|
|
|
|
if "electric_storage_heaters" in measure_config_list:
|
|
recs = self.heating_recommender.recommend_hhr_storage_heaters(
|
|
phase=0, system_change=True, heating_controls_only=False, _return=True
|
|
)
|
|
recs = self.insert_recommendation_id(recs, measures, "electric_storage_heaters")
|
|
mds_recommendations.append(recs)
|
|
|
|
if "low_energy_lighting" in measure_config_list:
|
|
raise Exception("check me out 9")
|
|
self.lighting_recommender.recommend(phase=0)
|
|
|
|
if "cylinder_insulation" in measure_config_list:
|
|
raise Exception("check me out 10")
|
|
self.hotwater_recommender.recommend(phase=0)
|
|
|
|
if "smart_controls" in measure_config_list:
|
|
raise Exception("check me out 11")
|
|
self.heating_recommender.recommend(phase=0)
|
|
|
|
if "zone_controls" in measure_config_list:
|
|
raise Exception("check me out 12")
|
|
self.heating_recommender.recommend(phase=0)
|
|
|
|
if "trvs" in measure_config_list:
|
|
raise Exception("check me out 13")
|
|
self.heating_recommender.recommend(phase=0)
|
|
|
|
if "solar_pv" in measure_config_list:
|
|
recs = self.solar_recommender.mds_recommend(phase=0, solar_pv_percentage=0.5)
|
|
recs = self.insert_recommendation_id(recs, measures, "solar_pv")
|
|
mds_recommendations.append(recs)
|
|
|
|
if "double_glazing" in measure_config_list:
|
|
raise Exception("check me out 15")
|
|
self.windows_recommender.recommend(phase=0)
|
|
|
|
if "mechanical_ventilation" in measure_config_list:
|
|
raise Exception("check me out 16")
|
|
self.ventilation_recomender.recommend(phase=0)
|
|
|
|
if "gas_boiler" in measure_config_list:
|
|
raise Exception("check me out 17")
|
|
self.heating_recommender.recommend(phase=0)
|
|
|
|
if "flat_roof_insulation" in measure_config_list:
|
|
raise Exception("check me out 18")
|
|
self.roof_recommender.recommend(phase=0)
|
|
|
|
if "room_in_roof_insulation" in measure_config_list:
|
|
raise Exception("check me out 19")
|
|
self.roof_recommender.recommend(phase=0)
|
|
|
|
property_representative_recommendations = Recommendations.create_representative_recommendations(
|
|
mds_recommendations, non_invasive_recommendations=[]
|
|
)
|
|
|
|
return property_representative_recommendations, errors
|
|
|
|
@staticmethod
|
|
def insert_recommendation_id(recommendations, measures, measure_name):
|
|
# Insert the recommendation identifier into this recommendation
|
|
measure_config = [m for m in measures if measure_name in m][0]
|
|
for r in recommendations:
|
|
r["recommendation_id"] = list(measure_config.values())[0]
|
|
|
|
return recommendations
|