preheat_open.api.mocks.MockApiAdapter

class preheat_open.api.mocks.MockApiAdapter(mocks_path=None)

Bases: Adapter

Mock adapter implementation for testing and development purposes.

This adapter provides simulated data and responses for testing without requiring a real backend system.

__init__(mocks_path=None)

Initialize the MockApiAdapter.

Parameters:

mocks_path (str) – Path to the directory containing mock data files

Methods

__init__([mocks_path])

Initialize the MockApiAdapter.

close()

Close connection to the building management system.

get_all_locations_collection()

Retrieve a collection containing all available locations.

get_all_locations_information()

Retrieve information about all available locations.

get_comfort_profile_setpoints(date_range, ...)

Retrieve comfort profile setpoints for a location and date range.

get_devices(location_id)

Retrieve all devices for a specific location.

get_electricity_prices(date_range, unit, ...)

Retrieve electricity prices for a unit and date range.

get_features(location_id)

Retrieve available features for a specific location.

get_location(location_id)

Retrieve a specific location by ID.

get_locations(location_ids)

Retrieve multiple locations by their IDs.

get_price_components(supply_point_ids)

Retrieve price components for specified supply points.

get_price_data(date_range, price_component_ids)

Retrieve price data for specified components and date range.

get_setpoint_schedule(control_unit, date_range)

Retrieve setpoint schedule from a control unit.

load_measurements(components, date_range[, ...])

Load measurement data for specified components and date range.

location_post_setup(location)

Perform post-setup operations on a location.

open()

Open connection to the building management system.

put_setpoint_schedule(schedule, control_unit)

Upload a setpoint schedule to a control unit.

close()

Close connection to the building management system.

This method should clean up resources, close connections, and perform any necessary cleanup operations.

get_all_locations_collection()

Retrieve a collection containing all available locations.

Returns:

Collection with all locations

Return type:

Collection

get_all_locations_information()

Retrieve information about all available locations.

Returns:

List of location information objects

Return type:

list[LocationInformation]

get_comfort_profile_setpoints(date_range, location)

Retrieve comfort profile setpoints for a location and date range.

Parameters:
  • date_range (DateRange) – Time range for the comfort profiles

  • location (Location | int) – Location object or location ID

Returns:

List of comfort profiles

Return type:

list[ComfortProfile]

get_devices(location_id)

Retrieve all devices for a specific location.

Parameters:

location_id (int) – ID of the location

Returns:

List of devices in the location

Return type:

list[Device]

get_electricity_prices(date_range, unit, include_vat, include_tariff)

Retrieve electricity prices for a unit and date range.

Parameters:
  • unit (Unit) – Unit to get prices for

  • date_range (DateRange) – Time range for the prices

  • include_vat (bool) – Whether to include VAT in prices

  • include_tariff (bool) – Whether to include tariff in prices

Returns:

Electricity price data

Return type:

ElectricityPrices

get_features(location_id)

Retrieve available features for a specific location.

Parameters:

location_id (int) – ID of the location to query

Returns:

Available features for the location

get_location(location_id)

Retrieve a specific location by ID.

Parameters:

location_id (int) – ID of the location to retrieve

Returns:

Location object

Return type:

Location

Raises:

ValueError – If location ID is not found

get_locations(location_ids)

Retrieve multiple locations by their IDs.

Parameters:

location_ids (list[int]) – List of location IDs to retrieve

Returns:

List of location objects

Return type:

list[Location]

Raises:

ValueError – If any location ID is not found

get_price_components(supply_point_ids)

Retrieve price components for specified supply points.

Parameters:

supply_point_ids (list[int]) – List of supply point IDs

Returns:

Dictionary mapping supply point IDs to their price components

Return type:

dict[int, list[AppliedPriceComponent]]

get_price_data(date_range, price_component_ids, timestamp_type=TimestampType.ISO)

Retrieve price data for specified components and date range.

Parameters:
  • date_range (DateRange) – Time range for the price data

  • price_component_ids (list[int]) – List of price component IDs

Returns:

Dictionary mapping component IDs to their price data

Return type:

dict[int, PriceData]

get_setpoint_schedule(control_unit, date_range)

Retrieve setpoint schedule from a control unit.

Parameters:
  • control_unit (Unit) – Control unit to query

  • date_range (DateRange) – Time range for the schedule

Returns:

Setpoint schedule

Return type:

SetpointSchedule

load_measurements(components, date_range, timestamp_type=TimestampType.ISO)

Load measurement data for specified components and date range.

This method loads measurement data into the components’ internal storage, typically for later retrieval or analysis.

Parameters:
  • components (list[Component]) – List of components to load measurements for

  • date_range (DateRange) – Time range for the measurements

Raises:

ValueError – If components or date range is invalid

Return type:

None

location_post_setup(location)

Perform post-setup operations on a location.

This method is called after a location has been created and allows the adapter to perform any additional setup or configuration.

Parameters:

location (Location) – Location that was just created

Example:
>>> # Default implementation does nothing
>>> class TestAdapter(Adapter):
...     def location_post_setup(self, location):
...         pass  # Custom setup logic would go here
>>>
>>> # Method exists and is callable
>>> hasattr(Adapter, 'location_post_setup')
True
open()

Open connection to the building management system.

This method should establish any necessary connections, authenticate, and prepare the adapter for data operations.

Raises:

ConnectionError – If connection cannot be established

put_setpoint_schedule(schedule, control_unit)

Upload a setpoint schedule to a control unit.

Parameters:
  • schedule (SetpointSchedule) – Setpoint schedule to upload

  • control_unit (Unit) – Control unit to receive the schedule

Returns:

HTTP response from the upload operation

Return type:

Response

Raises:

ValueError – If schedule or control unit is invalid