diff --git a/backend/Property.py b/backend/Property.py index f196f49b..e2ff651a 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -660,8 +660,6 @@ class Property: self.set_floor_type() self.set_floor_level() self.set_windows_count() - self.set_energy_source() - self.find_energy_sources() self.set_current_energy(kwh_client, kwh_predictions) def set_solar_panel_configuration(self, solar_panel_configuration): @@ -1168,202 +1166,6 @@ class Property: if condition_data.get("windows_area") is not None \ else None - def set_energy_source(self): - """ - This method sets the energy source of the property, based on the mains gas flag and energy tariff. - """ - # Default to "electricity_and_gas" to cover most scenarios including when mains_gas_flag is True - energy_source = "electricity_and_gas" - - # If the tariff explicitly indicates electricity use without a dual indication and mains_gas_flag is not True - # We check for the common electricity tariffs - if not self.data["mains-gas-flag"] and self.data["energy-tariff"] in [ - "Single", - "off-peak 7 hour", - "off-peak 10 hour", - "off-peak 18 hour", - "standard tariff", - "24 hour", - ]: - energy_source = "electricity" - - # Set the energy source based on the conditions above - self.energy_source = energy_source - - def find_energy_sources(self): - # Based on the heating and the hot water - heating_fuel_mapping = { - 'has_mains_gas': 'Natural Gas', - 'has_electric': 'Electricity', - 'has_oil': 'Oil', - 'has_wood_logs': 'Wood Logs', - 'has_coal': 'Coal', - 'has_anthracite': 'Anthracite', - 'has_smokeless_fuel': 'Smokeless Fuel', - 'has_lpg': 'LPG', - 'has_b30k': 'B30K Biofuel', - 'has_air_source_heat_pump': 'Electricity', - 'has_ground_source_heat_pump': 'Electricity', - 'has_water_source_heat_pump': 'Electricity', - 'has_electric_heat_pump': 'Electricity', - 'has_solar_assisted_heat_pump': 'Electricity', - 'has_exhaust_source_heat_pump': 'Electricity', - 'has_community_heat_pump': 'Electricity', - 'has_wood_pellets': 'Wood Pellets', - 'has_community_scheme': 'Varied (Community Scheme)', - "has_dual_fuel_mineral_and_wood": 'Wood Logs', - "has_electricaire": 'Electricity', - "has_wood_chips": 'Wood Logs' - } - - # Hot water - heater_type_to_fuel = { - 'gas instantaneous': 'Natural Gas', - 'electric heat pump': 'Electricity', - 'electric immersion': 'Electricity', - 'gas boiler': 'Natural Gas', - 'oil boiler': 'Oil', - 'electric instantaneous': 'Electricity', - 'gas multipoint': 'Natural Gas', - 'heat pump': 'Electricity', - 'solid fuel boiler': 'Solid Fuel', - 'solid fuel range cooker': 'Solid Fuel', - 'room heaters': 'Varied', # Could be any fuel, further specifics needed based on context - "single-point gas": "Natural Gas" - } - - # Define a mapping from system types to general categories or modifications of fuel types - system_type_modification = { - 'from main system': 'Main System', - 'from secondary system': 'Secondary System', - 'from second main heating system': 'Secondary System', - 'community scheme': 'Community Scheme' - } - - hotwater_appliance_to_fuel = { - 'gas range cooker': 'Natural Gas', - 'oil range cooker': 'Oil' - } - - fuel_map = { - None: "Natural Gas (Community Scheme)", - "mains gas": "Natural Gas (Community Scheme)", - "biomass": "Smokeless Fuel", - "electricity": "Electricity", - "biogas": "Smokeless Fuel", - "heat network": "Natural Gas (Community Scheme)", - "lpg": 'LPG', - "biodiesel": "Smokeless Fuel", - "b30d": "B30K Biofuel", - "coal": "Coal", - "oil": "Oil", - "unknown": None # Handle - anything post 2020 is electricity else gas - } - - self.heating_energy_source = list({ - fuel for key, fuel in heating_fuel_mapping.items() if self.main_heating.get(key, False) - }) - - if set(self.heating_energy_source) == {'Electricity', 'Natural Gas'}: - # It means they have mixed heating so we take the primary one, based on main fuel - # This will probably happen in the case of an extension - if self.main_fuel["clean_description"] in ["Mains gas not community", "Mains gas community"]: - self.heating_energy_source = ['Natural Gas'] - else: - self.heating_energy_source = ['Electricity'] - - if set(self.heating_energy_source) == {'Electricity', 'LPG'}: - if self.main_fuel["clean_description"] in ["Lpg not community", "Lpg community"]: - self.heating_energy_source = ['LPG'] - else: - self.heating_energy_source = ['Electricity'] - - if set(self.heating_energy_source) == {'Natural Gas', 'Wood Logs'}: - # It means they have mixed heating so we take the primary one, based on main fuel - # This will probably happen in the case of an extension - if self.main_fuel["clean_description"] in ["Mains gas not community", "Mains gas community"]: - self.heating_energy_source = ['Natural Gas'] - else: - self.heating_energy_source = ['Wood Logs'] - - if len(self.heating_energy_source) > 1 and "Varied (Community Scheme)" not in self.heating_energy_source: - # We might have something like heating energy source equal to ['Natural Gas', 'Varied (Community Scheme)'] - # so we treat this as community heating - raise Exception("Investigate me") - - if len(self.heating_energy_source) == 0: - heating_flags = { - v for k, v in self.main_heating.items() if k not in ["original_description", "clean_description"] - } - hotwater_flags = { - v for k, v in self.hotwater.items() if k not in ["original_description", "clean_description"] - } - - # If all flags are zero, we have a no data example - if (heating_flags == {False} or hotwater_flags == {None}) and ( - hotwater_flags == {False} or hotwater_flags == {None}): - # We have nodata so we try and rely on main fuel - if self.main_fuel["fuel_type"] in fuel_map: # We assume when None as it's unknown - mapped_fuel = fuel_map[self.main_fuel["fuel_type"]] - self.heating_energy_source = mapped_fuel - self.hot_water_energy_source = mapped_fuel - return - else: - raise NotImplementedError(f"Unhandled fuel {self.main_fuel['fuel_type']}") - - # We handle edge case where no heating system is indicated - if self.main_fuel["fuel_type"] in fuel_map: - mapped_fuel = fuel_map[self.main_fuel["fuel_type"]] - self.heating_energy_source = mapped_fuel - self.hot_water_energy_source = mapped_fuel - return - - if len(self.heating_energy_source) > 1: - # We treat this as a community scheme - self.heating_energy_source = ["Varied (Community Scheme)"] - - self.heating_energy_source = self.heating_energy_source[0] - - if self.heating_energy_source == "Varied (Community Scheme)": - - if self.main_fuel["fuel_type"] in fuel_map: # We assume when None as it's unknown - mapped_to = fuel_map[self.main_fuel["fuel_type"]] - if mapped_to is None and self.main_fuel["fuel_type"] == "unknown": - # Handle logic based on age band - if self.year_built >= 2020: - self.heating_energy_source = "Electricity" - else: - self.heating_energy_source = "Natural Gas (Community Scheme)" - - else: - self.heating_energy_source = mapped_to - else: - raise NotImplementedError(f"Unhandled fuel {self.main_fuel['fuel_type']}") - - if self.hotwater["heater_type"] is not None: - self.hot_water_energy_source = heater_type_to_fuel[self.hotwater["heater_type"]] - - if self.hotwater["extra_features"] == "plus solar": - self.hot_water_energy_source = self.heating_energy_source + " + Solar Thermal" - return - elif self.hotwater["system_type"] is not None: - fuel = system_type_modification[self.hotwater["system_type"]] - - if self.hotwater["extra_features"] == "plus solar": - self.hot_water_energy_source = self.heating_energy_source + " + Solar Thermal" - return - - if fuel in ['Main System', "Community Scheme"]: - self.hot_water_energy_source = self.heating_energy_source - elif fuel in ['Secondary System']: - # Check the secondary heating system - secondary_heating = self.data["secondheat-description"] - self.hot_water_energy_source = assumptions.DESCRIPTIONS_TO_FUEL_TYPES[secondary_heating]["fuel"] - else: - raise NotImplementedError(f"Investiage me - unhandled hot water fuel {fuel}") - else: - self.hot_water_energy_source = hotwater_appliance_to_fuel[self.hotwater["appliance"]] - def is_ashp_valid(self, measures): if "air_source_heat_pump" in self.non_invasive_recommendations: