Details about the MQTT Clients connected from Transmission can be found in the Transmission Info > Transmitters folder in the MQTT Transmission tag provider.

Each Sparkplug Edge Node Descriptor (which is the Group ID and Edge Node ID combination) will create an MQTT client and a single Transmitter configuration with multiple Sparkplug Edge Node Descriptors will result in multiple Sparkplug MQTT clients.

MQTT Transmission supports an optional RPC Client which is used when publishing MQTT from Ignition Python scripts. This is not included in the MQTT Transmission metrics.


An MQTT Client folder is available for each MQTT Transmission transmitter:

 


where:

Name

Data Type

Description

Command Latency (ms)LongThe amount of time for a test MQTT command message to be sent and received back by the MQTT Client 
Enable Latency CheckBooleanWriteable tag to enable command latency checking for each MQTT Client
MQTT Client IDStringThe Client ID for the MQTT Client
Offline DateTimeDateTimeThe last time at which the MQTT Client successfully disconnected from the MQTT Server
OnlineBooleanA read-only tag showing the connection status of the MQTT Client
OnlineDateTimeDateTimeThe last time at which the MQTT Client successfully connected to the MQTT Server
Primary Host IDStringThe Primary Host ID configured for this MQTT Client
Target Server URLStringThe URL of the target MQTT Server to connect to


Executing the code below in the Ignition Script Console will print out the values in the MQTT Client folder for review:

clients = system.tag.browseTags(parentPath="[MQTT Transmission]Transmission Info", tagPath="*MQTT Client", recursive=True)
index = 0
count = 0
while index < len(clients):
    data = []
    tagPath = str(clients[index]).split("/")
    
    data.append(["Sparkplug EdgeNode Descriptor",tagPath[len(tagPath)-3],tagPath[len(tagPath)-2]])
    data.append(["MQTT Client ID", system.tag.readBlocking(str(clients[index]) + "/MQTT Client ID")[0].value])
    data.append(["Online", system.tag.readBlocking(str(clients[index]) + "/Online")[0].value])
    data.append(["Online DateTime", system.tag.readBlocking(str(clients[index]) + "/Online DateTime")[0].value])
    data.append(["Primary Host ID", system.tag.readBlocking(str(clients[index]) + "/Primary Host ID")[0].value])
    data.append(["Target Server URL", system.tag.readBlocking(str(clients[index]) + "/Target Server URL")[0].value])
    data.append(["Offline DateTime", system.tag.readBlocking(str(clients[index]) + "/Offline DateTime")[0].value])

    if system.tag.readBlocking(str(clients[index]) + "/Online")[0].value:
		count = count + 1		     
    print data
    index = index + 1
    
print ("Number of MQTT Clients: " + str(len(clients)))
print ("Number of connected MQTT Clients: " + str(count))


Example results from the Transmission Info > Transmitters above

>>> 
[['Sparkplug EdgeNode Descriptor', 'G1', 'E1'], ['MQTT Client ID', u'MT-a9502db1-a649-40e6'], ['Online', True], ['Online DateTime', Tue Sep 26 08:58:05 CDT 2023], ['Primary Host ID', u'IamHost'], ['Target Server URL', u'tcp://localhost:1883'], ['Offline DateTime', Tue Sep 26 08:56:44 CDT 2023]]
[['Sparkplug EdgeNode Descriptor', 'MyGroup', 'MyEdgeNode'], ['MQTT Client ID', u'MT-1d624cea-c810-40e0'], ['Online', True], ['Online DateTime', Tue Sep 26 08:58:04 CDT 2023], ['Primary Host ID', u'IamHost'], ['Target Server URL', u'tcp://localhost:1883'], ['Offline DateTime', Tue Sep 26 08:56:44 CDT 2023]]
Number of MQTT Clients: 2
Number of connected MQTT Clients: 2
>>>
>>> 
[['Sparkplug EdgeNode Descriptor', 'G1', 'E1'], ['MQTT Client ID', u'MT-a9502db1-a649-40e6'], ['Online', False], ['Online DateTime', Tue Sep 26 08:58:05 CDT 2023], ['Primary Host ID', u'IamHost'], ['Target Server URL', u'tcp://localhost:1883'], ['Offline DateTime', Tue Sep 26 08:58:53 CDT 2023]]
[['Sparkplug EdgeNode Descriptor', 'MyGroup', 'MyEdgeNode'], ['MQTT Client ID', u'MT-1d624cea-c810-40e0'], ['Online', False], ['Online DateTime', Tue Sep 26 08:58:04 CDT 2023], ['Primary Host ID', u'IamHost'], ['Target Server URL', u'tcp://localhost:1883'], ['Offline DateTime', Tue Sep 26 08:58:53 CDT 2023]]
Number of MQTT Clients: 2
Number of connected MQTT Clients: 0
>>>


Additional Resources





  • No labels