Successfully Setting Up Exhaust Fan Automation with Temperature and Humidity Sensors

Hey everyone! I wanted to share my recent success in setting up an automation for my exhaust fan using temperature and humidity sensors. It was a bit of a learning curve, but I managed to get it working smoothly. Here’s how I did it:

First, I wanted the fan to turn on when either the temperature or humidity exceeded certain thresholds. I used input_number helpers to set these thresholds, which made it easy to adjust them later. Initially, I tried using static values, but I knew using templates would give me more flexibility.

I encountered a bit of confusion with the logic at first, especially with combining ‘or’ and ‘and’ conditions. After some research and trial and error, I figured out how to structure the automation correctly. Here’s a snippet of what worked for me:

yaml
alias: Exhaust Fan Automation
trigger:

  • platform: template
    value_template: ‘{{ states.sensor.temperature | int > states.input_number.temp_threshold | int }}’
  • platform: template
    value_template: ‘{{ states.sensor.humidity | int > states.input_number.humidity_threshold | int }}’
    condition:
  • condition: template
    value_template: ‘{{ trigger.platform == “template” }}’
    action:
  • service: switch.turn_on
    entity_id: switch.exhaust_fan

This setup ensures the fan turns on when either condition is met. I also added a separate automation to turn the fan off when both conditions drop below the thresholds, ensuring energy efficiency.

I’m really happy with how this turned out and how it’s improved my home’s air quality. If anyone has questions or needs help setting something similar up, feel free to reach out! Let’s keep learning and sharing our smart home experiences. :slight_smile: