kalkih / mini-graph-card

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

Graph may not be updated #944

Open ildar170975 opened 1 year ago

ildar170975 commented 1 year ago

HA 2023.3.5 latest mini-graph-card Win10+Chrome

Consider this code:

input_number:
  testing_number_01:
    min: 0
    max: 1
    step: 1
    mode: slider
type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: input_number.testing_number_01
        name: number
        secondary_info: last-changed

  - type: history-graph
    entities:
      - input_number.testing_number_01
    hours_to_show: 1

  - type: custom:mini-graph-card
    entities:
      - input_number.testing_number_01
    hours_to_show: 1
    points_per_hour: 3600
    aggregate_func: last
    smoothing: false
    line_width: 1
    cache: false
    show:
      labels: true

where cache: false seems to be not affecting at all, points_per_hour: 240 is defined to ensure that changes made frequently by a user (here interval is 15 sec) are displayed properly.

Clear browser cache.

The initial state: image

Now change value and see how the mini-graph-card is updated. After 1 minute the graph is not updated: image

Change again: image Immediately after changing the graph is redrawn - but we see only "0 -> 1" change instead of "0 -> 1 -> 0".

Go to Editor - the graph is displayed properly: image

Go back, refresh (F5) - the graph is displayed properly: image

Setting points_per_hour: 3600, playing with cache: false do not help.

And now the weirdest part:

  1. Copy the whole card onto another view.
  2. Change value - the graph is updated properly - but after several minutes I observe the same behaviour.
jlsjonas commented 1 year ago

I'll try to look into it this weekend, thnx for the report!

akloeckner commented 1 year ago

When searching the repo for update, I found #250 . Maybe related.

ildar170975 commented 1 year ago

I noticed the problem recently - may be same time when history-graph became "streaming"; not sure if it could be related...

echo-lalia commented 9 months ago

I just want to add that I believe I am observing the same issue. Graphs only seem to be accurate on refresh, and have really unexpected behavior when displaying them for a long time. (in addition to not updating regularly, I am having issues where two entities on the same graph/axis will not line up properly, or will disappear)

Before refreshing: image

After refreshing: image

- type: custom:mini-graph-card
  entities:
    - entity: sensor.octoprint_actual_tool0_temp
      show_fill: false
    - entity: sensor.octoprint_target_tool0_temp
      smoothing: false
      show_fill: true
      show_line: false
      show_state: false
      show_points: false
  hours_to_show: 1
  points_per_hour: 10
  min_bound_range: 5
  show:
    icon: true
    extrema: false
    fill: fade
    legend: false
    name: false
  icon: mdi:printer-3d-nozzle-heat
  align_icon: state
  update_interval: 5
ildar170975 commented 6 months ago

Just confirming that with the same version of mini-graph-card & HA 2024.1 - still same glitch:

1

akloeckner commented 6 months ago

From your animation, it looks to me like our graph does not update the most recent point, but only shows the second-most recent data point. 🤔

ildar170975 commented 6 months ago

Seems so (

akloeckner commented 5 months ago

While thinking about #1075 , I realized, we have two places where we react to HA state changes:

So, I wonder if maybe render is called before updateData. This might explain the behaviour described here.

ildar170975 commented 1 month ago

@akloeckner Have you found anything? Is there any workaround? Except forcing a user to press F5 periodically )))

akloeckner commented 1 month ago

No, I don't have that many "binary" sensors plotted with mini-graph-card. Plus, I don't keep the graphs open for long times, usually. :shrug: Also, I have no clear idea how this could be fixed. Not even, if my hypothesis above is correct: I have no clue how the order of execution could be changed without changing the architecture of the code. 😕