Using system.tag.readBlocking and turning into string

Let’s start from first principles.

When you use system.tag.readBlocking, the return value is a list of QualifiedValue objects.

To extract the first element of the list, use subscript 0 to retrieve the first element: qualifiedValue = listOfValues[0]. Now you have a QualifiedValue object. To retrieve the actual value, which can be any type, use getValue(), or, better, .value: actualValue = qualifiedValue.value.
The type of value at this point will be whatever the tag’s type is, per @josborn’s post above.
If your tag is not a string, and you actually need to do a string formatting operation, you can ask it for its string representation using the Python builtin str function. This is a lossy operation - the string representation of an object is not guaranteed to and indeed almost never does encode as much information as the actual type.

You should drive logic from the string representation of a value approximately never. For presentation, sure, it’s fine, although if you have a richer type you might still lose information (even a simple floating point might not be represented the way you want it to be if you simply call str).

4 Likes