mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Map to domain from 17.0 schema 🟩
This commit is contained in:
parent
eddeb2c516
commit
771eaf7eb4
2 changed files with 142 additions and 3 deletions
|
|
@ -24,8 +24,8 @@ class MainHeatingDetail:
|
|||
main_fuel_type: Union[int, str] # int from API, str from site notes
|
||||
heat_emitter_type: Union[int, str] # int from API, str from site notes
|
||||
emitter_temperature: Union[int, str]
|
||||
fan_flue_present: bool
|
||||
main_heating_control: Union[int, str] # int from API, str from site notes
|
||||
fan_flue_present: Optional[bool] = None
|
||||
boiler_flue_type: Optional[int] = None # TODO: make enum?
|
||||
boiler_ignition_type: Optional[int] = None # TODO: make enum?
|
||||
central_heating_pump_age: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -150,8 +150,145 @@ class EpcPropertyDataMapper:
|
|||
)
|
||||
|
||||
@staticmethod
|
||||
def from_rdsap_schema_17_0(_schema: RdSapSchema17_0) -> EpcPropertyData:
|
||||
raise NotImplementedError
|
||||
def from_rdsap_schema_17_0(schema: RdSapSchema17_0) -> EpcPropertyData:
|
||||
es = schema.sap_energy_source
|
||||
return EpcPropertyData(
|
||||
uprn=schema.uprn,
|
||||
assessment_type=schema.assessment_type,
|
||||
sap_version=schema.sap_version,
|
||||
dwelling_type=schema.dwelling_type.value,
|
||||
property_type=str(schema.property_type),
|
||||
built_form=str(schema.built_form),
|
||||
address_line_1=schema.address_line_1,
|
||||
address_line_2=schema.address_line_2,
|
||||
postcode=schema.postcode,
|
||||
post_town=schema.post_town,
|
||||
status=schema.status,
|
||||
tenure=str(schema.tenure),
|
||||
transaction_type=str(schema.transaction_type),
|
||||
inspection_date=date.fromisoformat(schema.inspection_date),
|
||||
completion_date=date.fromisoformat(schema.completion_date),
|
||||
registration_date=date.fromisoformat(schema.registration_date),
|
||||
total_floor_area_m2=float(schema.total_floor_area),
|
||||
solar_water_heating=schema.solar_water_heating == "Y",
|
||||
has_hot_water_cylinder=schema.has_hot_water_cylinder == "true",
|
||||
has_fixed_air_conditioning=schema.has_fixed_air_conditioning == "true",
|
||||
conservatory_type=schema.conservatory_type,
|
||||
has_conservatory=schema.conservatory_type != 1,
|
||||
door_count=schema.door_count,
|
||||
habitable_rooms_count=schema.habitable_room_count,
|
||||
heated_rooms_count=schema.heated_room_count,
|
||||
wet_rooms_count=0,
|
||||
extensions_count=schema.extensions_count,
|
||||
open_chimneys_count=0,
|
||||
insulated_door_count=schema.insulated_door_count,
|
||||
draughtproofed_door_count=None,
|
||||
led_fixed_lighting_bulbs_count=0,
|
||||
cfl_fixed_lighting_bulbs_count=0,
|
||||
incandescent_fixed_lighting_bulbs_count=0,
|
||||
roofs=EpcPropertyDataMapper._map_energy_elements(schema.roofs),
|
||||
walls=EpcPropertyDataMapper._map_energy_elements(schema.walls),
|
||||
floors=EpcPropertyDataMapper._map_energy_elements(schema.floors),
|
||||
main_heating=EpcPropertyDataMapper._map_energy_elements(
|
||||
schema.main_heating
|
||||
),
|
||||
window=EpcPropertyDataMapper._map_energy_element(schema.window),
|
||||
lighting=EpcPropertyDataMapper._map_energy_element(schema.lighting),
|
||||
hot_water=EpcPropertyDataMapper._map_energy_element(schema.hot_water),
|
||||
secondary_heating=EpcPropertyDataMapper._map_energy_element(
|
||||
schema.secondary_heating
|
||||
),
|
||||
sap_heating=SapHeating(
|
||||
instantaneous_wwhrs=InstantaneousWwhrs(),
|
||||
main_heating_details=[
|
||||
MainHeatingDetail(
|
||||
has_fghrs=d.has_fghrs == "Y",
|
||||
main_fuel_type=d.main_fuel_type,
|
||||
boiler_flue_type=None,
|
||||
fan_flue_present=None,
|
||||
heat_emitter_type=d.heat_emitter_type,
|
||||
emitter_temperature=d.emitter_temperature,
|
||||
main_heating_number=d.main_heating_number,
|
||||
main_heating_control=d.main_heating_control,
|
||||
main_heating_category=d.main_heating_category,
|
||||
main_heating_fraction=d.main_heating_fraction,
|
||||
sap_main_heating_code=d.sap_main_heating_code,
|
||||
central_heating_pump_age=None,
|
||||
main_heating_data_source=d.main_heating_data_source,
|
||||
main_heating_index_number=None,
|
||||
)
|
||||
for d in schema.sap_heating.main_heating_details
|
||||
],
|
||||
has_fixed_air_conditioning=schema.sap_heating.has_fixed_air_conditioning
|
||||
== "true",
|
||||
cylinder_size=schema.sap_heating.cylinder_size,
|
||||
water_heating_code=schema.sap_heating.water_heating_code,
|
||||
water_heating_fuel=schema.sap_heating.water_heating_fuel,
|
||||
immersion_heating_type=schema.sap_heating.immersion_heating_type,
|
||||
cylinder_insulation_type=schema.sap_heating.cylinder_insulation_type,
|
||||
cylinder_thermostat=None,
|
||||
secondary_fuel_type=None,
|
||||
secondary_heating_type=None,
|
||||
cylinder_insulation_thickness=None,
|
||||
),
|
||||
sap_windows=[],
|
||||
sap_energy_source=SapEnergySource(
|
||||
mains_gas=es.mains_gas == "Y",
|
||||
meter_type=str(es.meter_type),
|
||||
pv_battery_count=0,
|
||||
wind_turbines_count=es.wind_turbines_count,
|
||||
gas_smart_meter_present=False,
|
||||
is_dwelling_export_capable=False,
|
||||
wind_turbines_terrain_type=str(es.wind_turbines_terrain_type),
|
||||
electricity_smart_meter_present=False,
|
||||
photovoltaic_supply=(
|
||||
PhotovoltaicSupply(
|
||||
none_or_no_details=PhotovoltaicSupplyNoneOrNoDetails(
|
||||
percent_roof_area=es.photovoltaic_supply.none_or_no_details.percent_roof_area,
|
||||
)
|
||||
)
|
||||
if es.photovoltaic_supply
|
||||
else None
|
||||
),
|
||||
),
|
||||
sap_building_parts=[
|
||||
SapBuildingPart(
|
||||
identifier=bp.identifier,
|
||||
construction_age_band=bp.construction_age_band,
|
||||
wall_construction=bp.wall_construction,
|
||||
wall_insulation_type=bp.wall_insulation_type,
|
||||
wall_thickness_measured=bp.wall_thickness_measured == "Y",
|
||||
party_wall_construction=bp.party_wall_construction,
|
||||
sap_floor_dimensions=[
|
||||
SapFloorDimension(
|
||||
room_height_m=fd.room_height.value,
|
||||
total_floor_area_m2=fd.total_floor_area.value,
|
||||
party_wall_length_m=(
|
||||
float(fd.party_wall_length)
|
||||
if isinstance(fd.party_wall_length, int)
|
||||
else fd.party_wall_length.value
|
||||
),
|
||||
heat_loss_perimeter_m=fd.heat_loss_perimeter.value,
|
||||
floor=fd.floor,
|
||||
floor_insulation=None,
|
||||
floor_construction=None,
|
||||
)
|
||||
for fd in bp.sap_floor_dimensions
|
||||
],
|
||||
building_part_number=bp.building_part_number,
|
||||
wall_dry_lined=bp.wall_dry_lined == "Y",
|
||||
wall_thickness_mm=bp.wall_thickness,
|
||||
wall_insulation_thickness=bp.wall_insulation_thickness,
|
||||
floor_heat_loss=bp.floor_heat_loss,
|
||||
floor_insulation_thickness=None,
|
||||
roof_construction=bp.roof_construction,
|
||||
roof_insulation_location=bp.roof_insulation_location,
|
||||
roof_insulation_thickness=bp.roof_insulation_thickness,
|
||||
sap_room_in_roof=None,
|
||||
)
|
||||
for bp in schema.sap_building_parts
|
||||
],
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_rdsap_schema_17_1(schema: RdSapSchema17_1) -> EpcPropertyData:
|
||||
|
|
@ -1223,6 +1360,7 @@ class EpcPropertyDataMapper:
|
|||
@staticmethod
|
||||
def _map_energy_element(
|
||||
element: Union[
|
||||
EnergyElement_17_0,
|
||||
EnergyElement_17_1,
|
||||
EnergyElement_18_0,
|
||||
EnergyElement_19_0,
|
||||
|
|
@ -1246,6 +1384,7 @@ class EpcPropertyDataMapper:
|
|||
def _map_energy_elements(
|
||||
elements: Sequence[
|
||||
Union[
|
||||
EnergyElement_17_0,
|
||||
EnergyElement_17_1,
|
||||
EnergyElement_18_0,
|
||||
EnergyElement_19_0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue