kalkih / mini-graph-card

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

Feature request: dynamic bound or the ability to ignore some invalid data #740

Closed kerhbal closed 2 years ago

kerhbal commented 2 years ago

hi, first of all this is really fantastic, thank you for developing it! Background My thermostat sometimes just return a -124% humidity...like this:

Vivaldi-Overview – Home Assistant - Vivaldi--2022-02-23 at 11 32 49

I know there is lower_bound we can use to limit the graph, but it's a fixed one. If I choose to set the lower bound to 40, I cannot see the ones below it, but if I set it to be 20, the graph will be more flat and makes less sense. What would be best If we can ignore all the data points below 0 before generating the graph, that will be best. In this scenario, we can assume no data points in the period. Hope this makes sense, thanks!

ildar170975 commented 2 years ago

but it's a fixed one

Try lower_bound: ~40

My thermostat sometimes just return a -124% humidity

These wrong values may be filtered by using a template sensor. Some my devices return a 99999 value - I have to filter it in a template sensor.

kerhbal commented 2 years ago

@ildar170975 I see. since lower_bound: ~10 will allow any data to break it as shown below(use 10 as example here):

Vivaldi-Overview – Home Assistant - Vivaldi--2022-02-23 at 11 46 27

Though I haven't tried the template, should be a good solution. thanks!

ildar170975 commented 2 years ago

Me too - for humidity graphs I use ~10 since in my apartment it is usually 25..50%.

Here is a good explanation of the "soft bound": https://community.home-assistant.io/t/lovelace-mini-graph-card/71385/1372?u=ildar_gabdullin The y-axis is normally set to the values of lower and upper bounds, but if the graph value is lower than the lower bound or higher than the upper bound, the y-axis is expanded. Hope this is a correct description, it usually matches my observations.

ildar170975 commented 2 years ago

@kerhbal Please close the issue if it is resolved

kerhbal commented 2 years ago

@ildar170975 yeah sure will try it later today. thanks!

kerhbal commented 2 years ago

the filter template works! thanks!

kettly1260 commented 1 year ago

the filter template works! thanks!

can you give me a link or a temperature? I meet the same question.

kerhbal commented 1 year ago

@kettly1260 I have something like this in configuration.yaml to create a filter based on my humidity sensor

sensor:
  - platform: filter
    name: "filtered_humidity"
    entity_id: sensor.humidity
    filters:
      - filter: outlier
        window_size: 4
        radius: 40

I don't quite remember what the numbers mean... you can check it here https://www.home-assistant.io/integrations/filter/

kerhbal commented 1 year ago

and this filter acts as a new entity(a virtual one), then you can ignore the old entity and just put this new entity in any graph/frontend