Lovelace graph: legend not updated after unit of measurement has been changed (GUI bug?)

I think I came across a small Lovelace GUI glitch:

I changed the unit of measurement for a entity which is a template sensor, so the change was done in YAML and additionally in the customization.

While the entity is shown correctly, the graph card (attribute card when clicking on the entity) still shows the old description in the legend (Y axis)

grafik

It´s not really important in this case I´m just wondering if it´s a bug in Home Assistant which I should maybe raise on GitHub.

  • What do you think?
  • Where does the text for graphs come from?
  • Will it ever get updated or is it rendered once at the beginning of an entities’ life?

It will update to the new unit_of_measurement when the old unit_of_measurement is cleared from the home-assistant database. Be patient or delete your database.

Ah okay. Is it in states or statistics table (default - SQLite)?
Doesn´t really matter anyway as I´ll wait until it changes automatically (likely in 30 days). Thank you :+1:

iirc it’s in states

Yes. It’s a bug, and yes, it should be raised. This comes up on a fairly regular basis. Seems to me Lovelace should be looking at the most recent unit for a value, not the oldest one. But I’m just a dumb user. It would be great if someone who really understood how it works (and how it should work) could put that into a request.

It’s not a bug though. It’s pulled from the database. It’s a debate were it should be pulled from in the lookup.

OK, I won’t quibble over semantics.

What is the argument in favor of using the oldest value, rather than the most recent one? I’m open to being persuaded, but right now I can’t think of any good reason.

The most recent one will cause all sorts of refresh issues. Most notably, if the unit of measurement changes and it’s group with other devices, it will now have to find a new home. It’ll need to be broken out into a separate graph or join with another one with the same unit_of_measurement. This isn’t nice on browsers and it’ll cause latency issues and it could potentially lead to issues with constant refreshing. That’s just the tip of the iceberg.

Thank you for the quick response. Maybe it’s not as simple as I thought.

Still, the counter argument is that we already have this situation. I’ve had values finding new homes. I’ve had them broken out into a separate graph. I’ve had Lovelace do weird things until I did a full browser refresh.

For these issues, the decision whether to use “oldest” or “newest” value doesn’t seem to matter. You’ll get these results either way. So for this specific point, I’d say the logical best fit is to use the most current value. That’s the one the user is presumably changing to. This will minimize the period of “weird” behavior and stabilize the browser more quickly. No need to wait for the old values to roll off the database.

I appreciate your patience with these questions, but now I’m curious to hear more about the rest of the iceberg.

1 Like

So your solution is to rework an entire graph system to have the same output and issues? The juice isn’t worth the squeeze if you catch my drift. Going from same issues to same issues with little to no benefit is pretty much a surefire way to have no work done when the changes are large.

EDIT: Before you get all upset, just make a feature request. I’m not the ‘end all say all’ for changes in the system.

I’m not upset at all, and I’d drop it immediately if it’s bothering anyone. Just a helpful (I hope) discussion of options.

Obviously a major re-write of anything would need to justify the effort. I haven’t seen the code so I can’t tell how hard it would be to use the last unit instead of the first. It sounds simple when I say it that way, but I know things can be more complex than they look.

As for the benefit, I do think most reasonable people would expect the units displayed to match the most recent selection. Incorrectly displaying new data with an old unit is, to me, a lot worse than having the newest data show the newest (presumably, desired) unit, even if the older data is now displaying incorrectly. It also seems people would more easily understand what’s going on if they saw that, and wouldn’t be posting here thinking it’s a bug.

Here’s an example: You notice your temperature from one thermometer isn’t showing on the same graph as the rest, because it’s in the wrong unit. Oops, you forgot to change that unit! You go back and change it to the same unit as all the rest. Wouldn’t it make sense for all the temperatures to now display on the same graph? Wouldn’t a reasonable person wonder why nothing happened after they changed it?

1 Like