from typing import Dict, Union from epc_data.attributes.attribute_utils import clean_description class MainheatControlAttributes: CONTROL_SYSTEM_KEYWORDS = [ "charging system", "flat rate charging", "no thermostatic control", "programmer", "room thermostats", "trvs", "bypass", "flow switch", "automatic charge control", "manual charge control", "temperature zone control", "time and temperature zone control", "high heat retention storage heaters", "appliance thermostats", "dhw only", "no time or thermostatic control", "room thermostat" ] # These systems allow for the automatic regulation of temperature THERMOSTATIC_CONTROL_KEYWORDS = [] # These systems provide a way to store and manage energy usage CHARGING_SYSTEM_KEYWORDS = [] # These systems are mainly focused on on/off operations SWITCH_SYSTEM_KEYWORDS = [] # hese keywords indicate a lack of control system NO_CONTROL_SYSTEM_KEYWORDS = ["none"] # These systems provide control specifically for Domestic Hot Water DHW_CONTROL_KEYWORDS = [] def __init__(self, description: str): self.description: str = clean_description(description.lower()) # In the case of an empty description, we want to return a dictionary with all values set to False # and indicate there was no data self.nodata = not description or self.description in self.NO_CONTROL_SYSTEM_KEYWORDS if not self.nodata: if not any(keyword in self.description for keyword in self.CONTROL_SYSTEM_KEYWORDS): raise ValueError('Invalid description') def process(self) -> Dict[str, Union[str, bool]]: result: Dict[str, Union[str, bool]] = { "no_data": self.nodata } if self.nodata: return result # We consolidate CONTROL_SYSTEM_KEYWORDS into separate attributes for keyword in self.CONTROL_SYSTEM_KEYWORDS: result[f'has_{keyword.replace(" ", "_")}'] = keyword in self.description return result