kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
3.06k stars 237 forks source link

Weird lower/upper bounds MAY BE shown for a not-recorded entity #1135

Open ildar170975 opened 2 months ago

ildar170975 commented 2 months ago

Some sensors are EXCLUDED from Recorder:

recorder:
  ...
  exclude:
    ...
    entities:
      ...
      - sensor.xiaomi_cg_1
      - sensor.xiaomi_cg_2 

Consider this card for the 1st sensor:

type: custom:mini-graph-card
entities:
  - entity: sensor.xiaomi_cg_1
    attribute: co2
show:
  labels: true

image

Note that:

  1. A flat line is shown.
  2. Lower & upper bounds are same & equal to some weird "559" value: image

And same card for the 2nd entity: image

Note that:

  1. No graph is shown (as expected).
  2. Lower & upper bounds = 0 (as expected).

About 2 weeks ago (23.08.24) while checking this issue the 1st sensor was INCLUDED in Recorder for a few hours. This is the last record in DB for this sensor: image where last_updated_ts is 1724421565.94111 (Friday, 23 August 2024 16:59:25.941 GMT+03:00).

And attributes_id of this last record is image with that "559" value.

Means - this old "559" value recorded 2 weeks ago is shown in a graph - although hours_to_show: 24 (a default value). There will be same glitch if hours_to_show is defined explicitly: image

Imho we should not use a value from a DB if this value is beyond a selected time interval. Probably, there may be some negative side effects after this will be fixed, not sure...

P.S. Browser's cache was cleared. v0.12.2-dev.2 2024.9, Chrome

FAB1150 commented 2 months ago

maybe the best workaround for now is using the "sampler" integration on sensors that update very slowly. I do that with many sensors not just for graphs (especially for reinmann sum sensors, before the update that basically does the same thing as sampler).

ildar170975 commented 2 months ago

Thanks about info, I will read about “sampler”. But here no workaround needed - this a harmless glitch: since I know that this entity is excluded from Recorder - I will not want to see it’s graph in mini-graph-card. The main point is that old record is not supposed to be used since it is beyond a time interval.