smia.assetconnection.mqtt_asset_connection module

class smia.assetconnection.mqtt_asset_connection.MQTTAssetConnection[source]

Bases: AssetConnection

This class implements the asset connection for MQTT protocol. It inherits from the valid official class defined by SMIA.

async configure_connection_by_aas_model(interface_aas_elem)[source]

This method configures the Asset Connection using the interface element defined in the AAS model.

Parameters:

interface_aas_elem (basyx.aas.model.SubmodelElement) – element of the AAS model with the asset interface information.

async check_asset_connection()[source]

This method checks the Asset Connection.

async connect_with_asset()[source]

This method performs the connection process to the Asset Connection.

async execute_asset_service(interaction_metadata, service_input_data=None)[source]

This method sends a message to the asset and returns the response. The connection of the interface of the asset is already configured in ‘configure_connection_by_aas_model’ method, but the interaction metadata is provided in form of a Python object of AAS model (SubmodelElement).

Parameters:
  • interaction_metadata (basyx.aas.model.SubmodelElement) – element of the AAS model with all metadata for the interaction with the asset.

  • service_input_data – object with the input data of the service

Returns:

response information defined in the interaction metadata.

Return type:

object

async receive_msg_from_asset()[source]

This method receives a message from the asset through the Asset Connection.

async extract_general_interaction_metadata(interaction_metadata)[source]

This method extracts the general interaction information from the interaction metadata object. Since this is an MQTT Asset Connection, information about the topic, QoS, retain and control packet is obtained. All information is saved in the global variables of the class.

Parameters:

interaction_metadata (basyx.aas.model.SubmodelElementCollection) – SubmodelElement of interactionMetadata.

async get_topic(forms_elem)[source]

This method gets the complete request Topic from the forms element within the InteractionMetadata element. The information is saved in the global variables of the class.

Parameters:

forms_elem (basyx.aas.model.SubmodelElementCollection) – SubmodelElement of forms within InteractionMetadata.

async get_mqtt_parameters(forms_elem)[source]

This method gets the MQTT specific parameters from the forms element within the InteractionMetadata element. The information is saved in the global variables of the class.

Parameters:

forms_elem (basyx.aas.model.SubmodelElementCollection) – SubmodelElement of forms within InteractionMetadata.

async add_asset_service_data(interaction_metadata, service_input_data)[source]

This method adds the required data of the asset service, using the skill params information (exposure element and skill input data). The information is saved in the global variables of the class.

Parameters:
  • interaction_metadata (basyx.aas.model.SubmodelElementCollection) – SubmodelElement of interactionMetadata.

  • service_input_data (dict) – dictionary containing the input data of the asset service.

async serialize_data_by_content_type(interaction_metadata, service_data)[source]

This method serializes the data for the given InteractionMetadata.

Parameters:
  • interaction_metadata (basyx.aas.model.SubmodelElementCollection) – interactionMetadata Python object.

  • service_data (dict) – the data to be serialized in JSON format.

Returns:

service data in the content-type format.

Return type:

str

async send_mqtt_request()[source]

This method sends the required MQTT message to the asset. All the required information is obtained from the global variables of the class.

Returns:

True if communication succeeded.

Return type:

bool

class smia.assetconnection.mqtt_asset_connection.MQTTAssetInterfaceSemantics[source]

Bases: object

This class contains the specific semanticIDs of HTTP interfaces.

SEMANTICID_MQTT_INTERFACE_RETAIN = 'https://www.w3.org/2019/wot/mqtt#hasRetainFlag'
SEMANTICID_MQTT_INTERFACE_CONTROL_PACKET = 'https://www.w3.org/2019/wot/mqtt#ControlPacket'
SEMANTICID_MQTT_INTERFACE_QOS = 'https://www.w3.org/2019/wot/mqtt#hasQoSFlag'