Example of working with zone in buildings

This notebook is an introduction to working with zone data in the preheat_open toolbox.

[1]:
from preheat_open import set_logging_level, test
set_logging_level("WARNING") # prevent annoying info logs from printing
from preheat_open.building import Building
2022-03-18 11:22:28,351  INFO      api                               Loading config from /home/ask/.preheat/config.json                                                                                                                .(api.py:126)

We load the API test location

[2]:
b = Building(2756)
print(b)
Building(2756): API test location - TEST

While Preheat units describe the “moving parts” of a building structure, the zones describe the physical layout of the building. To get a list of the zones of a building we call its zones attribute

[3]:
b.zones
[3]:
[Zone(Zone_A), Zone(Zone_B)]

Every zone has as unique id given by the id attribute

[4]:
z = b.zones[0]
z.id
[4]:
4829

We can use the zone id when querying zones from the building by providing a list of ids to the get_zones method which returns a list of zones.

[5]:
b.get_zones([z.id])
[5]:
[Zone(Zone_A)]

To learn about the type of a zone we use the get_type method which returns the type of the zone, e.g. ‘stairway’, ‘corridor’ or ‘bathroom’, and its dryness, i.e. ‘dry’, ‘wet’ or ‘?’ (for unknown dryness)

[6]:
z.get_type()
[6]:
('stairway', 'dry')

Finding the units of a zone

Zones usually have associated units, such as secondary heating or indoor climate units. Using the get_units method we can query for the units of a given type, such as secondaries. The optional boolean flag sub_zones (defaults to True) tells the method whether to recursively query sub zones or not.

[11]:
print("Units coupled to the zone itself:", z.get_unit_types(sub_zones=False))
print("Units coupled to the zone and sub zones:", z.get_unit_types())
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_16425/3029097866.py in <module>
----> 1 print("Units coupled to the zone itself:", z.get_unit_types(sub_zones=False))
      2 print("Units coupled to the zone and sub zones:", z.get_unit_types())

AttributeError: 'Zone' object has no attribute 'get_unit_types'

Say we are interested in a list of all the indoor climate units connected to the zone we use get_units (with the sub_zones flag working similarly to before)

[ ]:
print("Indoor climate units coupled to the zone itself:", z.get_units("indoorClimate", sub_zones=False))
print("Inddoor climate units coupled to the zone and/or sub zones:", z.get_units("indoorClimate"))

Finding the zone of a unit

Next we wish to consider a unit and determine its associated zone(s). Consider an arbitrary indoor climate unit and list its associated zone id(s)

[ ]:
ic = b.query_units("indoorClimate")[0]
ic.zone_ids

These can then be called from the building using the get_zones method.