0

MQTT Collector logs only DBIRTH

Hello, I have modified the python script available in tahu-master python-examples-example.py to test the MQTT collector (23.2.1). The broker I am using is mosquitto. Using mosquitto_sub, I can see that my messages are being delivered to the broker. However, Canary Data collector is able to see only the NBIRTH and DBIRTH messages. The DDATA messages from the client script are not being registered. My DBIRTH message is published by calling:

def publishDeviceBirth():
    print("Publishing Device Birth")

    # Get the payload
    payload = sparkplug.getDeviceBirthPayload()

    addMetric(payload, "ABCD", None,MetricDataType.Float,25.1)
    addMetric(payload, "EFGH", None, MetricDataType.Float, 3.1)
    addMetric(payload, "IJKL", None, MetricDataType.Float, 4.81)
    addMetric(payload, "MNOP", None, MetricDataType.Float, 4.81)

    # Publish the initial data with the Device BIRTH certificate
    totalByteArray = bytearray(payload.SerializeToString())
    client.publish("spBv1.0/" + myGroupId + "/DBIRTH/" + myNodeName + "/" + myDeviceName, totalByteArray, 0, False)

and DDATA message is published by:

while not exit_flag:
    # Periodically publish some new data
    payload = sparkplug.getDdataPayload()
    ABCD = round(random.uniform(20.0, 30.0), 2)
    EFGH = round(random.uniform(2.0, 4.0), 2)
    IJKL = round(random.uniform(5.0, 10.0), 2)
    MNOP = round(random.uniform(5.0, 10.0), 2)

    # Add some random data to the inputs
    addMetric(payload, "ABCD", None, MetricDataType.Float, ABCD)
    addMetric(payload, "EFGH", None, MetricDataType.Float, EFGH)
    addMetric(payload, "IJKL", None, MetricDataType.Float, IJKL)
    addMetric(payload, "MNOP", None, MetricDataType.Float, MNOP)
    #payload.seq = get_next_seq()

    # Publish a message data
    totalByteArray = bytearray(payload.SerializeToString())
    client.publish("spBv1.0/" + myGroupId + "/DDATA/" + myNodeName + "/" + myDeviceName, totalByteArray, 0, False)

The sparkplug.getDdataPayload() handles all timestamp and sequence numbers and I can see that the timestamp and sequence numbers are changing. QoS is set to 0 in both client and subscriber. In the historian I can see the tags and also the values that are specified in the DBIRTH function.

Any help would be much appreciated. Thanks

2 replies

null
    • kevinks
    • 8 days ago
    • Reported - view

    The topic configured in historian is:
     

    spBv1.0/GroupID/+/NodeID/#
    
    • smason
    • 7 days ago
    • Reported - view

    Hi ,

    I won't be much help troubleshooting your script, but there are alternatives for testing the MQTT Collector if you're interested in trying them.

    1. Publisher - you could publish data from one of your DataSets (or sub-branch) to the mosquitto broker using Canary's Publisher service, then collect it using the MQTT Collector. You would obviously want to store it in a separate DataSet after looping it through.
    2. Data Generation - our data generation tool can be used to write simulated data directly to the Historian or to an MQTT server using a SparkplugB or JSON payload. 

Content aside

print this pagePrint this page
  • 7 days agoLast active
  • 2Replies
  • 20Views
  • 2 Following