MSSQL + NODE RED + MQTT and numeric value number format problem

Hi there,

I have some production numbers in my MSSQL server and I’m pulling with Node Red and published through MQTT to HA.

All numbers has 6 digits. I can divide and multiply them with their self without any problem (I meant all numbers).

But, I can not displayed these number as standard number format like 1,234.567 etc. All numbers displayed without comma or point. like 123456

I’m running on:
Home Assistant 2022.12.1
Supervisor 2022.11.2

My Country and unit system already set in my config. Also, number format is 1,234.567 in my user prefs.

Any advice?

Could you describe what does ‘publishing to ha’ mean? do you create ha entity from data in mqtt?
And related question: why do you publish through mqtt since NR can create HA entity and set its state directly.

regardless questions above you have to debug values on every stage:

  1. in NR, using debug node
  2. in mqtt using some mqtt browser app, for example MQTT explorer application
    3 values stored in destination sensor (in dev tools tab of HA)

it will eventually show the stage where the issue is visible for the first time.

Here is debug windows in NR:

and devtools states:

all numbers are unformatted.

NodeRed and its debug for sure doesn’t respect HA formatting settings.

Not sure if entities page in dev tools respects fornatting or shows raw values. IMO formatting is mainly to be applied on cards.
Anyway afaik states are always stored as string. So once storing them into entity (ie sensor) they are converted to string.

Not sure where and what decides that the picked value from a sensor is a number. Maybe device class or unit ms decide about that.

can you paste settings of your entity node. you can also click on entity’s more info icon. opened window should show units and possibly reflects ha formatting

Problem solved after state_class declared in mqtt sensor settings.

state_class: measurement

Thanks for your guidance.