List of valid "unit_of_measurement" options?

Right, it just needs to have some unit_of_measurement, doesn’t matter what it is. Sometimes previous values without a uom can delay the graph displaying until they’re flushed out with new data.

1 Like

Thank you for explaining. Is there a list of the “special” uom values which get converted?

I suspect that it’s these: core/unit_system.py at 0b4b071c0238999f5af5c4d391478ec87e545d21 · home-assistant/core · GitHub

Only c and f get converted. Everything else remains untouched

That’s what I thought, and then I saw the conversion functions for other things. I guess those are just helpers for integrations to use when they want. Incidentally, the frontend changes the icon when it sees a temperature unit: frontend/sensor_icon.ts at dc79fc2919d836ae28ce0c065aacd6ef52f47dc7 · home-assistant/frontend · GitHub

  const unit = stateObj?.attributes.unit_of_measurement;
  if (unit === UNIT_C || unit === UNIT_F) {
    return "hass:thermometer";
  }

This does not seem to be true for long term statistic see problem reported here

To historize the states of my Venstar thermostat attribute: hvac_action
what unit_of_measurement should be used for different text strings like idle, cooling, etc.?

So far, with this configuration:
HVAction

when I pull it up in history it’s trying to trend a numerical value.

To clarify, the variable is acquiring the data:

HVACTION1

But the history is either not being stored or retrieved properly:

HVACTION2

Is unit of measure the problem, or something else?
Ideally, the trend would show up like the weather forecast:

HAWF

if you add a unit of measurement, it attempts to graph it. So don’t add a unit of measurement.

1 Like

That’s it, THANK YOU!!!

HVACTION3

i have a similar issue. i have no uom but i still see a line graph. any thoughts?

that’s the only thing that causes it unless something changed recently.

1 Like

Would state_class: being present perhaps cause this behaviour too?

It could. To be honest, I haven’t been paying attention to those details lately.

1 Like

This doesn’t make sense. Does it mean that Home Assistant only supports dollars, euros and cents as currency unit of measurements? What about the rest of the world?

1 Like

And if you want graphs, but there simply isn’t a unit of measurement for the data (ratio’s, dimensionless numbers, …), you can add a blank unit of measurement:

unit_of_measurement: “”

2 Likes

this answer does not seem to be valid anymore with 2023-05 they “assume” a numeric value and cast it to decimal, what causes an exception, what causes the sensor to dispaly “unknown”.
There seems to have been a breaking change

1 Like

Not sure what you’re talking about. The solution is still valid as is the information in this post. If your value is numeric, add a unit_of_measurement and the information will be graphed.

Since 2023.5.0, several people have reported that their Template Sensors now indicate unknown (as opposed to previous versions). It appears that the rules for how unit_of_measurement is handled have become more strict. Given that Template Sensors are no longer behaving like they did in the past, it’s effectively an undocumented breaking change.

Another user believes this may be the PR responsible for the new behavior (tagged as a ‘Code quality improvement’) :

1 Like

Right, but that doesn’t change the solution to this thread, which is what I’m referring to. If you put a unit_of_measurement on a sensor, it will turn it into a graph. The original question was “what do I place on a voltage sensor” and the answer was “v”. None of that has changed…

Also, if you output None instead of 'unkonwn' or 'unavailable' in your template sensors, then you’ll avoid this strictness. That’s the proper way to set a sensor to unknown or unavailable. The other option is to use availability templates (which sets None under the hood).

We ended up finding a series of issues in Beta with this change. Properly created template sensors would be unaffected. When you explicitly set a numeric sensor to a string state, you’ll get this error.