MQTT Engine Error processing edit for tag path - cannot accept children tags

Hello IA Forum,

I have a gateway tag change script that publishes to mqtt every minute.

if newValue.quality.isGood() and newValue.value == 0:

	parent_path = str(event.tagPath.getParentPath()) + "/currMachSpeed"
	
	curr_mach_speed_path = parent_path + "/CurrMachSpeed"
	curr_mach_speed_unit_path = parent_path + "/CurrMachSpeedUnit"
	timestamp_path = parent_path + "/Timestamp"
	version_path = parent_path + "/Version"
	value_paths = [curr_mach_speed_path, curr_mach_speed_unit_path, timestamp_path, version_path]
	
	values = system.tag.readBlocking(value_paths)
	
	curr_mach_speed = values[0].value
	curr_mach_speed_unit = str(values[1].value)
	
	timestamp = system.date.format(values[2].value, "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
	version = str(values[3].value)
		
	line_name = str(event.tagPath.getParentPath().getParentPath().getParentPath())
	line_name = line_name.replace("[default]Lines/", "")
	line_name = "Front_LH"
	
	publish_value = {
		"Version": version, 
		"Timestamp": timestamp, 
		"CurrMachSpeed": {
			"Value": curr_mach_speed,
			"Unit": curr_mach_speed_unit
		}
	}
	
	mqtt_engine_name = "CBAM Test"
	topic = "m/cbm/main/assembly/C1/line/" + line_name + "/currMachSpeed"
	payload = str(system.util.jsonEncode(publish_value)).encode()
	system.cirruslink.engine.publish(mqtt_engine_name, topic, payload, 0, 0)

This publishes to mqtt succesfully
image

but I continue to get these errors in the ignition gateway.

this seems to have to do something specifically with this line.
payload = str(system.util.jsonEncode(publish_value)).encode()

Before I was casting the publish_value to a string before encoding it but we need the object that is posted to our topic to be json type not a string. It's strange because it seems to still be publishing just fine to our mqtt but our logs are filled with these errors.

Hello,

For anyone interested or has a similar problem. After reviewing the mqtt documentation. I found that

"MQTT Engine Custom Namespaces are used to provide support for generic, non Sparkplug compliant MQTT messages with string based payloads. If a custom namespace is configured MQTT Engine will convert all messages received to tags where the topic of each message will translate directly to the tag's path and the payload will be the tag's value. "

There was a custom namespace configured on the gateway side and after just removing those namespaces the errors went away.

3 Likes