Enforcing or converting data type in device attributes?

Hi there,
need some advice here with a simple type casting behaviour.
I have a device which is mostly numerical type.

I was expecting that the logic will autoconvert the type accordingly.
But one example is here, where you can see the counts are not converted to integers:


Is there a way to do a cast conversion in the Device State Nor or some other setting?

I also noticed another issue, here I am setting the field to numerical zero.


However it gets somehow casted to a string (which also doesn’t make any sense given that the attribute is Numerical).


Let me know what’s the best way to solve this problem.

So those screenshots appear to be from the device communication log, which will output the parsed JSON exactly as the device state is sent. Depending on how the value is referenced in the Device: State Node, that will sometimes be a string.

However, we are very good about casting values appropriately, and based on the fact that the communication log does not have any errors about data types in the messages, it seems to have worked in this case.

If you export the data, or view it on a dashboard block, or look it up in the recent states panel, or query the data via the API, you should see that it was cast appropriately. Please let us know if that is not true.

Ah got it, I assumed it was the final state and polluting my data.