Frontend: Counter in the frontend should be numeric instead of categorical

Created on 23 Jul 2020  路  6Comments  路  Source: home-assistant/frontend

Checklist

  • [x] I have updated to the latest available Home Assistant version.
  • [x] I have cleared the cache of my browser.
  • [x] I have tried a different browser to see if it is related to my browser.

The problem

The details card for counter entities displays as a categorical/color bar plot. A bar plot is not useful for interpreting trends since it destroys any notion of ordering/magnitude, as can be seen in the example image below.

image

Expected behavior

Counter values are obviously numeric, they should display as a line plot. I can't think of a use case where you would prefer a bar plot, considering what counters are intended to be used for.

Steps to reproduce

Pull up the details card for a counter entity from anywhere in the UI.

Environment

  • Home Assistant release with the issue: 0.113
  • Last working Home Assistant release (if known): NA, present since at least 0.111 from my experience and probably longer.
  • Browser and browser version: Chrome and Firefox, latest
  • Operating system: HA is on a raspi 4 running the HA managed system (hassio), browsers I've tried on a bunch of systems.

State of relevant entities


image

Problem-relevant configuration

This counter is fed by a separate automation that counts lightning strikes based on messages received over MQTT from a device using an AS3935 lightning sensor. I am not including the automation because this issue applies to all counter entities as far as I am aware, but I note that the actual value counting works entirely as expected and the only problem is with how the counter history is displayed in the frontend.

counter:
    lightning_strikes:
        initial: 0
        step: 1
        restore: no
        minimum: 0
        icon: "mdi:lightning-bolt"

Javascript errors shown in your browser console/inspector

NA

Additional information

I assume this is just a mistake with how counter entities are configured to be displayed. Without really knowing a lot about the HA internals, I would guess that the frontend decides what type of plot to use based on the data type of the entity value column in the history database. Presumably counter values are stored as some type of int, which the frontend assumes is categorical.

bug

Most helpful comment

We only show line graphs for entities with a unit of measurement, maybe we should add the option to set a unit of measurement for counters.

All 6 comments

We only show line graphs for entities with a unit of measurement, maybe we should add the option to set a unit of measurement for counters.

That sounds like a reasonable solution, the only caveat I'd give is that it would seem logical that counters should show as a line graph by default.

Thinking about this some more, I guess we could also fix it on the frontend. By setting the unit to "#" when fetching the history.

I agree. By default a counter should be a line graph as a number is a number. We don't need a UOM for a line graph we just require it for our purposes for categorization. Defaulting it to # is a good idea

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 has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Issue is still present.

Was this page helpful?
0 / 5 - 0 ratings