flexmeasures.utils.entity_address_utils.build_ea_scheme_and_naming_authority(host: str, host_auth_start_month: str | None = None) str

This function creates the host identification part of USEF’s EA1 addressing scheme, so everything but the locally unique string.

If not given nor configured, host_auth_start_month is the start of the next month for localhost.

flexmeasures.utils.entity_address_utils.build_entity_address(entity_info: dict, entity_type: str, host: str | None = None, fm_scheme: str = 'fm1') str

Build an entity address.

fm1 type entity address should use entity_info[“sensor_id”] todo: implement entity addresses for actuators with entity_info[“actuator_id”] (first ensuring globally unique ids across sensors and actuators)

If the host is not given, it is attempted to be taken from the request. entity_info is expected to contain the required fields for the custom string.

Returns the address as string.

flexmeasures.utils.entity_address_utils.get_domain_parts(domain: str) ExtractResult

wrapper for calling tldextract as it logs things about file locks we don’t care about.

flexmeasures.utils.entity_address_utils.get_host() str

Get host from the context of the request.

Strips off www. but keeps subdomains. Can be localhost, too.

flexmeasures.utils.entity_address_utils.parse_entity_address(entity_address: str, entity_type: str, fm_scheme: str = 'fm1') dict

Parses an entity address into an info dict.

Returns a dictionary with scheme, naming_authority and various other fields, depending on the entity type and FlexMeasures scheme (see examples above). Returns None if entity type is unknown or entity_address is not parse-able. We recommend to return invalid_domain() in that case.

Examples for the fm1 scheme:

sensor = ea1.2021-01.io.flexmeasures:fm1.42 sensor = ea1.2021-01.io.flexmeasures:fm1.<sensor_id> connection = ea1.2021-01.io.flexmeasures:fm1.<sensor_id> market = ea1.2021-01.io.flexmeasures:fm1.<sensor_id> weather_station = ea1.2021-01.io.flexmeasures:fm1.<sensor_id> todo: UDI events are not yet modelled in the fm1 scheme, but will probably be ea1.2021-01.io.flexmeasures:fm1.<actuator_id>

Examples for the fm0 scheme:

connection = ea1.2021-01.localhost:fm0.40:30 connection = ea1.2021-01.io.flexmeasures:fm0.<owner_id>:<asset_id> weather_sensor = ea1.2021-01.io.flexmeasures:fm0.temperature:52:73.0 weather_sensor = ea1.2021-01.io.flexmeasures:fm0.<sensor_type>:<latitude>:<longitude> market = ea1.2021-01.io.flexmeasures:fm0.epex_da market = ea1.2021-01.io.flexmeasures:fm0.<market_name> event = ea1.2021-01.io.flexmeasures:fm0.40:30:302:soc event = ea1.2021-01.io.flexmeasures:fm0.<owner_id>:<asset_id>:<event_id>:<event_type>

For the fm0 scheme, the ‘fm0.’ part is optional, for backwards compatibility.

flexmeasures.utils.entity_address_utils.reverse_domain_name(domain: str | TldExtractResult) str

Returns the reverse notation of the domain. You can pass in a string domain or an extraction result from tldextract


exception flexmeasures.utils.entity_address_utils.EntityAddressException