Dear community, freshly coming from FHEM I am trying to (re-) create an automation that monitors the state of a ventilation fan. Having searched for hours, I still can’t wrap my head around how to do this. Now my hope is that some of you can point me in the right direction.
The problem I want to solve is this: The ventilation fan is switched on with a wall switch and once switched off will run for a follow-up time of 15 minutes. The only information I have in HA is the state of the switch (on/off), using a powermeter is not an option. From this and the known follow-up time I want to infer the state of the ventilation fan (on/follow-up/off). In the end, I want to use this state to keep track of the total runtime of the fan (filter has to be replaced every X hours) and visualize the state with differently colored icons in the GUI.
I assume I need some kind of state entity that stores the fan state and that I can use to show different icons/colors (how?) plus an automation that reacts to state changes of the switch and has a timeout to induce the followup-to-off-transition, triggered by the on-to-off-transition of the switch. Obviously, this timeout needs to be canceled if the switch changes back to on while the timeout is still running.
When the runtime counter reaches a certain value (e.g. 100h), an item should be added to the todo-list to exchange the filter. The runtime-counter should be reset to 0 when this todo-list item has been marked as done. Until then, the hours should still be counted and if possible, the todo-list entry should be updated with the new value.
I’m not expecting a ready-to-use solution (unless there’s already a blueprint I just failed to find); any hints on how to approach this automation and its various aspects are highly appreciated.
and 3 automations created with the UI to select the duschbad_luefter_state:
alias: Duschbadlüfter wird angeschaltet
description: "Fan being switched on"
triggers:
- trigger: state
entity_id:
- input_boolean.switchdemo # dummy-switch for testing - replace with actual wall-switch
to: "on"
actions:
- target:
entity_id: input_select.duschbad_luefter_state
data:
option: "on"
action: input_select.select_option
mode: single
second one for the off->followup transition
alias: Duschbadlüfter läuft nach
description: "Fan keeps running for another 15 min."
triggers:
- trigger: state
entity_id:
- input_boolean.switchdemo # dummy-switch for testing - replace with actual wall-switch
to: "off"
conditions: []
actions:
- target:
entity_id: input_select.duschbad_luefter_state
data:
option: followup
action: input_select.select_option
mode: single
and ast one for the followup->off transition:
alias: Duschbad Lüfter geht aus
description: "Fan followup time ends"
triggers:
- trigger: state
entity_id:
- input_select.duschbad_luefter_state
to: followup
for:
hours: 0
minutes: 15
seconds: 0
conditions: []
actions:
- target:
entity_id: input_select.duschbad_luefter_state
data:
option: "off"
action: input_select.select_option
mode: single
This already works like intended, but I’m wondering if it’s good practice to have 3 individual automations or if it would be better to combine then into one. I’m also wondering if the automations should be included in the package yaml where the related entities are defined. I’d be happy to hear your thoughts on this.
Hmm, for now I can live with these individual automations, optimizations may be for another day. Meanwhile, I’ve got the todo list integration working, too. Adding to the todo list works as you proposed. For resetting the filter_changed_datetime helper, I’m using the blueprint Restart Safe - To-do List Chore Notifications! with an action that is executed when the entry is ticked off.