kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
2.96k stars 232 forks source link

Graph stays flat although the sensor values have changed over time #933

Open ivanovd opened 1 year ago

ivanovd commented 1 year ago

After the 2023.0 update of HA the graphs on the cards started showing a flat line, even though all sensors were updating regularly.

Here is the card config:

image

Here is the sensor history for the past 24 hours:

image

As you can see, this happens for all sensors ... I have another instance where I have only two mini cards with the same configuration and they work fine:

image image

So I am not sure if it's a bug related to the number of stacked cards or it is something else ... did clear the cache and hard refresh a few times but that didn't help.

Any ideas are welcome.

ernst77 commented 1 year ago

seems like 2023.3.1 broke something. Same issue for me

ildar170975 commented 1 year ago

@ivanovd Your code does not have points_per_hour specified and no info about actual sensor’s update frequency is provided.

ildar170975 commented 1 year ago

@raphv No code is posted, nothing to analyze ((

ivanovd commented 1 year ago

@ivanovd Your code does not have points_per_hour specified and no info about actual sensor’s update frequency is provided.

While that is true. It was working before 2023.1 and it works on my other instance as you can see. I will try with the suggested options. The sensors are ZigBee therefore they send update on valu change, not on regular intervals.

ildar170975 commented 1 year ago

@ivanovd The fact that it worked does not prove that your setup is correct. Number of points per hour should be at least same as a maximum frequency.

Also, when you see a flatline in mini-graph - check is there a flatline in a conventional history-graph (I have this rather often). Also, clear browser cache.

I will check both cases a bit later.

ildar170975 commented 1 year ago

@raphv What your provided is a card with several sensors , one of them is flatlined. And no conventional history-graph card for the same data. please try to post only data related to the issue to localize a problem.

Like this:

To help with the problem this info is required.

ildar170975 commented 1 year ago

Assume that you see the XXXX sensor flatlined. Then please show a mini graph card with THIS sensor only. And history graph for THIS sensor. Same hours-to-show. Pontss-per-hour - equal to or x2 of real update frequency.

There is one more thing. I noticed that you posted graphs for attributes of some sensor - then history graph must be posted for same data, not for “state” of this sensor.

Sorry for typos, posting from iPhone.

ildar170975 commented 1 year ago

Asked about it several times. Make one more post with this info: https://github.com/kalkih/mini-graph-card/issues/933#issuecomment-1454785577 If you have a problem with one sensor - do not confuse people with unrelated information. Show info for this particular sensor only. Please do not get offended, do not mean to offend you.

ildar170975 commented 1 year ago

@raphv Probably if we discuss this issue via Discord or Telegram, we would solve it faster. Otherwise we deal with language problem, misunderstanding etc.

First - two things which I would like to explain. If you do understand this - very good. But anyway just in case:

1.Assume you have a sensor which has a state and an attribute. Using history graph you may build a graph for the state only. To build a graph for the attribute - a template sensor must be created. Using mini graph you may build a graph for the attribute too - but in case of any problems with the graph (like a flatline) it is hard to investigate since there is nothing to compare with (i.e. history graph for this attribute). That is why I never use mini graph for attributes, always create template sensors for them.

2.There is a difference between history graph and mini graph. History graph shows exact changes of a state. Mini graph shows a calculated curve which is defined based on options like points per hour, smoothing etc. To make a mini graph show a curve which is close to a real curve - some options should be set properly, like smoothing = false, points per hour = at least same as a real update frequency (or 2x, 3x, …). For my “Speedtest” graphs (measured once an hour) I anyway use points per hour = 60 (or may be 12, do not remember exactly) - just to have a better presentation of my graph.

3.Sometimes ALL my mini graphs are flatlined. Then I open a History and see that all history graphs are flatlined too. It happens due to unknown bugs in Recorder, python , whatever… See it rather often. And this is not about mini graph - this happens with Recorder.

As for your posts - what I noticed:

1.Regarding this post: https://github.com/kalkih/mini-graph-card/issues/933#issuecomment-1454646494 Here I can see 2 mini graphs and 2 history graphs. Since there is no code - hard to say what could be wrong.

2.Starting from this post: https://github.com/kalkih/mini-graph-card/issues/933#issuecomment-1454731821 What I understand is one graph is flatlined. Which one particularly - was unclear, you have several lines. You said “green flatline” - but there are 2 green-ish lines))). That is why I asked “show me a card with ONE bad sensor” - to be sure which is a problematic one. Then I asked you to provide a history graph for this data. Since I do not know what is a name of a problematic sensor (I do not need a long friendly name, I need exact unique entity_id) and no code was provided for the history graph - again I may only guess. Whenever someone needs to report a problem - he should provide a detailed info which may be used by another person to reproduce the problem.

ildar170975 commented 1 year ago

First, I am not a developer of this card, but have some experience with it and trying to help people here with it. The author of this card is not maintaining the project anymore. There are a few Dev persons who sometimes suggest changes, a few users like me who help to investigate issues. As for the last example - it seems to be like a caching problem…. Could you clean a browser cache to be sure? Also, as I said before, I usually suggest to always post a history graph to exclude the Recorder’s issues…

Why 2 almost same graphs are different - have no idea((( And this cannot be reproduced, unfortunately.

MattJeanes commented 1 year ago

I'm also seeing this issue since upgrading HA to 2023.3.1:

image

image

Very strange!

ildar170975 commented 1 year ago

@MattJeanes No additional info is provided. Read my posts above, correct your code if needed.

MattJeanes commented 1 year ago

Apologies @ildar170975 should have provided more info

Here is the configuration of the card:

type: custom:mini-graph-card
entities:
  - entity: sensor.growatt_battery_state_of_charge
    name: Battery state of charge (past 24 hours)
show:
  points: hover
  labels: true
hours_to_show: 24
points_per_hour: 60
smoothing: false
aggregate_func: last

And a history state card:

type: history-graph
entities:
  - entity: sensor.growatt_battery_state_of_charge
hours_to_show: 24

The sensor updates roughly once a minute, although the value may not always change necessarily every time.

image

I have cleared my browser cache and tried other browsers and devices but they all show the same issue. Interestingly the current state does show correctly as you can see it shows 11% but the graph is not showing anywhere near that for some reason.

If there is any more information I can provide please let me know, the only relevant log in dev tools console is MINI-GRAPH-CARD 0.11.0.

I could try restarting HA but if it works then I won't be able to help diagnose the issue until it re-appears again.

The issue appears to have started after restarting HA in the first place, the graph flatlined after that point.

ildar170975 commented 1 year ago

Here is the history

No, edit your post and give a history-graph card (not a History view) with same hours_to_show. Also, always post a history-graph CARD, not graphs from more-info (which may have a useless statistics instead of real graphs).

lower_bound: 10
upper_bound: 100
color_thresholds:

Remove for testing.

points_per_hour: 6

Must be set based on recommendations I posted above. Also, what is a real update freq for the sensor?

All changes you may add in your post - to keep info in one place.

changing it to a minimal version

Never ever, default values will not give you a precise picture. Check this. Also, add this:

smoothing: false
aggregate_func: last
MattJeanes commented 1 year ago

@ildar170975 I have updated my comment above with the new information.

ildar170975 commented 1 year ago

Very strange. Usually - and it happens several times a month - I see flatlines too, but history-graphs are flatlined too, this is a Recorder's issue. The only choice I have then is a reboot. When only mini-graphs are flatlined, I could only suspect a cache problem, but you tested on several devices... Well, no ideas, unfortunately. Reboot and keep living...

MattJeanes commented 1 year ago

Rebooting HA 'fixed' it as I suspected

image

Hopefully this doesn't happen too often, I am curious where the bug is - HA or here, but in any case that's sorted it for the moment at least. Will be keeping an eye on the bug fixes list for the next HA patch 😄

ildar170975 commented 1 year ago

BTW - have you played with a new "set precision" feature? This was the latest thing which could affect, otherwise I am out of ideas.

bobloadmire commented 1 year ago

i've rebooted the host system multiple times, still not displaying correctly since updating.

MattJeanes commented 1 year ago

BTW - have you played with a new "set precision" feature? This was the latest thing which could affect, otherwise I am out of ideas.

That's the ability within HA to adjust the displayed precision of sensors introduced in 2023.3 right? No I haven't used this yet

ildar170975 commented 1 year ago

since updating.

to what? Using 2023.3.0. I am scared now to update to 2023.3.1 )))

bobloadmire commented 1 year ago

I thought of that, but changing precision didn't make a difference

ildar170975 commented 1 year ago

What HA version are you on? Updated to 2023.3.1, will see...

harristom commented 1 year ago

Same issue here on 2023.03.1

Card:

type: custom:mini-graph-card
name: Valves
entities:
  - entity: sensor.thermostat_living_room_1_valve_state
    name: Living Room 1
  - entity: sensor.thermostat_living_room_2_valve_state
    name: Living Room 2
  - entity: sensor.thermostat_living_room_3_valve_state
    name: Living Room 3
  - entity: sensor.thermostat_bathroom_valve_state
    name: Bathroom
  - entity: sensor.thermostat_kitchen_valve_state
    name: Kitchen
  - entity: binary_sensor.study_valve_state
    name: Study
    y_axis: secondary
  - entity: binary_sensor.bedroom_valve_state
    name: Bedroom
    y_axis: secondary
state_map:
  - value: 'off'
    label: Closed
  - value: 'on'
    label: Open
points_per_hour: 12
aggregate_func: max
line_width: 2.5
lower_bound: 0
upper_bound: 100
lower_bound_secondary: 0
upper_bound_secondary: 1

You can see that Living Room 3 shows 9% at 11:35-39 but actually was at 0% the whole time. Living Room 3 is just an example, the other valves on the chart have the same problem and indeed other mini graph cards are also exhibiting the issue.

2023-03-09 11_45_11-Home Assistant - Home – Home Assistant

2023-03-09 11_45_52-Home Assistant - Home – Home Assistant

diamant-x commented 1 year ago

Same issue here. Appeared after upgrading to any of the new 2023.3 versions. (at least right after installing x.2 and x.3). Data seems to be recorded correctly, is just the custom chart that doesn't load them. Clearing cache didn't work, other devices didn't work. Using the flag cache: false in the card doesn't work. Precission changes not used in this (or other) entity. Same behaviour in all mini-graph-card components. Changing points-per-hour doesn't change it. Only workaround is a second restart of HA.

image

yaml:

type: custom:mini-graph-card
entities:
  - entity: sensor.processor_use
show:
  points: hover
  labels: true
hours_to_show: 24
points_per_hour: 60
smoothing: false
aggregate_func: last
line_width: 1

Update after HA restart (container, not yaml or full OS): Missing history is now loaded, this is different between x.2 and now x.3, as in x.2 the missing period was still missing. -> I think this is related with the flag cache: false of the card. image

RPi4b8Gb
Home Assistant 2023.3.3
Supervisor 2023.03.1
Operating System 9.5
Frontend 20230309.0 - latest
antsalm commented 1 year ago

This flatlining has been present since 2023.3. Atleast for me. I run HA in a container. Sometimes rebooting Home Assistant is enough, sometimes rebooting whole container fixes it. It affects all devices, so CTRL+F5 does not fix it. I think it gets stuck on initial values of the used sensor.

Picture show how it briefly worked one of the reboots this morning as I was working with other stuff on HA.

image

type: custom:mini-graph-card
name: L1
aling_header: left
animate: true
hours_to_show: 2
points_per_hour: 30
hour24: true
line_width: 6
font_size: 78
align_state: center
decimals: 0
update_interval: 2
show:
  extrema: false
  icon: false
upper_bound_secondary: 2500
lower_bound_secondary: 0
entities:
  - entity: sensor.l1_power
    show_fill: true
    color: '#9e6b1b'
    name: L1

edit:

Noticed aswell, that when it starts working. Adjusting the points per hour removes the flat-line: Example video

Wummeke commented 1 year ago

Same issue here.

image

Both mini-graph-card and history card show the last 24 Hours. here are the configs:

- animate: true
  color_thresholds:
    - color: '#a55eea'
      value: -6.9
    - color: '#8854d0'
      value: -3.9
    - color: '#3867d6'
      value: -1.2
    - color: '#4b7bec'
      value: 1.6
    - color: '#2d98da'
      value: 4.3
    - color: '#45aaf2'
      value: 7.1
    - color: '#0fb9b1'
      value: 9.9
    - color: '#2bcbba'
      value: 12.7
    - color: '#20bf6b'
      value: 15.5
    - color: '#26de81'
      value: 18.2
    - color: '#fed330'
      value: 21
    - color: '#f7b731'
      value: 23.8
    - color: '#fd9644'
      value: 26.6
    - color: '#fa8231'
      value: 29.3
    - color: '#fc5c65'
      value: 32.1
    - color: '#eb3b5a'
      value: 35.9
  entities:
    - entity: sensor.outside_temperature
      index: 0
      name: 'Balkon'
      show_state: true
      state_adaptive_color: true
    - color: '#9f9f9f'
      entity: sensor.solar_elevation
      line_width: 1
      show_fill: false
      show_legend: false
      show_state: false
      y_axis: secondary
  hour24: true
  align_icon: left
  line_width: 2
  lower_bound_secondary: 0
  name: 'Balkon'
  points_per_hour: 12
  hours_to_show: 24
  show:
    graph: line
    points: false
  type: 'custom:mini-graph-card'

- type: history-graph
    title: "Balkon temperature"
    hours_to_show: 24
    entities:
      - entity: sensor.outside_temperature
        name: "Balkon"

After a restart of HA it works for a few hours, but then this happens again. I'm on HA 2023.3.3, I have this at least since 2023.3.0, but I'm not sure when it exactly started. I have my recoder data in a Postgres database on my NAS, not on the same device as HA. And no db issues mentioned in the log files.

Ascathon commented 1 year ago

For me it works fine on my Android phone with the app... But on the desktop in Firefox I had to restart hass to get it working. Changing settings like points her hour to a different value "fixes" it but changing it back to desired value gives me the flatliner again. So probably some cache but exactly.

Also works fine on new private session in Edge where I have never used hass.

2023_03_11_00_07_37

Existing Firefox sessino versus fresh Edge session

Ascathon commented 1 year ago

"Fixed" it by removing a node in the storage tab. 2023-03-11-00_13_51

canedje commented 1 year ago

here also problems. No history shown in the graphs. running HA 2023.3.3 supervised

EDIT: IT is just at Chrome. In edge it is showing the right graph image left picture edge, right picture chrome

EDIT 2:

even more strange. If I run HA local it is not showing the right graph If I run HA external over internet it is showing the right graph again image

Wummeke commented 1 year ago

I just tried different browsers, A fresh never been used before Firefox shows the same behaviour as in Chrome and on mobile. A fresh never been used before Edge also shows flatlines.

FireFox: image

Edge: image

Chrome: image

(config of the Balkon sensor is posted above, the Licht sensor is similar)

ildar170975 commented 1 year ago

Once again. Already wrote about it earlier but still see same posts.

  1. One issue = 1 post. No "wrote above/earlier", all info in ONE place.
  2. One post must contain this info: -- minimal mini-graph-card config to demonstrate an issue, w/o color_thresholds & state_map, for only ONE sensor which is flatlined:
    type: custom:mini-graph-card
    entities:
    - entity: sensor.my_sensor
    show:
    labels: true
    hours_to_show: 24 ## not too big & not too small - to show that 2/3 of time the graph is OK, then became flatlined
    points_per_hour: 60 ### at least equal to the real update interval or x2
    smoothing: false
    aggregate_func: last
    line_width: 1
    lower_bound: 0 ### or any other value to see a flatline

    -- a screenshot of that min-graph-card (default light theme); -- a conventional history graph for the same hours_to_show for the same ONE sensor - not a History page, not a more-info (read above why more-info may be WRONG); -- a screenshot of that history-graph (default light theme); -- info about sensor - how often it is polled (a real update freq); -- when you started observing flatlines (after which event, after which HA update); -- did it stop after HA reboot or after clearing a browser's cache (also, test with cache: false option); -- difference in different browsers if present.

P.S. Do not use default values for hours_to_show, points_per_hour & smoothing, use what is explained above.

MattJeanes commented 1 year ago

It seems clear to me that this is a bug introduced by an update of HA to 2023.3 (or maybe one of the patch versions), but the question remains of if the issue goes away completely after a HA reboot or if it returns later.

Personally, I have not seen the issue reoccur in the past couple days since rebooting, and I have applied a further update to 2023.3.3 without any issues too but I'm still waiting to see if it does come back.

If a reboot is all that's needed to fix it and it stays fixed then that's probably good enough and no further fix is required, maybe a little note in the readme or pinning this issue wouldn't go amiss but not super important.

If however it's going to keep coming back then it's going to need a fix somewhere, whether that's in HA itself or here I'm not sure but I think we should wait and see if a reboot fixes it permanently first.

It could be a bug in HAs API that mini-graph-card is using or it could be an implementation detail of something that used to work accidentally but now doesn't that mini-graph-card relied on. 🤷

So in summary, let's reboot and let live until we see it come back, then look into it further if it does.

Der-Sven commented 1 year ago

I can confirm, that the issues occur after updating to 23.3.x

What I have seen, is that for all my graph cards the same (not to the last digit after the comma) wrong values are beeing used for drawing. no matter what type of sensor.

Screenshot 2023-03-12 121320 Screenshot 2023-03-12 121340 Screenshot 2023-03-12 121401

Rebooting solved it for now. I will monitor and see if it reoccurs after time.

Edit: After reboot, it actually did flatline with the values received at reboot.

Screenshot 2023-03-12 143727 Screenshot 2023-03-12 143743
Crayjin commented 1 year ago

Same here. After reboot flatline started again. Here Reboot was done on 12.03.2023 at 22:08ish

image image

adrianrdzv commented 1 year ago

Yeah the issue is definitely related to the points per hour value. My card is displaying 12 hours, here are the screenshots with points_per_hour

1

Screenshot 2023-03-13 at 10 24 20

2

Screenshot 2023-03-13 at 10 24 28

3

Screenshot 2023-03-13 at 10 24 38

So originally I had 2, changing it to any other value (I put 2.1) and fixed it. Reboot did not work on my case.

Home Assistant 2023.3.3
Supervisor 2023.03.1
Operating System 9.5
sperglord8008s commented 1 year ago

Same Issue.

ildar170975 commented 1 year ago

I clearly explained here what kind of posts are expected here. Still see same posts w/o needed info. Probably some cases are related to "I do not know how to use the card" issue, but not possible to find it out - due to absence of info & ignoring requirements by users. Due to this - all "bad" posts after that post will be HIDDEN - unless users EDIT them accordingly to requirements. Edit your post, write here smth like "post edited" - then the post will be displayed. Any questions - ask here.

SgtBatten commented 1 year ago

@ildar170975 I can finally access github again. Thanks for your assistance going over this issue with me on the community forums. https://community.home-assistant.io/t/lovelace-mini-graph-card/71385/2294

I did not realise others were affected, so I agree this is likely an issue with HA and not the graph card.

For anyone following along, my experience was that I could rectify the graph by changing any single parameter. eve editing the name of the graph caused the issue to vanish. I could also reproduce the error only on existing charts. If i copy the exact code to a new dashboard it would occur, but any changes would fix it.

As it stands I only have one graph which goes back more than a day so it still shows the flatline still, all others have rectified since updating to 2023.3.3 as their hours showing has passed. Very odd one.

Thlerry commented 11 months ago

Looks like I am having the exact same issue, but on in the HA app on iOS. This is my graph in chrome on Mac: image

This exact same graph showing in the HA app with some flat lines: image

It was working fine in the APP and suddenly the lines became flat at some spots. Like others have mentioned editing the yaml and making a change fixes the issue for a bit, then it reappears.

image

Note: Looks like the flat line on the 3 sensors appear at the same time, as if there is no value that can be read for some time (or the same value is read).

Note2: Something even more weird, is the same graph in another dashboard doesn't have the flat lines, even on the HA app !