GOAL: Making a simple notification that alerts me when the airco filter has been used for X amount of hours
This seemed easy enough to do but has proven to be a lot harder than I thought. I did learn quite a bit and found multiple people struggling to get this to work. I am finally happy with the result and wanted to share all the hoops I jumped through to get this working.
I also want to keep this as a reference for myself so I can add other filters in the future.
Problem 1: Finding out how many actual hours the airco has been running in both cooling as heating modes
Turns out that my airco unit, an Innova 2.0, only tracks in which mode it is in. As it is almost always on and controlled by set temperatures, calculating the operating time was useless.
By looking in the “States” tab in the Developer Tools, I found out that my airco unit had an “hvac_action” attribute. This shows the actual state when it is heating, cooling or idling. This attribute just doesn’t have a sensor yet.
I made a new sensor by making a new helper under “Template → Sensor” and added in the state as: “{{ state_attr(‘climate.innova_leaf’, ‘hvac_action’) }}”. First the entity is mentioned and second the desired state that needs to be monitored.
{{ state_attr('climate.innova_leaf', 'hvac_action') }}
So I finally got my sensor keeping track of the actual operating modes.
Problem 2: Calculating the amount of hours the airco has been running in these modes
There is a dedicated helper “History Stats” that can calculate how many hours the airco has been in certain states. You can also combine states so this helper should be ideal. The only problem is that it uses the History database which only goes back 10 days. I want to keep track over multiple months.
A solution is to use this helper to calculate the daily operation times and figure out later how to add up these days.
Setting up the helper was straight forward. It just didn’t know the different states the above made sensor can have but these can be inserted manually. In my case “cooling” and “heating”.
Next up I just had to define the start: {{ now().replace(hour=0, minute=0, second=0) }}
And the end: {{ now() }}
Now I get a daily total in hours of when my airco actually has been cooling or heating.
Problem 3: Making a persistent counter covering up to multiple months
To persistently count up the daily runtime (even through home assistant restarts) I used again a helper, “Utility Meter”. I set it up to keep track of the above “History Stats” sensor.
Now I have my total airco runtime that can keep track over multiple months.
Problem 4: Making a switch to reset the counter after the filter has been changed
Next I wanted to make a switch that jumps to the ‘off’ position when the “Utility Meter” helper reaches a certain value. I like a visual queue in my airco Device tab and this switch should reset the “Utility Meter” back to 0 when turned back on, indicating that the filter got cleaned.
I created a 4th helper, this time a “Template → Switch”.
I added in the Action that when it is turned on, it calibrates the “Utility Meter” helper and sets its value to “0”. This restarts the integration and starts a new cycle.
Problem 5: Change the standard ‘bolts’ to a proper switch
Making a switch automatically sets the used icons to thunder bolts. I wanted a classic toggle switch as this seemed more appropriate for this function.
I found out that this is caused because the assumed state is set to true. This can be seen in the “States” tab in the Developer Tools: “assumed_state: true”. Changing this to true here isn’t persistent and it will revert to false.
A few lines have to be added to the configuration.yaml to set this to false and make it persistent.
homeassistant:
customize:
switch.innova_filter_clean:
assumed_state: false
Problem 6: Make the automation trigger the switch and send a notification
Finally the easiest part, a small automation that triggers when the numeric state of the “Utility Meter” helper goes above a certain threshold. It turns the defined switch to the off position and sends me a notification to clean the filter. As soon as the filter has been cleaned I just toggle the switch back on and the counter resets to “0”.
This was way more work than I originally anticipated and I had to solve multiple problems. But I am happy with the end result:


