← Back to Chronicles

Building an Intelligent Kitchen
Ventilation System
with Sensor Fusion

Cliff Notes — TL;DR

A kitchen exhaust fan that once relied on fragile, trigger-specific turn-off logic — requiring the system to know exactly what turned it on before it could turn it off — has been completely refactored into a unified, sensor-driven ventilation manager. The new automation polls every three minutes, checks the live state of all physical sensors simultaneously, and only initiates a configurable countdown once every single condition has cleared. A new 30-minute runaway watchdog ensures the fan can never silently run indefinitely. The result is a system that doesn't care why the fan turned on — only whether every reason to keep it on has resolved.

Background

Background & Business Context

The kitchen vent fan, integrated into an LG over-range microwave, serves as the primary air quality management device for the main living area. It is triggered automatically by a network of sensors responding to cooking, heat, air quality events, and even passive house venting through the front door.

The original design tracked each trigger source with an input_select helper called kitchen_vent_trigger. The turn-off automation then checked the value of that selector against five separate branches — one for each trigger type — each with its own hardcoded delay and conditions. Two critical problems emerged:

  1. Blind Spots. When a new trigger source was added (like VOC-Pollutants), the turn-off automation had no corresponding branch. The fan would turn on — and never turn off. This exact failure was caught live during a morning debugging session when the vent had been running since 5:55 AM with no path to resolution.
  2. Race Conditions. If two triggers overlapped (e.g., the microwave finishes but the stove is still hot), the selector only stored the last trigger. The turn-off branch for that stored trigger might fire even though a different, still-active condition warranted continued venting.

The goal: eliminate the trigger-tracking pattern entirely and replace it with direct sensor observation.

"The system doesn't care why the fan turned on — only whether every reason to keep it on has resolved."
Architecture

Architecture Overview

The refactored system operates on a simple principle: poll the real world, not the trigger history.

System Design

  • Polling Loop: A time_pattern trigger fires every 3 minutes.
  • Sensor Fusion Gate: A single AND condition block checks all physical sensors simultaneously.
  • Countdown Timer: A user-configurable input_number.turn_off_count_down_minutes helper controls the cool-down period.
  • Soft Landing: The fan ramps to LOW for 15 seconds before full shutdown to prevent mechanical stress.
  • Watchdog: An independent automation monitors fan runtime and escalates after 30 minutes.
What We Built

What We Built

1. Universal Sensor-Driven Turn-Off

The five fragmented branches were collapsed into a single conditional block that checks every physical condition directly. Only when every row in this table evaluates as clear does the countdown begin:

SensorEntityClear Threshold
Microwave Powerdrn_iot_plug_3_th_microwave_powerBelow 100W
Stove TemperatureDevice sensor e21e76…Below 85°F
Carbon Monoxidefirst_air_quality_monitor_carbon_monoxideBelow threshold (or unavailable)
VOC Levelfirst_air_quality_monitor_volatile_organic_compoundsBelow voc_venting_threshold
Ambient Temperaturefirst_air_quality_monitor_temperatureBelow minimum_vent_temperature_helper
Front DoorContact sensor 2ba76b…Closed

A notable edge case was handled for the CO2 sensor: the entity was reporting unavailable after a recent reboot. An OR condition was added so that unavailable is treated as "clear" rather than blocking the turn-off indefinitely.

2. Debug-Mode Alexa Announcements

To aid development without cluttering daily life, a conditional Alexa TTS block fires only when the Announcements Verbosity helper is set to Debug. Under normal operation the system is completely silent:

automation.yaml — conditional debug announcement

- if:
  - condition: state
    entity_id: input_select.drn_announcements_verbosity
    state: Debug
  then:
  - action: notify.alexa_media_living_echo
    data:
      message: >-
        Kitchen vent all-clear detected. Starting
        {{ states('input_number.turn_off_count_down_minutes') | int }}
        minute countdown to shut off.

3. Runaway Vent Watchdog

A dedicated automation monitors fan.lg_microwave_fan using a state trigger with a for duration of 30 minutes. If the fan stays on continuously beyond that threshold — regardless of the reason — a critical-priority push notification is sent to the user's phone:

automation.yaml — 30-minute watchdog trigger

triggers:
- trigger: state
  entity_id: fan.lg_microwave_fan
  to: 'on'
  for:
    minutes: 30

This catches scenarios the turn-off automation cannot handle: stuck sensors, unavailable entities, or manual activations that were simply forgotten.

Results

Benefits Realized

AreaBeforeAfter
Turn-off logic5 trigger-specific branches1 universal sensor check
New trigger coverageRequires a code change per triggerAutomatic — sensors checked directly
Overlapping triggersLast-write-wins race conditionAll conditions evaluated simultaneously
Developer feedbackNoneAlexa announces countdown in Debug mode
Runaway protectionNone — fan could run indefinitely30-minute watchdog with critical phone alert
Countdown delayHardcoded per branch (90s, 5m, etc.)Single configurable helper for all scenarios
Conclusion

Conclusion

By shifting from trigger-history tracking to real-time sensor fusion, the kitchen ventilation system became both simpler and more robust. The input_select.kitchen_vent_trigger selector is no longer the gatekeeper for turn-off logic — the physical world is. This eliminates an entire class of bugs where the system "forgets" why the fan is on, and ensures that any future sensor additions (humidity, particulate matter, radon) require zero changes to the turn-off automation.

The fan simply stays on until everything is clear, then gracefully shuts down.

Built With

Home Assistant OS Raspberry Pi LG ThinQ Zigbee Air Quality Sensors Amazon Alexa
← Newer: The $100 Context Tax Older: Tainé Camera Chronology →