I am using ha-average ( GitHub - Limych/ha-average: Average Sensor for Home Assistant ) to make a sensor. However, it is coming up unitless, so I can’t put it in a graph along with other temperatures. How do I properly give it a unit of Fahrenheit?
I tried adding [ unit_of_measurement: “°F” ], however HA gives an error in the logs saying that it’s deprecated. What’s the new way to do this?
I looked it up and there’s no details about what to actually do. I searched for actual documentation for an hour and came up with nothing so trying here instead.
I agree, it’s a bit obscure. I assume our friend is referring to this bit of the github readme:
Known Limitations and Issues
Due to the fact that HA does not store in history the temperature units of measurement for weather, climate and water heater entities, the average sensor always assumes that their values are specified in the same units that are now configured in HA globally.
Your temperature units are presumably set to °F in Settings | System | General. If your average temperature is coming up without units, that implies that the three sensors you’re averaging don’t have the correct device class. That might be the first thing to check.
Otherwise, if you look up sensor in the HA docs:
It refers you to another page about how to modify units of measurement (using customize):
you spent an hour and couldn’t find anything? You gotta learn how to use a flipping search box dude, it’s not hard. I was able to go find this in 2 minutes. You are trying to modify a sensor so maybe try doing a search for “sensor” and Oh, what do you know, here it is…
Ah, but you knew what you were looking for. The search box is hopeless if you don’t have the right search term. I usually use a google site search - gives more results and prioritizes them better.
I went to the Customizing entities page you mention, and I just tried to set the three sensors to have °F, but when I do with this option unit_of_measurement: "°F"
I get this error: 2023-04-28 16:10:03.113 ERROR (MainThread) [homeassistant.config] Invalid config for [sensor.statistics]: [unit_of_measurement] is an invalid option for [sensor.statistics]. Check: sensor.statistics->unit_of_measurement. (See /config/configuration.yaml, line 67). Please check the docs at https://www.home-assistant.io/integrations/statistics
However, when I go to that URL, I don’t see any way for me to properly set the unit.
Am I missing something obvious?
@Fallingaway24, the page you referred me to is the thing I’ve already tried that isn’t working. Unless my syntax is off or something, I don’t understand why the documentation is saying one thing when HA is acting another.
Below are the bits of my YAML that are pertinent for context:
As I said earlier, this is the place where temperature units are set globally.
If you go to Developer Tools | States and look up your various temperature sensors, they should have state attributes something like this:
state_class: measurement
temperature_valid: true
unit_of_measurement: °F
device_class: temperature
If they have the device class temperature, then the unit of measurement should be assigned automatically. If not you can change the device class with customize.