[Deprecated] Interactive history explorer custom card

OK! Thanks a lot!

Hi, I like the chart card, but have two questions

  1. When I delete the states of an entity, my chart does no longer show anything. The statistics (in the db) are still there (only the states are purged to keep db small) and the statistics graph of HA keeps showing the bars:
square: false
type: grid
cards:
  - type: custom:history-explorer-card
    cardName: historycard-77069541
    labelsVisible: true
    header: Daily
    barGraphHeight: 200
    defaultTimeRange: 1o
    defaultTimeOffset: 1d
    decimation: true
    tooltip:
      showDuration: true
      showLabel: false
    uiLayout:
      invertZoom: true
      selector: hide
      interval: hide
    graphs:
      - type: bar
        options:
          interval: daily
          showTimeLabels: true
        entities:
          - entity: sensor.energy_wattpilot
            name: ''
            color: rgba(0,255,0,0.5)
  - chart_type: bar
    period: day
    type: statistics-graph
    entities:
      - sensor.energy_wattpilot
      - sensor.wattpilot_totally_charged
    stat_types:
      - change
    hide_legend: true
    title: Daily
columns: 1

Do I set anything wrong or why does this happen to my charts?

  1. Is it normal, that this chart is slower than the HA statistic graph? Or is there a way just to use the statistics and not the states for the chart?

Thanks for any hints!

You deleted your entire history, so an empty graph is not unexpected here…

No, that’s not normal. Check if the shown time range is the same. Also, if you’re only interested in long term statistics, make sure to force that source. Otherwise the card will fetch the main history DB, which is usually slower (but a lot more accurate).

statistics:
  force: true

Thanks for the answers.

No all, only the short term statistics (states table)

The force did what I needed! Thanks a lot for this.

Hello,
very nice integration!!
However, it seems i can’t get this to hide entities that have no statistics. Shouldn’t it be set like this?

views:
  - title: History Explorer
    panel: true
    type: panel
    badges: []
    cards:
      - type: custom:history-explorer-card
        recordedEntitiesOnly: true
        defaultTimeRange: 1w
        combineSameUnits: true
        showUnavailable: false
        cardName: historycard-30691461

Thanks!

Yup, that’s your entire history :slight_smile: That’s why the graph showing the history was empty.

There is a very clear distinction in Home Assistant between history and long term statistics. This card merges both in realtime and tries to hide the HA implementation details under a combined history. But that doesn’t change the underlying approach. If you delete your states table, then you kill your entire history and only keep the (much less precise) long term statistics.

BTW, brutally killing the entire history DB is probably not the right approach. If it’s about keeping DB size down, you should exclude entities you don’t care about and/or that create lots of states. See here for some ideas.

What do you mean by ‘statistics’ ? See the my reply above to topfer.

1 Like

Hello,
i’m thinking about this part:

i assumed this would filter out all entities that have no “statistics”, so long term recordings (all my entities have short term recordings - the fixed 10 days), am i wrong? because i still see all my entities and it’s a mess.
I also tried with

force: true

with no results, i still see all my entities.
Probably i misinterpreted the readme :slight_smile:
Thanks

It will filter out all entities that have no history, the ‘short term recording’ as you put it. It does not filter by long term statistics.

You can manually add filters to the list, eg only energy entities, etc. From the readme:

The entities shown in the list can be further filtered using the filterEntities option. The same wildcard syntax applies here. For example:

type: custom:history-explorer-card
filterEntities: 'binary_sensor.*'   # Show only binary sensors in the selector dropdown list
filterEntities:                     # Or use multiple filters, entities matching any of the filters will be added
  - '*power*'
  - 'sensor.*energy*'

thanks, much clearer, my fault!
i can’t think to an entity with no history, is it only the case of specific exclusion? (TBH i wouldn’t even know how to exclude some entities from keeping the canonic 10 days history…)

You can use the recorder settings in the configuration.yaml. Either exclude only long term statistics

# Exclude long term statistics
homeassistant:
  customize_glob:
    "sensor.my_sensor*":
      state_class: none
  customize:
    sensor.my_sensor_2_state:
      state_class: none

Or all statistics:

#Exclude recorder
recorder:
  exclude:
    entity_globs:
      - sensor.time*
      - sensor.date*
    entities:
      - sun.sun

HTH

This is amazing… thank you

Any idea why this does not work?
The dynamically added (same sensor) is much closer but the YAML one is garbage? I just want a bar chart showing costs per day.

The netBars key is at the wrong spot. It should be under the entity key, not under the type key.

And are you sure that your sensor actual does contain accumulated cost ? It fluctuates a lot for that. If your cost per day is not a total increasing or net metering entity, then you can’t use bar graphs. Bar graphs with adjustable intervals are only supported for total_increasing or net metering sensors at this time, not randomly changing entities. You’ll have to use line graphs for those I’m afraid. You can use stepped line mode if you don’t want them to interpolate.

Thanks for the answer… so this as close as it can get?

I don’t know, it isn’t really clear to me what you want to achieve.

What does this sensor with the insanely long name represent ? Is it accumulative or not ?

It shows how much the electric costs were the day before. Provided by the energy companies API

This is the data in a stats graph card

Can you post the content of the attributes and entityinformation from developer tools?

Hi,

Using this card for some days now, I was wondering if it is possible to set some global/central defaults for al the existing card (without any overrule settings) and new cards?

That’s not possible with the HA frontend. A specific card instance can only see its own dedicated config.