flexmeasures.data.queries.generic_assets

Functions

flexmeasures.data.queries.generic_assets.get_asset_group_queries(group_by_type: bool = True, group_by_account: bool = False, group_by_location: bool = False, custom_aggregate_type_groups: dict[str, list[str]] | None = None) dict[str, Select]

An asset group is defined by Asset queries, which this function can generate. Each query has a name (for the asset group it represents). These queries still need an executive call, like all(), count() or first(). This function limits the assets to be queried to the current user’s account, if the user is not an admin. Note: Make sure the current user has the “read” permission on their account (on GenericAsset.__class__?? See https://github.com/FlexMeasures/flexmeasures/issues/200) or is an admin. :param group_by_type: If True, groups will be made for assets with the same type. We prefer pluralised group names here. Defaults to True. :param group_by_account: If True, groups will be made for assets within the same account. This makes sense for admins, as they can query across accounts. :param group_by_location: If True, groups will be made for assets at the same location. Naming of the location currently supports charge points (for EVSEs). :param custom_aggregate_type_groups: dict of asset type groupings (mapping group names to names of asset types). See also the setting FLEXMEASURES_ASSET_TYPE_GROUPS.

flexmeasures.data.queries.generic_assets.get_location_queries(account_id: int | None = None) dict[str, Select[tuple[GenericAsset]]]

Make queries for grouping assets by location.

We group EVSE assets by location (if they share a location, they belong to the same Charge Point) Like get_asset_group_queries, the values in the returned dict still need an executive call, like all(), count() or first(). Note that this function will still load and inspect assets to do its job.

The Charge Points are named on the basis of the first EVSE in their list, using either the whole EVSE name or that part that comes before a “ -” delimiter. For example: If:

evse_name = “Seoul Hilton - charger 1”

Then:

charge_point_name = “Seoul Hilton (Charge Point)”

A Charge Point is a special case. If all assets on a location are of type EVSE, we can call the location a “Charge Point”.

Parameters:

account_id – Pass in an account ID if you want to query an account other than your own. This only works for admins. Public assets are always queried.

flexmeasures.data.queries.generic_assets.group_assets_by_location(asset_list: list[GenericAsset]) list[list[GenericAsset]]
flexmeasures.data.queries.generic_assets.query_assets_by_type(type_names: list[str] | str, account_id: int | None = None, query: Select | None = None) Select

Return a query which looks for GenericAssets by their type.

Parameters:
  • type_names – Pass in a list of type names or only one type name.

  • account_id – Pass in an account ID if you want to query an account other than your own. This only works for admins. Public assets are always queried.

  • query – Pass in an existing Query object if you have one.