kalkih / mini-graph-card

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

fix: retain the last out-of-bounds state #961

Closed akloeckner closed 1 year ago

akloeckner commented 1 year ago

This re-insures the logic to keep the last known state before the start of our grah interval within the history. While this is not really correct, it allows for rendering steady-state-graphs.

This element was mistakenly removed in #881.

The piece of code relies on history being chronographical.

fixes #960

akloeckner commented 1 year ago

@ildar170975, can you run this fix on your end, too, to see if it really fixes the issue?

ildar170975 commented 1 year ago

@akloeckner Unfortunately, right now do not have a devcontainer to test this fix; could you create a js file - so I will replace it manually & test? I mean "mini-graph-card-bundle.js"....

akloeckner commented 1 year ago

I added the bundle js to the PR. I'll just have to remember to remove it again before merging...

ildar170975 commented 1 year ago

Thanks a lot !!! Tested with new "mini-graph-card-bundle.js". https://github.com/kalkih/mini-graph-card/issues/960 - seems to be fixed: изображение

Surely more tests are required, will do it these days.

Also, (another issue probably) console log is flooded with "fetch finished" - is it expected?

akloeckner commented 1 year ago

Thanks for testing! Let me know, when you're ok to merge! I'll create a new dev release then.

As to the fetches, that might be related to #935 ? I didn't notice that many requests yet. I think, there should be one request per graph.

ildar170975 commented 1 year ago

Let me know, when you're ok to merge!

This particular issue (https://github.com/kalkih/mini-graph-card/issues/960) seems to be solved. Gonna close https://github.com/kalkih/mini-graph-card/issues/960.

Currently I am mostly satisfied with the current implementation. The only critical issue for me is https://github.com/kalkih/mini-graph-card/issues/944 - but again, not life-critical )))

akloeckner commented 1 year ago

Ok, I'll merge this then. And will have a look at #944 later...

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 0.12.0-dev.3 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

akloeckner commented 1 year ago

I just noticed: This fix will not work, if the last change is even outside of the scope of the recorder component in home assistant. The HA history API just reports nothing in this case. I guess, there is not much we can do here. We can rather file an issue with HA to include such state in the history response, maybe.

ildar170975 commented 1 year ago

outside of the scope of the recorder component in home assistant

Assume that Recorder has 10-days history. Assume that some sensor was changed 11 days ago, currently it's value is 100. I expect to see a flatline with a value "100" - for ANY hours_to_show (even > 240).

Could you elaborate what possible errors we may have?

akloeckner commented 1 year ago

I expect to see a flatline with a value "100" - for ANY hours_to_show (even > 240).

Exactly. But I seem to have no line at all in that case. In the dev tools of the browser, I have checked the response of the API request and it is simply []. I have no easy and reliable way to reproduce, though.

ildar170975 commented 1 year ago

I see no issues so far.

My test with some input_number which was changed a long time ago:

изображение

A bit "enriched" case: изображение

Recorder has 10 days.

Code:

type: vertical-stack
cards:
  - type: custom:mini-graph-card
    entities:
      - input_number.air_pm25_level_1
    aggregate_func: last
    points_per_hour: 60
    smoothing: false
  - type: custom:mini-graph-card
    entities:
      - input_number.air_pm25_level_1
    hours_to_show: 72
    aggregate_func: last
    points_per_hour: 60
    smoothing: false
  - type: custom:mini-graph-card
    entities:
      - input_number.air_pm25_level_1
    hours_to_show: 250
    aggregate_func: last
    points_per_hour: 60
    smoothing: false
akloeckner commented 1 year ago

Hmm... Looks good to me. My data has also changed in the meantime, so... I guess, I'll observe and open a separate issue, once it happens again.

github-actions[bot] commented 6 months ago

:tada: This PR is included in version 0.12.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: