R5fan
(R5fan)
May 4, 2025, 6:47am
1
Simple time moving average helpers stop updating when the underlying sensor stops updating, like when its a power measurement from a socket that is off and remains at zero:
Ive read some ways to force updates in Z2M, but that feels like the wrong solution and apparently is going to get depreciated. A time based moving average should update every time, Id call this a bug, but Im open to work arounds.
Same thing here. I tried filtering the UV index to get rid of some weird, sometimes extreme 1-minute peaks that are obviously wrong:
- platform: filter
name: "Filtered UV Index"
unique_id: filtered_uv_index
entity_id: sensor.ecowitt_uv_index
filters:
- filter: time_simple_moving_average
window_size: "00:03"
precision: 0
This is what I get:
Simply does not return to zero no matter how long I wait. Only reloading all YAML config forces the sensor to update and it snaps back to where it should be.
Problem seems to be that this sensor I want to filter only updates upon change and the filter only seems to recalculate when it gets a new input - no matter how old that last input is!
…I too would consider this a bug, but I’m no expert.
Another “simple time moving average” filter that has an underlying sensor that constantly updates works perfectly fine.
Any ideas / solutions anyone?
The issue has been discussed quite some times:
opened 07:46PM - 13 Feb 25 UTC
closed 05:42PM - 14 Feb 25 UTC
integration: filter
### The problem
I‘m using a time-windowed moving average to calculate the power… consumption on a device. Since the recent update to 2025.1 the sensor only updates when the base sensor values change. When the base sensor value remains constant, particularly when the value goes to zero, the average window does not advance any longer.
sensor.waschmaschine_power is of state class measurement and device class power. The measurements come in regularly as observed on MQTT, but last_changed and last_updated do not change once the values are constant zero.
### What version of Home Assistant Core has the issue?
core-2025.2.1
### What was the last working version of Home Assistant Core?
core-2025.1.1 (assumed)
### What type of installation are you running?
Home Assistant Core
### Integration causing the issue
_No response_
### Link to integration documentation on our website
_No response_
### Diagnostics information
_No response_
### Example YAML snippet
```yaml
sensor:
- platform: filter
name: "Gemittelte Leistung Waschmaschine"
entity_id: sensor.waschmaschine_power
filters:
- filter: time_simple_moving_average
window_size: "00:01"
precision: 2
```
### Anything in the logs that might be useful for us?
```txt
```
### Additional information
_No response_
even in 2021:
opened 03:07PM - 08 Oct 21 UTC
closed 05:16PM - 14 Nov 21 UTC
integration: filter
stale
### The problem
If a sensor doesn't change its state for a longer time (e.g. po… wer produced by a solar panel during the night) the moving average filter remains at the state it had the last time the sensor changed. Only when a new change happens from the sensor the filtered state jumps to the value of the sensor during the 'static period'.

### What is version of Home Assistant Core has the issue?
core-2021.9.7
### What was the last working version of Home Assistant Core?
_No response_
### What type of installation are you running?
Home Assistant Core
### Integration causing the issue
Filter Sensor
### Link to integration documentation on our website
https://www.home-assistant.io/integrations/filter/#time-simple-moving-average
### Example YAML snippet
```yaml
sensor:
- { platform: simulated, name: test_sim, period: 3600, spread: 0.1 }
- { platform: filter, name: test_sim_rng, entity_id: sensor.test_sim,
filters: [{ filter: range, lower_bound: -0.2 }],
}
- { platform: filter, name: test_sim_sma, entity_id: sensor.test_sim_rng,
filters: [{ filter: time_simple_moving_average, window_size: "00:10" }],
}
```
### Anything in the logs that might be useful for us?
```txt
see pic above
```
### Additional information
the filtered state should be updated after some time if there is no change of input state.
and here in 2023:
Okay. So…How do I get round this please?
I have tried using a time_pattern trigger but I can’t work out how to incorporate filters into the code:
template:
- trigger:
- platform: time_pattern
seconds: /20
sensor:
- name: Import Power Filtered
unique_id: import_power_filtered
unit_of_measurement: "W"
state_class: measurement
state: "{{ states('sensor.givtcp_sa2236g166_import_power')|float(0) }}"
That is as far as I can get but I want to…
I’ going to try this one out:
Average Sensor for Home Assistant
1iverea9er
(1iverea9er)
October 14, 2025, 4:32pm
4
I have sent the corresponding bugreport .
While the PR was in progress, I rewrote the original integration code and fixed the issue in the custom HACS integration:
Contribute to 1iverea9er/Filter-Extended development by creating an account on GitHub.