modifying recommendation classes

This commit is contained in:
Khalim Conn-Kowlessar 2026-03-18 22:11:16 +00:00
parent 84d4263d9a
commit e92b70f9ec
3 changed files with 42 additions and 41 deletions

View file

@ -28,7 +28,7 @@ class FireplaceRecommendations(Definitions):
:return:
"""
number_open_fireplaces = int(self.property.data["number-open-fireplaces"])
number_open_fireplaces = self.property.epc_record.number_open_fireplaces
if number_open_fireplaces == 0:
return

View file

@ -56,7 +56,7 @@ class HeatingControlRecommender:
We can then consider the heating system itself
:return:
"""
if (self.property.data["mainheatc-energy-eff"] in ["Poor", "Very Poor", "Average"]) or (
if (self.property.epc_record.mainheatc_energy_eff in ["Poor", "Very Poor", "Average"]) or (
self.property.main_heating_controls["clean_description"] in ["Programmer and room thermostat"]
):
# We recommend Programmer and appliance thermostats as the heating control. This has an average energy
@ -125,10 +125,10 @@ class HeatingControlRecommender:
new_config=ending_config, old_config=self.property.main_heating_controls
)
# This upgrade will only take the heating system to average energy efficiency
if self.property.data["mainheatc-energy-eff"] in ["Poor", "Very Poor", "Average"]:
if self.property.epc_record.mainheatc_energy_eff in ["Poor", "Very Poor", "Average"]:
simulation_config["mainheatc_energy_eff_ending"] = "Good"
else:
simulation_config["mainheatc_energy_eff_ending"] = self.property.data["mainheatc-energy-eff"]
simulation_config["mainheatc_energy_eff_ending"] = self.property.epc_record.mainheatc_energy_eff
description_simulation = {
"mainheatcont-description": new_description,
@ -193,10 +193,10 @@ class HeatingControlRecommender:
)
# This upgrade will only take the heating system to average energy efficiency
# If the current system is below good, we make it good
if self.property.data["mainheatc-energy-eff"] in ["Poor", "Very Poor", "Average"]:
if self.property.epc_record.mainheatc_energy_eff in ["Poor", "Very Poor", "Average"]:
simulation_config["mainheatc_energy_eff_ending"] = "Good"
else:
simulation_config["mainheatc_energy_eff_ending"] = self.property.data["mainheatc-energy-eff"]
simulation_config["mainheatc_energy_eff_ending"] = self.property.epc_record.mainheatc_energy_eff
description_simulation = {
"mainheatcont-description": new_controls_description,
@ -208,7 +208,7 @@ class HeatingControlRecommender:
has_trvs = not needs_trvs
cost_result = self.costs.roomstat_programmer_trvs(
number_heated_rooms=int(self.property.data["number-heated-rooms"]),
number_heated_rooms=self.property.epc_record.number_heated_rooms,
has_programmer=has_programmer,
has_room_thermostat=has_room_thermostat,
has_trvs=has_trvs
@ -257,7 +257,7 @@ class HeatingControlRecommender:
if (
(self.property.main_heating_controls["thermostatic_control"] == "time and temperature zone control") or
(self.property.data["mainheatc-energy-eff"] in ["Very Good"])
(self.property.epc_record.mainheatc_energy_eff in ["Very Good"])
):
# No recommendation needed
return
@ -274,17 +274,17 @@ class HeatingControlRecommender:
)
# If the current system is below very good, we make it very good
if self.property.data["mainheatc-energy-eff"] in ["Poor", "Very Poor", "Average", "Good"]:
if self.property.epc_record.mainheatc_energy_eff in ["Poor", "Very Poor", "Average", "Good"]:
simulation_config["mainheatc_energy_eff_ending"] = "Very Good"
else:
simulation_config["mainheatc_energy_eff_ending"] = self.property.data["mainheatc-energy-eff"]
simulation_config["mainheatc_energy_eff_ending"] = self.property.epc_record.mainheatc_energy_eff
description_simulation = {
"mainheatcont-description": new_controls_description,
"mainheatc-energy-eff": simulation_config["mainheatc_energy_eff_ending"]
}
cost_result = self.costs.time_and_temperature_zone_control(
number_heated_rooms=int(self.property.data["number-heated-rooms"])
number_heated_rooms=self.property.epc_record.number_heated_rooms
)
description = (
@ -324,10 +324,10 @@ class HeatingControlRecommender:
new_config=ending_config, old_config=self.property.main_heating_controls
)
# Only adjust if the current system is below good
if self.property.data["mainheatc-energy-eff"] in ["Poor", "Very Poor"]:
if self.property.epc_record.mainheatc_energy_eff in ["Poor", "Very Poor"]:
simulation_config["mainheatc_energy_eff_ending"] = "Average"
else:
simulation_config["mainheatc_energy_eff_ending"] = self.property.data["mainheatc-energy-eff"]
simulation_config["mainheatc_energy_eff_ending"] = self.property.epc_record.mainheatc_energy_eff
description_simulation = {
"mainheatcont-description": new_controls_description,
@ -339,7 +339,7 @@ class HeatingControlRecommender:
has_bypass = self.property.main_heating_controls["auxiliary_systems"] == "bypass"
cost_result = self.costs.programmer_trvs_bypass(
number_heated_rooms=int(self.property.data["number-heated-rooms"]),
number_heated_rooms=self.property.epc_record.number_heated_rooms,
has_trvs=has_trvs,
has_programmer=has_programmer,
has_bypass=has_bypass

View file

@ -160,7 +160,7 @@ class HeatingRecommender:
"""
# We can also recommend hhr if the property doesn't have a mains has connection
no_mains = not self.property.data["mains-gas-flag"]
no_mains = not self.property.epc_record.mains_gas_flag
# If the property already has room heaters then we recommend HHR as an option since the home already has
# a variation of room heaters
@ -199,28 +199,28 @@ class HeatingRecommender:
# 2) If the property doesn't have a heating system, but it has access to the mains gas
no_heating_has_mains = self.property.main_heating["clean_description"] in [
'No system present, electric heaters assumed'
] and self.property.data["mains-gas-flag"]
] and self.property.epc_record.mains_gas_flag
# The property is using portable heaters and has access to gas mains
has_room_heaters = self.has_room_heaters and self.property.data["mains-gas-flag"]
has_room_heaters = self.has_room_heaters and self.property.epc_record.mains_gas_flag
# We also check if the property has electric heating, but it has access to the mains gas
electic_heating_has_mains = self.has_electric_heating_description and self.property.data["mains-gas-flag"]
electic_heating_has_mains = self.has_electric_heating_description and self.property.epc_record.mains_gas_flag
portable_heaters_has_mains = (
self.property.main_heating["has_portable_electric_heaters"] and self.property.data["mains-gas-flag"]
self.property.main_heating["has_portable_electric_heaters"] and self.property.epc_record.mains_gas_flag
)
# The next condition is if the home has a non-gas boiler, such as an oil boiler, with a mains gas connection
non_gas_boiler = (
self.property.main_heating["has_boiler"] and
not self.property.main_heating["has_mains_gas"] and
self.property.data["mains-gas-flag"]
self.property.epc_record.mains_gas_flag
)
# Additionally, if the property has a gas connection, is using gas heating but doesn't have a boiler,
# we recommend a boiler
non_boiler_gas_heating = (
self.property.data["mains-gas-flag"] and
self.property.epc_record.mains_gas_flag and
self.property.main_heating["has_mains_gas"] and
not self.property.main_heating["has_boiler"]
)
@ -386,7 +386,7 @@ class HeatingRecommender:
recommendation_phase = phase
if self.property.data["mainheat-energy-eff"] not in ["Poor", "Very Poor"]:
if self.property.epc_record.mainheat_energy_eff not in ["Poor", "Very Poor"]:
return
hotwater_from_mains = self.property.hotwater["clean_description"] in ["From main system"]
@ -407,7 +407,7 @@ class HeatingRecommender:
size=None,
exising_room_heaters=False,
system_change=False,
n_heated_rooms=self.property.data["number-heated-rooms"],
n_heated_rooms=self.property.epc_record.number_heated_rooms,
n_rooms=self.property.number_of_rooms,
is_electric=True
)
@ -581,7 +581,7 @@ class HeatingRecommender:
# New functions to estimate size of ASHP
estimated_load = self.estimate_peak_kw(
floor_area_m2=self.property.floor_area,
epc_primary_kwh_per_m2_yr=self.property.data["energy-consumption-current"],
epc_primary_kwh_per_m2_yr=self.property.epc_record.energy_consumption_current,
primary_to_delivered_factor=1.55, # use 1.13 if heating fuel is gas
space_heat_fraction_range=(0.35, 0.60),
hdd_base_dd=2000.0, # set from location
@ -670,7 +670,7 @@ class HeatingRecommender:
# If the property does not have existing cavity and loft insulation, we include a note that the cost
# includes the boiler upgrade scheme and that the cavity and loft need to be treated, to ensure access
# to the funding
if not non_intrusive_recommendation and self.property.data["tenure"] not in assumptions.SOCIAL_TENURES:
if not non_intrusive_recommendation and self.property.epc_record.tenure not in assumptions.SOCIAL_TENURES:
if has_cavity_or_loft_recommendations:
description = description + (
f" You must ensure that the property has an insulated cavity and "
@ -923,7 +923,7 @@ class HeatingRecommender:
# If the property is off-gas and has no heating system in place, the number of heated rooms will actually
# be 0, so we use the number of rooms as the figure
number_heated_rooms = (
self.property.data["number-heated-rooms"] if self.property.data["number-heated-rooms"] > 0
self.property.epc_record.number_heated_rooms if self.property.epc_record.number_heated_rooms > 0
else (
self.property.number_of_rooms - 1 if self.property.number_of_rooms > 1 else
self.property.number_of_rooms
@ -949,20 +949,20 @@ class HeatingRecommender:
}
# Fallback if property type unknown
base = base_by_type.get(self.property.data["property-type"], 1)
base = base_by_type.get(self.property.epc_record.property_type, 1)
# Area-based adjustments
if self.property.data["property-type"] in ("Flat", "Maisonette"):
if self.property.epc_record.property_type in ("Flat", "Maisonette"):
if self.property.floor_area > 90:
return base + 1 # duplex or very large flat
return base
if self.property.data["property-type"] == "Bungalow":
if self.property.epc_record.property_type == "Bungalow":
if self.property.floor_area > 100:
return base + 1 # secondary corridor
return base
if self.property.data["property-type"] == "House":
if self.property.epc_record.property_type == "House":
if self.property.floor_area > 140:
return base + 1 # extra landing / circulation
return base
@ -1060,17 +1060,17 @@ class HeatingRecommender:
**hot_water_simulation_config
}
# This upgrade will only take the heating system to average energy efficiency
if self.property.data["mainheat-energy-eff"] in ["Very Poor", "Poor"] and not self.dual_heating:
if self.property.epc_record.mainheat_energy_eff in ["Very Poor", "Poor"] and not self.dual_heating:
heating_simulation_config["mainheat_energy_eff_ending"] = "Average"
else:
heating_simulation_config["mainheat_energy_eff_ending"] = self.property.data["mainheat-energy-eff"]
heating_simulation_config["mainheat_energy_eff_ending"] = self.property.epc_record.mainheat_energy_eff
# TODO:We possibly shouldn't touch the hot water energy efficiency if we aren't recommending dual immersion
# we'll keep this for the moment though
if self.property.data["hot-water-energy-eff"] in ["Very Poor", "Poor"]:
if self.property.epc_record.hot_water_energy_eff in ["Very Poor", "Poor"]:
heating_simulation_config["hot_water_energy_eff_ending"] = "Average"
else:
heating_simulation_config["hot_water_energy_eff_ending"] = self.property.data["hot-water-energy-eff"]
heating_simulation_config["hot_water_energy_eff_ending"] = self.property.epc_record.hot_water_energy_eff
number_heated_rooms = self._estimate_n_heated_rooms()
@ -1261,11 +1261,12 @@ class HeatingRecommender:
boiler_recommendation = {}
description_simulation = {}
has_inefficient_space_heating = self.property.data["mainheat-energy-eff"] in ["Very Poor", "Poor", "Average"]
has_inefficient_space_heating = self.property.epc_record.mainheat_energy_eff in ["Very Poor", "Poor", "Average"]
# We check if there's a mains connection and the hot water is inefficient, as this will improve with a boiler
has_inefficient_water = (
self.property.data["mains-gas-flag"] and self.property.data["hot-water-energy-eff"] in ["Very Poor", "Poor"]
self.property.epc_record.mains_gas_flag and self.property.epc_record.hot_water_energy_eff in ["Very Poor",
"Poor"]
)
non_invasive_recommendation = next((
@ -1281,13 +1282,13 @@ class HeatingRecommender:
)
new_heating_eff = (
"Good" if self.property.data["mainheat-energy-eff"] in ["Very Poor", "Poor", "Average"]
else self.property.data["mainheat-energy-eff"]
"Good" if self.property.epc_record.mainheat_energy_eff in ["Very Poor", "Poor", "Average"]
else self.property.epc_record.mainheat_energy_eff
)
new_hotwater_eff = (
"Good" if self.property.data["hot-water-energy-eff"] in ["Very Poor", "Poor", "Average"]
else self.property.data["hot-water-energy-eff"]
"Good" if self.property.epc_record.hot_water_energy_eff in ["Very Poor", "Poor", "Average"]
else self.property.epc_record.hot_water_energy_eff
)
simulation_config = {
@ -1343,7 +1344,7 @@ class HeatingRecommender:
boiler_costs = self.costs.boiler(
exising_room_heaters=exising_room_heaters,
system_change=system_change,
n_heated_rooms=self.property.data["number-heated-rooms"],
n_heated_rooms=self.property.epc_record.number_heated_rooms,
n_rooms=self.property.number_of_rooms
)