HVAC Fan runtime, filter replacement date, and reset button

I have information overload reading all of the posts here, on Reddit, and on a blog. So I have a hard time figuring out what I need to do for my goal which is to track the number of hours the HVAC fan has been ‘on’, a reset for fan on time, and how many days passed since last filter change, as well as the date the filter was last replaced. I want all of that in an entities card but want a way to prevent accidentally running the reset script.

The posts and blog that I have looked at are

The first one by Tediore is the closest to what I want so I used his as a guide to make my own package with the automation, sensors, script, and helpers.

This is what I have so far -

automation:
# Add previous day's runtime to input_number each night
- alias: Store HVAC runtime nightly
  initial_state: 'on'
  trigger:
  - platform: time
    at: '00:00:01'
  action:
  - service: homeassistant.update_entity
    entity_id:
    - sensor.fan_time_today
    - sensor.fan_time_yesterday
  - service: input_number.set_value
    entity_id: input_number.hvac_runtime
    data_template:
      value: "{{ ((states('sensor.furnace_filter_life') | float) + (states('sensor.fan_time_yesterday') | float)) | round(1) }}"

sensor:
# Fan time today
- platform: history_stats
  name: Fan time today
  entity_id: sensor.hvac_fan
  state: 'on'
  type: time
  start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
  end: '{{ now() }}'

# Fan time yesterday (for use in storing runtime each night)
- platform: history_stats
  name: Fan time yesterday
  entity_id: sensor.hvac_fan
  state: 'on'
  type: time
  duration:
    hours: 24
  end: "{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}"

# Fan time current day before filter change script is called
- platform: history_stats
  name: Fan time before last filter change
  entity_id: sensor.hvac_fan
  state: 'on'
  type: time
  start: "{{ as_timestamp(now().replace(hour=0).replace(minute=0).replace(second=0)) }}"
  end: "{{ as_timestamp(states('input_text.furnace_filter')) }}"

- platform: template
  sensors:
  # Created to use HVAC action state attribute in the history stats sensors
    hvac_fan:
      friendly_name: HVAC Fan
      value_template: "{{ state_attr('climate.thermostat','fan') }}"

  # Used to display current total runtime in frontend
    furnace_filter_life:
      friendly_name: "Filter runtime"
      value_template: >
        {% set active = states('sensor.fan_time_today') | float %}
        {% set runtime = states('input_number.hvac_runtime') | float %}
        {{ (runtime + active) | round(1) }}
      unit_of_measurement: 'h'
      icon: mdi:air-filter

script:
# Reset filter change date and set total runtime to zero
  furnace_filter_date:
    alias: Furnace filter change date
    sequence:
    - service: input_text.set_value
      entity_id: input_text.furnace_filter
      data_template:
        value: '{{ now() }}'
    - service: homeassistant.update_entity
      entity_id:
      - sensor.fan_time_before_last_filter_change
    - service: input_number.set_value
      entity_id: input_number.hvac_runtime
      data_template:
        value: >
          {% set active = states('sensor.fan_time_before_last_filter_change') | float %}
          {{ 0 - active }}

input_text:
# Store furnace filter change date
  furnace_filter:
    name: Furnace filter change date

input_number:
# Used to store runtime nightly to reduce reliance on history
  hvac_runtime:
    name: Runtime
    icon: mdi:clock-outline
    mode: box
    min: -500
    max: 500
    unit_of_measurement: 'h'

He made his package with input_text. Not sure if I should leave it as input_text. If I should change the package to input_datetime how do I do that so that all related integrations continue to work?

I want a sensor for the input_text.furnace_filter so that the date and time doesn’t have an underline in the entities card. How does that need to be written into a template? I found a thread at Show Input Datetime as value not as input but I am not sure if the first example is all I need and that is for input_datetime and not input_text

1 Like

I just realized that input_text.furnace_filter is used to calculate sensor.fan_time_before_last_filter_change which is used to update input_number.hvac_runtime to 0 when the reset script is activated which in turn would affect sensor.furnace_filter_life So if I change input_text.furnace_filter to input_datetime.furnace_filter the only other integration I should have to change is the end time of sensor.fan_time_before_last_filter_change

I’m still not sure if I need to change anything in that respect.

Did you managed to make this one work? Kind of the same problem i have, after multiple searches i got the same results

I was able to figure out a way to do this without writing and special code. I have two furnaces and I wanted to track how long the furnace is running and use that to know when to change the filter instead of just every x days. So for each furnace I created a timer and set it to 200 hrs. Then I have an automation that catches when the furnace goes to heating or cooling and it starts the timer. Then when the furnace goes back to idle an automation pauses the timer.
Lastly I have an automation when the timer finishes it updates a text box in my dashboard that states the filter is dirty. I could have it send me a notification as well. I did add a button on my dashboard that resets the timer and the text box when I change the filter.

2 Likes