🧯 Auto Fan Temp Control for 3-Speed-Fan using HA FAN % or MQTT Integration

This Blueprint is for controlling a 3 speed fan based on a temp sensor reading. There is a version for a 3 speed MQTT Fan & another version that communicates thru a Home Assistant fan entity using speed percentages.

:bookmark_tabs: Changelog

  • 2023-03-01: Add Author Tag. Bump HA required Version to 2023-3-0
  • 2022-12-26: BugFix. Time default no longer all zeros. Update default Tnx: cappadanna
  • 2022-12-12: Add Update Method Note, minor code change.
    • Name of Blueprint may have changed meaing you have to re-download with a new link.
    • If name changed, it is similar. Variables have not changed.
  • 2022-05-15-A: Minor code clean-up on Casting, no functional change.
    • Updated AirCon Start Example code to include start AirCon only if warm enough in room.
  • 2022-05-15: Add 2nd Blueprint triggered with HA fan entity, otherwise identical.
  • 2022-05-12.1: Change MQTT QOS to 2
  • 2022-05-12: Added support for weekday control
    • Added Action Selectors to the ‘fan’ & ‘all done’ loops for controlling AirCon or Heat or anything.
  • 2022-05-05: Updated for 2022.5.0 HA. Added Markdown to !input Descriptions plus shortcut and & or.
  • 2022-02-07: Add Default value to float filters (for HA Breaking change).
  • 2021-11-20: Add Minimum Home Assistant version.
  • 2021-09-03: Add Description.
  • 2021-08-19: Remove negative Temp Gap hysteresis, logic wrong.
  • 2021-08-04: Remove Default path as it made my fan beep for no reason.
  • 2021-08-02: First blueprint version :tada: needs Home Assistant Core 2021.7 or higher for Trigger_ID to work.

:crystal_ball: About this blueprint

Type of blueprint: AUTOMATION

Why do I need this?

This functionality started as a way to help my Bedroom AC unit keep an even temperature throughout the bedroom over night. My partner wanted the fan on, but not faster than it had to be. I wanted it to change speeds following the temperature of the room. So that’s what I did.

I continue to use this functionality in a slightly different way in my home system. If you want to see my use the automation form of this look at my HA Configuration GitHub repository. You will see that I have combined the control of the AC unit climate entity with this fan speed function and also have an ‘on demand’ version of this for when the room needs to be used during the day. My feeling was that I wanted to make this accessible to a wider audience, so I created this blueprint.

If you are looking to tweak the function here or are looking for something the same but different, hit me up on my Discord and we can work on that! If you see problems or have questions and don’t want to use Discord, Comments here are also welcome.

:wrench: Configuration

Requirements

  • 1 input_boolean entity as the feature so you can enable or disable the automation easily. Open your Home Assistant instance and show your helper entities.
  • 1 input_number used as the target temperature for the area you will be in.
  • 1 temperature sensor or temp average sensor or filtered temp sensor. This should be located physically within the breeze area of the fan for maximum desired affect.

:card_index_dividers: Input fields

people2monitor/name: Person or People to follow
    Select the Person you want this BP to trigger 
    on for this action. Multiples are allowed.

fan_control/name: Toggle to turn the fan function off for when away or seasonally
    (#1) ```input_boolean``` - If this is set to off, the Automation
    will be disabled.

room_temp_now/name: Room Temperature Sensor
    (#2) This is a temperature sensor or averaged temperature sensor
    preferrably within the path of the moving air from the fan.

room_set_temp/name: Room Target Temperature
    (#3) ```input_number``` - This is the target temperature of the
    room.

temp_gap/name: Temp Hysteresis
    (#4) This keeps the fan from speed cycling too often. (Let''s
    call it Hysterisis)

temp_gap_1_to_2/name: Temp Gap between Low and Medium
    (#5) This is the temp swing between Low and Medium.

temp_gap_2_to_3/name: Temp Gap between Medium and High
    (#6) This is the temp change between Medium and High.

fan_on_time/name: Time of day fan should start
    (#7) Set this for the time of day you want the fan function to
    be enabled.

fan_off_time/name: Time of day fan should stop
    (#8) Set this for the time of day you want the fan function to
    end.

weekday/name: Day of the week to use the Automation
    (#9) Enable it these days only

loop_action/name: User action for fan enabled condition (loop)
    (#11) This is intended to start / set temp on an AC unit or whatever
    you want to do. It is executed on every successful trigger that does not send
    the operation to off.

off_action/name: User action for fan off condition (off_action)
    (#12) This is intended to disable an AirCon unit or whatever you
    want to do. It is executed on every successful operation off trigger.

**AutomationFanControl_HA_fan.yaml ONLY:**

fan/name: Fan Entity
    (#10) This is the Home Assistant Fan entity

**AutomationFanControl_MQTT.yaml ONLY:**

mqtt_fan_topic/name: Fan Topic
    (#10) This is the MQTT Topic needed to change the fan speed.

:eyes: :airplane: Extended Information

Questions:

  1. You can use either Metric or Imperial, but the sensor and the input_number have to be using the same scale.
  2. The Hysteresis offset can be ‘0’ for the simplest operation. If you hare using the input_number to control both this and a climate integration, you may want an offset so the fan does not quick cycle. It basically move the input_number set point by the amount you pick
  3. You can have multiple automations running off of this with the same or different temp settings or times, but I suggest the times on ‘ENABLED’ versions do not overlap, or it will get very confused.

:hammer_and_wrench: HOW the Blueprint / Automation works

Walk-thru:

  1. The header of the Blueprint contains the required info plus the URL from where it came from.
  2. The input: section is where it gets the information it needs to fill in the blanks. This information is stored in the actual automation referencing this Blueprint when executing the task.
  3. The Variables section has several entries. These are converting !inputs to variables that can be used in templates.
  4. The triggers section has hooks for the listed things. 2 of them are used to stop the automation at the appropriate time, and the rest are used to start the automation or to adjust the fan speed on temperature changes.
  5. In the action the first test looks to see if the automation wants to stop. If that is not the case, it will test the temperature reading against the set point and adjust the fan speed accordingly.

🪄 How do I use this

In the yaml file linked below I show how I and controlling my AirCon within the fan loop. I have a window unit that is WIFI enabled for Temperature and on/off. I set this up to only trigger to the AirCon unit when it actually needs to change something to avoid rate limiting situations. Follow the comments and see the example yaml code here

:sun_with_face: :snowflake: Troubleshooting tip

If you are troubleshooting and you want to see more traces back when doing so, here is a TIP I’ve found.
Manually edit the automation created with the ui editor (or manually with a text editor) and add the following to have this automation contain 10 traces instead of the normal 5. Then if the automation is triggering often, you can see the last 10 traces to help you decide what the issue is.
HA Docs on this here.

trace:
  stored_traces: 10

:envelope_with_arrow: Version Updates

Updates will be published on my GIT repository with the rest of my Home Assistant Blueprint collection.

:envelope_with_arrow: There is not an official version control system for Blueprints. However I have found something that comes pretty close. It is not perfect, but for MOST Blueprints, it does just fine. I encourage you to check this script out and use it to easily check if I have updated this blueprint. :link:koter84 Blueprint Update Script

Please Click the :orange_heart: at the end of this top Post if you find this Useful

:calling: Software to Download :floppy_disk:

Click this badge to import this Blueprint. This is the version that uses HA fan integration and 0%, 33%, 66%, & 100% values to control the fan:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Click this badge to import this Blueprint. This is the version that uses MQTT speeds 0, 1, 2, 3 to control the fan:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Direct link to download Blueprint:

HA Fan Entity Version: Version: Copy this link if you want to import the blueprint in your installation.
https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/AutoFanControl_HA_fan.yaml

MQTT Version: Version: Copy this link if you want to import the blueprint in your installation.
https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/AutoFanControl_MQTT.yaml

:globe_with_meridians: All My Blueprints

Link to ALL my Blueprints

Here is a list of each of my blueprints, a quick description and jump links to the Blueprints Exchange post…

:cyclone: Scripts

:fire_extinguisher:Broadlink on Script Blueprint

This is a SCRIPT Blueprint that uses my Broadlink RM3 to turn my TV on and get it into the correct mode, Pushes remote buttons in sequence.

:fire_extinguisher:Tasmota EZ Button Blueprint

This Script Blueprint generates 3 Buttons to help you manage your Tasmota installed base. Restart All, Update a few, and Update all.

:fire_extinguisher:Play Media File Script Blueprint Blueprint

This is a SCRIPT Blueprint. This provides a way to play canned media files with the big long list of YAML entries but keep the main script or automation clean.

:fire_extinguisher:TTS All Message Blueprint

This script can use any of the 11 integrated TTS Platforms in Home Assistant to send a message to a media player.

:arrows_clockwise: Automations

:fire_extinguisher:Auto Fan Control Blueprint

This Blueprint is for controlling a 3 speed fan based on a temperature sensor. Both fan % control & MQTT fan control versions.

:fire_extinguisher:Door Open TTS Cloud-Say Message Blueprint

This Blueprint is a TTS.cloud-say version of another Door Announcer I found in the HA Blueprint Exchange.

:fire_extinguisher:Keypad Lock or puzzle Box Tool Blueprint

This Blueprint accepts 5 actions & when done in the right order, flips an input_boolean.

:fire_extinguisher:Zigbee2MQTT - Xiaomi Cube Controller Blueprint

This Blueprint uses a Zigbee2MQTT built sensor to sort out the multitude of commands from the Xiaomi Magic Cube Remote.

:fire_extinguisher:Zigbee2MQTT - ZemiSmart ZM-RM02 Controller Blueprint

This Blueprint uses the Z2M (Zigbee2MQTT) imported Action sensor to sort out the 18 commands from the ZemiSmart ZM-RM02 Controller.

:fire_extinguisher:ZHA - Xiaomi Cube Controller Blueprint

This Blueprint uses a ZHA built sensor to sort out the 38(+54) commands from the Xiaomi Magic Cube Remote.

:fire_extinguisher:Device_tracker Monitor & Notifier

This Blueprint Monitor’s device_tracker entities that you choose & notifies you if they go offline. Then it gives you the opportunity to devise an action to deal with it.

:fire_extinguisher: Zigbee2MQTT Aqara Magic Cube T1-Pro CTP-R01 Xiaomi Lumi cagl02

This Blueprint gives you literally hundreds of actions available on the new Magic Cube.

:fire_extinguisher: Humidifier Water Throttle Control

This blueprint monitors a humidity sensor & by determining the error from the goal, sends info to a humidifier as to how long to flow the water. This saves water & has a minimal effect on function. Requires a Sonoff SV, Generic hygrostat Integration, & a suitable humidifier.

:fire_extinguisher: Person_Alert_Blueprint

This BluePrint will monitor a person or persons, and when they ‘enter’ or ‘leave’ the zone or zones you pick, it will trigger an action for both enter and leave phases. Yes, it will watch multiple people and multiple zones at the same time!

:fire_extinguisher: Octoprint_Additional_Buttons_Helper

This is Blueprint is provided as a helper for people using the Octoprint Plugin called OctoPrint-HomeAssistant. What this does is add 6 buttons, 4 of which you as the user can set your own G-Codes to for customizing. Also adds safe shutdown and presentation functions.

:man_juggling:t5: Contact Links or see my other work

What are we Fixing Today Homepage / Website: https://www.WhatAreWeFixing.Today/

Channel Link URL: (WhatAreWeFixingToday) What are we fixing today? - YouTube

Discord Guild: (Sir_Goodenough#9683) WhatAreWeFixingToday?

:cheese: If you want to support me

Buy me Coffee: Sir GoodEnough

PayPal one-off donation link: PayPal.Me

#WhatAreWeFixingToday

#SirGoodEnough

Hello, i am experimenting with the blue print, but the fan is always running the same speed, what am I doing wrong?

Can you post your automation calling file, maybe I can see something.
And are you using the HA Fan version or the MQTT version?

November 30, 2022 > Update. Added ZHA Cube Controller version to library.
December 11, 2022 > Update. Added Device Tracker Blueprint to the list.

  • 2022-12-12: Add Update Method Note, minor code change.
    • Name of Blueprint may have changed meaing you have to re-download with a new link.
    • If name changed, it is similar. Variables have not changed.

Hi. Great blueprint to control my hvac. Would it be possible to add a bypass for the time start/stop? I basically want the fan function to run all the time until I manually turn it off. I could set start at 00:00:00 and end at 23:59:59 but that could make the fan turn of and then on in a second, correct me if I’m wrong.

Set it for all zeros both start and end. Actually setting both times the same at any time makes sure it never stops.

The HA rules changed since I wrote this and it no longer assumes all 0’s like it originally did. I noticed that bug this this week when I was working on a revision.
I’ll fix the masters now.

Update…

  • 2022-12-26: BugFix. Time default no longer all zeros. Update default Tnx: cappadanna

Added new blueprint

:fire_extinguisher: Zigbee2MQTT Aqara Magic Cube T1-Pro CTP-R01 Xiaomi Lumi cagl02

This Blueprint gives you literally hundreds of actions available on the new Magic Cube.

New Version:

:bookmark_tabs: Changelog

  • 2023-03-01: Add Author Tag. Bump HA required Version to 2023-3-0
1 Like