MQTT Engine not providing the correct data type for json payload

I’m publishing this payload to the MQTT Engine in Ignition:
{“L”: 65.0778888988495, “a”: 5.6495682209730145, “b”: 5.287174153327942}

When I view from the MQTT Engine tag browser, the datatype is set to Int8 for the values.
I need to have it as a Float8.
{
“readOnly”: true,
“dataType”: “Int8”,
“enabled”: true,
“name”: “L”,
“tagType”: “AtomicTag”
}

Is there a way to correct this?

The datatype is set based on the initial value that arrives for the tag. If it has a decimal, it will be a double. If it doesn’t have a decimal and is a number, it will be a long. To correct it, just delete the tag in MQTT Engine’s tag provider and it will get recreated on the subsequent payload.

Thanks Wes!

The initial values that were being published were all zeros, so that was forcing the datatype to be integer. I set the initial value to 0.0001 and now the topic values are now floats.

Thanks for your quick response!

Hello @wes.johnson , I’m resurrecting this post because I’m facing the same issue.

Is there any way to automate the tag type change?I do understand that this wouldn’t be easy for complex types, but it is quite often the case that sensors from third parties publish a 0 as initial values, setting therefore the tag to int value, while subsequent production values will be with decimals.

We have thousands of topics coming out of our MQTT broker, and if a couple of thousands new come up, it is quite impractical to go check all tags have the correct type.

Thank you.

I also was curious if anyone found a way to do this. We are suffering a similar issue, sending application will trim decimals if they are 0, which causes integers to be initially created. With JSON payloads, would be nice to have a feature to allow datatype to update.

I like the idea of making this a configurable option. I’m adding an issue to our backlog to implement this in the future.

1 Like

Just curious if there is any ETA on this feature? :slight_smile:

This is now in the nightly build. There is a new option in custom namespaces called ‘Numbers as Floats’. When enabled, all numbers will be created as 8 byte floats. Nightly Engine is here: Nightly Module Builds - MQTT Modules for Ignition 8.x - Confluence