Why does the "unit of measure" do not change?

Hi,
I am very new to HA. Configured my first template based sensor and included the unit of measure as “Fahrenheit”. Restarted HASS only to realize that it should be °F. Then changed it to the correct one and restarted HASS. Now, it shows correctly when I go to the “States” tab and check. But, it still appears as Fahrenheit in the front end and gets its own graph, probably because the unit of measure is different.
How can it be resolved

Here is the part from config.yml file:

sensor:
  - platform: template
sensors:
  outside_temp:
    friendly_name: "Outside Temperature"
    unit_of_measurement: '°F'
    value_template: "{{ states.weather.dark_sky.attributes.temperature }}"

Thanks in advance

do you have imperial or metric set at the top of config yaml?

Try [CTRL] + [F5] to refresh your web browsers cache.

1 Like

Thank you.
I have imperial set up. It works well with other sensors, such as thermostat sensors. Following is how those are seen in the “States” tab

Topmost is the sensor I created using template. Below is the thermostat from Nest.

This is how the graphs look like

I tried clearing Chrome cache which did not help.

What’s your unit of measure for the whole system?

homeassistant:
  latitude: 32.87336
  longitude: 117.22743
  elevation: 430
  unit_system: metric # WHATS THIS
  time_zone: America/Los_Angeles
  name: Home
  whitelist_external_dirs:
    - /usr/var/dumping-ground
    - /tmp

It is imperial. Following from config.yaml file:

unit_system: imperial

Ok, I’m not sure why I asked that. I don’t think I fully read your statement. Anyways, can you check your customize section of your config for that item?

What’s odd to me is that the whole word is written out. It has to be getting the whole word from somewhere.

Also, have you purged your database yet?

Indeed. And not just written out but in quotes and lowercase.

I’d bin the database as well, and also comment out that sensor and reboot, in case there’s another one that’s overwriting it somehow.

Then if the sensor is gone, uncomment it again and reboot.

Love a good mystery :slight_smile:

The whole word is not a mystery :blush:

It is how I wrote it the first time. After realizing the error I changed it and restarted HASS. But it is still somehow getting that old word I’ve written.
Pardon my ignorance! How do I purge the database? If I did, what would be the other consequences?

OK. I am now totally confused.
I purged the database using recorder.purge service with limiting days to 1 and repacking. Commented out the outside temperature template and restarted HASS, and purged the database again.
Now it is becoming more confusing!! :thinking:
When I go to History, I still can see outside temperature, but now it is grouped with other thermostats and having F as units.
But, in the frontend (I use Lovelace) I still get the Outside temperature graph separately with Fahrenheit as the unit of measure, not F
I am not sure what’s wrong, where!!!

Purging the database fixed the history graphs. Now you have to clear the cache for the main interface because your browser is still holding on to old information. Ever wonder why browsers take up so much memory? because they are designed to download the least amount of information when loading a page. Browser cache stores information that the browser doesn’t need to reload each time. So your browser is pulling old in formation instead of pulling the new information. This needs to be done every time you make a change to your interface. So, CTRL+F5 on the browser page will clear the cache and reload the page.

Thanks for all the tips!
Strange.
Purged the database! Removed (commented) the template sensor! Shut down HASS and restarted PI! cleared the browser cache! and I still can see the history graph for outside temperature in the history graphs and still the front end showing the graphs with fahrenheit as unit of measure. I totally out of options now!

are you fully purging the database? Like deleting EVERYTHING. If it’s holding on to any bit of old data, it will use that.

How do I fully purge the database. I only used the recorder.purge with keep_days 1. Are you saying that I should use 0? Will that do?

OK. Did the purge with keep_days =0. It did resolve the issue (Thank you @petro) and I am seeing the correct unit of measure. What is still puzzling me is, the template sensor is still commented in the config.yaml but it is still active for some reason!. I can’t see the entity listed in the Entity list in the states too. Very strange! Anybody know what’s going on?

Usually that’s a byproduct of your history. Things stay in home assistant if the history exists (reason why you were having the problem). If you purged it and commented the template out, not sure why it’s still there.

OK. After few days,the sensor disappeared and appeared after I uncommented it from the config file. So , everything is now working fine. Mystery solved!
Thanks everybody.

1 Like

This thread helped me figure out some nuances, that’s for sure.