Having somewhat of a thing with MinMax sensor

So in configuration.yaml I have a sensor, a maxmin sensor:

# Min value for temp outside sensor....
  - platform: min_max
    name: min_outside_temperature
    type: min
    entity_ids:
      - sensor.utesensor_6_temperatur
      - sensor.utesensor_4_temperatur
      - sensor.sensor_utsidan_utsikten_temperatur
      - sensor.sensor_utsidan_matplats_temperatur

Now it works most of the time, and then from time to time it seems to grab the max value instead of the min value? So it looks a bit lite this in ApexCharts:

Now I have actually been inside the statistics and statistics_short_term and kind of handled the two first ones by adjusting the data stored - but that has NOT removed them from ApexCharts. That might be something else like where more is the statistics data stored? Or is ApexCharts storing something locally?

Anyways, the three red peaks in the graph, they are max value from the sensors above, but why minmax chooses to select max value instead of defined min value is something I simply do not know.

The green graph that is "over" the red one, is a sensor that removes the incorrect data:

# Maska bort felvärden i min_max som kan slå ut tempen....
  - sensor:
    - default_entity_id: sensor.faktisk_utsida_temperatur
      name: Fakstisk Utomhus Temperatur
      unit_of_measurement: "°C"
      state: '{%- if (states(''sensor.faktisk_utsida_temperatur'') in [''unavailable'',''unknown'',''Okänd'',''Otillgänglig'',''none'']) -%} {{ states(''sensor.min_outside_temperature'') }}
              {%- elif (states(''sensor.min_outside_temperature'') | float > ( states(''sensor.faktisk_utsida_temperatur'')|float + 3 )) -%} {{ states(''sensor.faktisk_utsida_temperatur'') }}
              {%  else %} {{ states(''sensor.min_outside_temperature'') }}
              {%- endif -%}'

So anyone that has any good news? or ideas why I am fighting this?

Just looking at that, regardless of if the data is min or max or noise or rabbit droppings, I think I would add a filter. If the value is more than x% away from the prior then drop the data as invalid and usew the prior kind of thing.

That is what the green graph is doing, the so called "Faktiskt Utomhus Temperatur" - or well it compares if temperature is more than +3 Celsius compared to last time. But it is kind of a filter.

I have also started to play with creating my own min sensor. It is only 4 different entities, so it should be fairly straight forward to set up an if statement to select the lowest value...

I Decided to go the old way, and created another sensor that does min() in the old fashioned way - and it to this date the only solution that always presents the correct value:

  - sensor:
    - default_entity_id: sensor.faktisk_utsida_temperatur_2
      name: Faktisk Utomhus Temperatur 2
      unit_of_measurement: "°C"
      state: '{%- if (states(''sensor.faktisk_utsida_temperatur'') in [''unavailable'',''unknown'',''Okänd'',''Otillgänglig'',''none'']) -%} {{ states(''sensor.min_outside_temperature'') }}   
              {%- elif (states(''sensor.utsikten_utesensor_temperature'')|float > ( states(''sensor.sovrum_utesensor_temperature'')|float) and  states(''sensor.matplats_utesensor_temperature'')|float > ( states(''sensor.sovrum_utesensor_temperature'')|float) and states(''sensor.balkong_utesensor_temperature'')|float > ( states(''sensor.sovrum_utesensor_temperature'')|float)) -%} {{ states(''sensor.sovrum_utesensor_temperature'') }}
              {%- elif (states(''sensor.sovrum_utesensor_temperature'')|float > ( states(''sensor.utsikten_utesensor_temperature'')|float) and  states(''sensor.matplats_utesensor_temperature'')|float > ( states(''sensor.utsikten_utesensor_temperature'')|float) and states(''sensor.balkong_utesensor_temperature'')|float > ( states(''sensor.utsikten_utesensor_temperature'')|float)) -%} {{ states(''sensor.utsikten_utesensor_temperature'') }}
              {%- elif (states(''sensor.utsikten_utesensor_temperature'')|float > ( states(''sensor.matplats_utesensor_temperature'')|float) and  states(''sensor.utsikten_utesensor_temperature'')|float > ( states(''sensor.matplats_utesensor_temperature'')|float) and states(''sensor.balkong_utesensor_temperature'')|float > ( states(''sensor.matplats_utesensor_temperature'')|float)) -%} {{ states(''sensor.matplats_utesensor_temperature'') }}
              {%- elif (states(''sensor.utsikten_utesensor_temperature'')|float > ( states(''sensor.balkong_utesensor_temperature'')|float) and  states(''sensor.matplats_utesensor_temperature'')|float > ( states(''sensor.balkong_utesensor_temperature'')|float) and states(''sensor.sovrum_utesensor_temperature'')|float > ( states(''sensor.balkong_utesensor_temperature'')|float)) -%} {{ states(''sensor.balkong_utesensor_temperature'') }}
              {%  else %} {{ states(''sensor.min_outside_temperature'') }}
              {%- endif -%}'