2020 from honeybee_energy .load .infiltration import Infiltration
2121 from honeybee_energy .properties .face import FaceEnergyProperties
2222 from honeybee_energy .properties .room import RoomEnergyProperties
23+ from honeybee_energy .schedule .ruleset import ScheduleRuleset
2324except ImportError as e :
2425 raise ImportError ("\n Failed to import honeybee_energy:\n \t {}" .format (e ))
2526
5152logger = logging .getLogger ()
5253
5354
55+ def _get_hb_room_energy_properties (_hb_room : room .Room ) -> RoomEnergyProperties | None :
56+ """Get the Honeybee-Room's Energy Properties.
57+
58+ Arguments:
59+ ----------
60+ *_hb_room: (room.Room) The Honeybee Room to get the Energy Properties from.
61+
62+ Returns:
63+ --------
64+ * (RoomEnergyProperties): The Honeybee-Room's Energy Properties.
65+ """
66+ return getattr (_hb_room .properties , "energy" , None )
67+
68+
69+ def _get_hb_room_energy_electric_equipment (_hb_room : room .Room ) -> equipment .ElectricEquipment | None :
70+ """Get the Honeybee-Room's Energy Electric Equipment Properties.
71+
72+ Arguments:
73+ ----------
74+ *_hb_room: (room.Room) The Honeybee Room to get the Energy Electric Equipment Properties from.
75+
76+ Returns:
77+ --------
78+ * (equipment.ElectricEquipment): The Honeybee-Room's Energy Electric Equipment Properties.
79+ """
80+ energy_properties = _get_hb_room_energy_properties (_hb_room )
81+ if energy_properties is None :
82+ return None
83+ return energy_properties .electric_equipment
84+
85+
5486def _dup_face (_hb_face : face .Face ) -> face .Face :
5587 """Duplicate a Honeybee Face and all it's properties.
5688
@@ -301,6 +333,23 @@ def merge_elec_equip(_hb_rooms: List[room.Room]) -> equipment.ElectricEquipment:
301333 with values merged from the HB-Rooms.
302334 """
303335
336+ # -- Filter out any HB-Rooms which do not have an Energy Properties object
337+ _hb_rooms = [rm for rm in _hb_rooms if _get_hb_room_energy_properties (rm ) is not None ]
338+
339+ # -- Filter out any HB-Rooms which do not have ElectricEquipment
340+ _hb_rooms = [rm for rm in _hb_rooms if _get_hb_room_energy_electric_equipment (rm ) is not None ]
341+ if not _hb_rooms :
342+ msg = "Warning: No Honeybee-Rooms with Electric Equipment found."
343+ print (msg )
344+ return equipment .ElectricEquipment (
345+ identifier = "default_electric_equipment" ,
346+ watts_per_area = 0.0 ,
347+ schedule = ScheduleRuleset .from_constant_value (
348+ identifier = "default_electric_equipment_schedule" ,
349+ value = 0.0 ,
350+ ),
351+ )
352+
304353 # -- Collect all the unique PH-Equipment in all the rooms.
305354 # -- Increase the quantity for each duplicate piece of equipment found.
306355 ph_equipment = {}
@@ -318,10 +367,10 @@ def merge_elec_equip(_hb_rooms: List[room.Room]) -> equipment.ElectricEquipment:
318367 ph_equipment [equip_key ] = equip
319368
320369 # -- Calculate the total Watts of all of the HBE-Elec-Equipment in the rooms
321- total_floor_area = sum (rm .floor_area for rm in _hb_rooms )
370+ total_floor_area = sum (rm .floor_area for rm in _hb_rooms ) or 0.0
322371 total_watts = sum (
323372 (rm .floor_area * rm .properties .energy .electric_equipment .watts_per_area ) for rm in _hb_rooms # type: ignore
324- )
373+ ) or 0.0
325374
326375 # -- Build a new HBE-Elec-Equip from the reference room, add all the PH-Equipment to it.
327376 reference_room = _hb_rooms [0 ]
0 commit comments