Lowpass filter does not recalc if sensor value remains unchanged

Lowpass filter only does adjust/recalc if the sensor value changes. If the sensor returns a stable value (lets say solid 0% or 100%) then the value remains at whatever it was at the last change.

- platform: filter
  name: "boiler average"
  entity_id: sensor.solar_boiler
  filters:
    - filter: lowpass
      time_constant: 3
      precision: 0

How can I trick the lowpass filter to recalc even on stable input so its value approaches solid 0% (or 100%) in the example. see the blue averaged (lowpass) remains 40% even as boiler value is constant 0.

image

just seen, this post is dup to Filter sensor not being updated when source sensor is updated , sorry

The state of the sensor needs to change, to enforce a re-evaluation.
Changing a state-attribute also counts as a state change.
If the sensor is a template sensor you could just add an attribute “timestamp” with a value of the current time, and update the sensor on a time schedule.
This would trigger a re-evaluation.
This is an example I use as a base for an Integrationssensor, but this should also apply to filter:

  - trigger:
      - platform: homeassistant
        event: "start"
      - platform: time_pattern
        minutes: "/1"
    sensor:
      - name: home_calc_base_power
        unique_id: home_calc_base_power
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        icon: mdi:flash
        state: |
          {% set consumer = {
              'shelly1':4*0.7,
              'shelly25':2*0.7,
              'shelly3EM':2*1.0,
              'shellyEM':1*1.0,
              'shellyRGBW':1*0.5,
              'shellyDimmer':2*0.7,
              'shellyPlugS':5*0.7,
              'shellyPlug':2*0.7,
              'sonoff':2*0.5,
              'tuyaBulp':1*0.5,
              'hub_sculpture':1*1.2,
              'bedroom_charger':1*0.0,
              'seantv':1*1.7,
              'traffo':2*0.0
             } 
          %}
          {{ (consumer.values()|map('float',0)|sum)|round(2,0) }}
        attributes: 
          triggered_at: "{{ now() }}"
2 Likes

I had the same problem.
The solution was, to config the Sensor (via MQTT in my case) with “force_update: true”

see: How to force a template sensor to update even if the value hasn't changed?

Is there a way to get this working with a lowpass filter? I tried but it says force_update is not valid here, I guess that’s only for template sensors. I’m trying to smooth out quick peaks and valleys in a solar power production sensor. The problem is, when the sensor remains at zero for a long time, the filtered sensor never updates.

  - platform: filter
    name: Filtered Grid Export
    entity_id: sensor.grid_export
    filters:
      - filter: lowpass
        time_constant: 5
    force_update: true

Nevermind, I think lowpass is the wrong tool for this job, I’ll use a statistics sensor instead.