Core: History Graph Lovelace Card showing wrong Temperature measurement C/F

Created on 7 Jun 2019  路  21Comments  路  Source: home-assistant/core

I have a few Xiaomi zigbee sensors which, through deconz, show up as binary sensors. Using a template I'm extracting the temperatures to create temperature sensors.

  mudroom_temperature:
    friendly_name: "Mudroom Temperature"
    unit_of_measurement: "掳C"
    value_template: "{{ state_attr('binary_sensor.mudroom_door', 'temperature') }}"
  mailbox_temperature:
    friendly_name: "Mailbox Temperature"
    unit_of_measurement: "掳C"
    value_template: "{{ state_attr('binary_sensor.mailbox', 'temperature') }}"
  bay_window_temperature:
    friendly_name: "Bay Window Temperature"
    unit_of_measurement: "掳C"
    value_template: "{{ state_attr('binary_sensor.bay_window', 'temperature') }}"

The values are reported in Celsius, however, my configuration is for imperial.

homeassistant:
name: Home
latitude: !secret latitude
longitude: !secret longitude
elevation: 100
unit_system: imperial
time_zone: America/New_York
customize: !include customize.yaml

When I display the values in the entities lovelace card, the values are properly converted to Fahrenheit.

image

However, when I add it to the History Graph card, it displays Celsius despite everything.

image

System: HassOS 2.11
Supervisor Version: 166
Raspberry Pi 3b+
arch | armv7l
dev | false
docker | true
hassio | true
os_name | Linux
python_version | 3.7.3
timezone | America/New_York
version | 0.94.0
virtualenv | false

stale

Most helpful comment

This is not resolved. Still an issue in 108.6.

All 21 comments

I can confirm this as well on 0.95.2. I have a D1 mini that I setup with esphome and I have the same issue. Graph shows C for this sensor.

I tried changing the configuration in esphome to have it send F, however, that did not resolve the issue and just put the same F value in the C graph.

Happy to provide anything else if needed.

Running HA 0.97.0 I have a similar issue. The entities are all created by an Ecobee Thermostat and Sensors via HomeKit. The thermostat (Dining Room) is consistantly showing F, but the Bedroom and Living Room sensors show C in the lovelace history graph, even though the entity state page shows the unit_of_measurement of F. The history state from the entity itself has two graphs, I assume one for F and one for C, can't tell which is which as the tooltip does not show the units.

image

The History tab does not show this issue:
image

No errors in the logs. I don't know what else to check, but can provide anything if needed. Dropping the HA DB and restarting fixes the problem though.

Greg

I also have a similar issue. I have a single combined history graph that shows a few indoor temperature sensors and the Dark Sky outdoor temperature. I just noticed this morning that the Dark Sky outdoor temp has split into a separate graph because it thinks the the units are in celsius. Check the "States" page shows the the units are indeed Fahrenheit.

image

I'm seeing the same issue on 0.100.3. The unit_of_measurement for the sensors are showing as 掳F and lovelace entity shows 掳F. However the history_graph shows 掳C, but the temperatures on the chart are in 掳F temps.

Same thing here - looking at the raw JSON being sent to the browser, I see a mix of Units of Measurement. Multiple changes in the same day when no changes have been made to the configuration.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

This is not resolved. Still an issue in 108.6.

I agree that this is not resolved and should be re-opened. Discovered this issue today on our setup with a Lumi sensor we just added! See images below for comparison with a SmartThings sensor which is working properly.
image
image

Also have the same problem. It seems that it is intermittent. Sometimes if I remove the device and re-add it, then it picks it up in F.

Same issue here, also using lumi (Aqara) sensors via ZHA. They look correct everywhere in the UI except the history-graph card.

seeing the same problem using the vicare integration

Same issues here with esphome-based ESP32+Si7021 temperature monitors

same issue with esphome and xiaomi sensors. they show up with the correct units in a sensor card, but not in a history graph.

I encountered this issue after changing the unit_of_measurement for a template sensor from 掳F/sec to 掳F/min during initial setup/playing around. My history-graph components all showed the original units, not the new units. I love that the homeassistant database is sqlite, because I can go poke around in and try to see problems.

Open the db with write access:

sudo sqlite3 home-assistant_v2.db

Look at some records for the entity I'm struggling with:

sqlite> select * from states where entity_id = 'sensor.bbq_temp_30mstats_rate_of_change';
state_id|domain|entity_id|state|attributes|event_id|last_changed|last_updated|created|context_id|context_user_id|old_state_id
370041|sensor|sensor.bbq_temp_30mstats_rate_of_change|unknown|{"unit_of_measurement": "\u00b0F/sec", "friendly_name": "BBQ Temperature 30min Rate of Change"}|372598|2020-08-31 20:31:50.186508|2020-08-31 20:31:50.186508|2020-08-31 20:32:50.153665|||
370305|sensor|sensor.bbq_temp_30mstats_rate_of_change|unknown|{"unit_of_measurement": "\u00b0F/min", "friendly_name": "BBQ Temperature Rate of Change"}|373089|2020-08-31 20:40:07.019939|2020-08-31 20:40:07.019939|2020-08-31 20:41:06.963640|||
...

I noted the attributes field contained a mix of units. I simply deleted the attributes with the old units:

sqlite> delete from states where entity_id = 'sensor.bbq_temp_30mstats_rate_of_change' AND attributes LIKE '%/sec%';

And now my history-graph is working as expected.

If you're seeing this issue, check your states database entries for mixed units. If you change the unit of measurement a device provides to HA "mid-stream", the old values won't be converted to the new units automatically.

The workaround posted by mfisher87 didn't work for me. I have no unit discrepancy in my database. I even tried clearing all history (on the chance I missed something) and that didn't help either. :/

Yup, just found this thread because the new Sonoff Zigbee bridge (just flashed via Tasomotizer) and Sonoff Zigbee Temp sensor is doing the very same thing to me. Shows 掳F as the unit of measurement in the customization (not edited), and in a Glances card (for example), Developer Tools, etc. But shows 掳C in the Lovelace graph card.

So (just as @Rooster13 posted above) it is not combined into the same graph for camparing trends of multiple temp sensors....

I had already upgraded to the very latest HassIO and HomeAssistant v0.114.4 and this is still unresolved...?

_Rant: I hate how "stale-bot" will just close things... I think that's the dumbest thing that was ever put on Github -- no activity does not mean resolved._

So, having made this bug some time ago, I've had the chance to observe it and learn some more details.

There is a chance when a new adding a new device that records temperature, for this bug to show.

It can happen when adding a new device, when removing and adding the device again, or after a device drops, but gets picked back up after reboot.

As for the fix, the reason the ticket is closed is because it self-heals and everyone loses interest. It depends on your Lovelace Card. However long you have set your display window to be, after it has reached that time, it will start displaying correctly.

I'm not positive, but it's as if when a device gets added, the initial state temp can get saved to the db with the wrong unit, and the display sees that as the first unit and ignores others. Until it's no longer there, then it sees the correct unit and displays accurately.

@yaroto98 is correct.

There are cases that occur when the reporting entity is unavailable or posts an unknown value where the unit logged is Celcius even though the entity is set with Fahrenheit in the configuration. I believe this is a "bug" in Home Assistant core but I don't know enough about the codebase so that's just a SWAG.

In my install, I have a database script that deletes unavailable and unknown values from the database which runs every 30 minutes. I will still occasionally see this but it corrects itself pretty quickly.

Thanks for the feedback @yaroto98 & @gdoerr ! No-one on the thread had mentioned that this may self-correct (after the time-window specified on the Lovelace card)... so I've now changed mine from 48 hours down to 1 hour to see if that works as a workaround.

It is interesting though that the History graph in the entity detail popup does not exhibit this issue.

For me this appeared immediately because I just paired my Sonoff Zigbee temp sensor and then immediately added it to my UI -- so that is in alignment with @yaroto98 description.

Nothing much new to offer but ran into this again this weekend. Everything was working great for multiple weeks, had to update my esphome firmware on 3 temp/humidity monitors and after they rebooted 1 of the 3 exhibited the Celsius display bug. It did self-heal after a couple hours.

I encountered this error setting up a new mqtt temperature sensor on 0.117.5. unit_of_measurement for the sensor is 掳C in the yaml config, but units are set to Imperial in the UI. I verified with sqlite3 that there were a couple data points in the db with "unit_of_measurement": "\u00b0C" instead of "unit_of_measurement": "\u00b0F" so I deleted them with the previously listed commands, and it resolved the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

flsabourin picture flsabourin  路  3Comments

sogeniusio picture sogeniusio  路  3Comments

TheZoker picture TheZoker  路  3Comments

kirichkov picture kirichkov  路  3Comments

aweb-01 picture aweb-01  路  3Comments