kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
2.89k stars 233 forks source link

Cannot read properties of undefined (reading 'length') #960

Closed ildar170975 closed 1 year ago

ildar170975 commented 1 year ago

0.12.0-dev.2

Observe this error in Browser console for ALL entities which were not changed within a selected period:

1) DB size did not change within 4 days (> 24 hrs which is a default value for hours_to_show)

type: custom:mini-graph-card
entities:
  - sensor.home_assistant_v2_db_size

изображение

изображение

2) This input_number helper was not changed for a long time. Consider this card:

type: vertical-stack
cards:
  - type: custom:mini-graph-card
    entities:
      - input_number.testing_device_class_apparent_power
  - type: history-graph
    entities:
      - entity: input_number.testing_device_class_apparent_power
  - type: entities
    entities:
      - entity: input_number.testing_device_class_apparent_power

Now the graph is not displayed, same errors in the console: изображение изображение

Change the helper's value - then the graph will be displayed w/o errors:

изображение

  1. Any sensor which value was changed more than 15 minutes ago: изображение
akloeckner commented 1 year ago

That might be related to the way, HA reports history. I believe, if we ask it "what is the history of the last hour?", it will respond with "nothing" if there were no changes. If we want to fix that, we have to also ask it "What's the current state", and just use that in a flat line.

Not sure, if that's already what we're doing. If it's not, it will be quite some code change. Then, just displaying a message instead of the graph might be easier: "no changes in the last X hours".

ildar170975 commented 1 year ago

Tested with 0.11: no errors, graph IS displayed, also plenty of "fetch" messages in console:

изображение

ildar170975 commented 1 year ago

it will be quite some code change.

I just upgraded to 0.12.dev version - and got these "no graph displayed" issues for MANY of my graphs. Earlier these graphs were displayed as flat - and it was OK since it was true. As you can see in the post above, downgrading to 0.11 again caused these graphs displayed.

Then, just displaying a message instead of the graph might be easier: "no changes in the last X hours".

This will be absolutely not informative, 99% of users will expect flat lines in this case.

akloeckner commented 1 year ago

Hmm... OK. So it's good I didn't fire the release script on the master branch. 😆

akloeckner commented 1 year ago

It might be my change here: https://github.com/kalkih/mini-graph-card/commit/527f005c902be8a9d572aabcb82993dfedd73572

That's the only difference in calcPoints I could find.

ildar170975 commented 1 year ago

Seems to be solved by https://github.com/kalkih/mini-graph-card/pull/961 (changes not yet added to a release) @akloeckner - thanks a lot!

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 0.12.0-dev.3 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] commented 6 months ago

:tada: This issue has been resolved in version 0.12.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: