Moving average filter not behaving as expected

I have added an entity that should be the 12-hour moving average of the outside temperature:

  - platform: filter
    name: Gedämpfte Aussentemperatur
    entity_id: sensor.temperatur_aussen
    filters:
      - filter: time_simple_moving_average
        window_size: 12:00

However what I get isn’t anywhere close to the moving average:
grafik

The green/blue line is the original sensor values, the red one the filtered one. As you can see it’s almost exactly following the original values, there is no averaging over the last 12 hours. Is this a bug or did I configure (or understand) the filter wrong?

I think 12h is just too big. the idea of such a filter is to smooth erratic values.
What kind of data/chart are you expecting?
Have you tried with a smaller value (something between 5-15 min?)
Also you haven’t set a window_size, which defaults to 1h so 12h might just be too big. Have you tried to set the window_size to 12 or 24h?

I haven’t tried with smaller values because I need 12h so there is not point in using smaller ones. And I did set a window_size, see my code snippet above.
If this filter doesn’t work with larger values (larger than what exactly?) then it should be documented.
I’m expecting something similar to this:
ma

Read is the line of the moving average.

I’m writing a control for a heating system and there you often use the 12 hour moving average outside temperature to decide whether it’s summer (=> heating off) or still winter (=> heating on).

try wrapping your time in quotes.

That seems to work considerably better now. It’s too early to say it’s exactly what I want but at least it doesn’t follow the source value as closely as before any more.
In this case the documentation at https://www.home-assistant.io/integrations/filter is wrong and should be updated.

Good idea, feel free to do a PR and submit a change :wink: