šŸ§Æ 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

  • 2024-06-04: Blueprint Input Sections for enhanced Descriptions.
    • (Documentation change 2-7-2024 to add License notice. Changes only to Descriptions.)
  • 2023-08-07: Updates for Home Assistant 2023.8
    • Selector syntax change
    • Condition Selector addition (where applicable)
    • MQTT Discovery name changes (where applicable)
    • Clean-up code formatting
  • 2023-07-19: Remove Helper on MQTT version
  • 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 meaning 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

What if I am having problems getting it going?

You can contact me for help, see the links below.

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.

:moyai:License Notice:

  • Copies of the original Blueprint that were converted via the ā€˜Take Controlā€™ feature or other means are officially not supported by me.

  • I may or may not be able to support you when you have a problem after you make changes to my code, as some of the code is no longer mine.

  • I & my license also require attribution as a link back to the original should you use this code in your own creation.

  • Here is a link to my license & the original github post expected to be followed & referenced as attribution should you use this code elsewhere.

: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.

additional_conditions:
    Extra conditions you may want to add to this automation 
    (Example: Home occupied, TV on, etc)

: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.

:magic_wand: 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

https://github.com/SirGoodenough/HA_Blueprints/blob/master/README.md

: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) https://bit.ly/WhatAreWeFixingTodaysYT

Discord Guild: (Sir_Goodenough#9683) WhatAreWeFixingToday?

:cheese: If you want to support me

Buy me Coffee: https://www.buymeacoffee.com/SirGoodenough

PayPal one-off donation link: PayPal.Me

#WhatAreWeFixingToday

#SirGoodEnough

1 Like

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

Hi. Have been using your blueprint for my HVAC together with a Sunricher 0-10v zigbee dimmer and it works great! Would it be possible to add an offset for the off temperature? For example: I set the desired temp to 23 degrees. When my HVAC starts it cools down my temp sensors so quickly that it turns off after a very short time. And then starts again and so on. It would be great if it could turn off at maybe 22.5 and then start again at 23. Like a hysteresis.

I tried adding a variable in the blueprint (called ā€œtemp_hysā€, negative value) which made it turn off at room_set_temp_val + temp_hys but it would also start at the same value again. My skills at this are very limited :smiley:

I tried the below blueprint since it both has an off temp value and sets the speed seamlessly between set values (with would be great since my HVAC fan is 0-100%) but it doesnā€™t seem to work at all.

https://community.home-assistant.io/t/multi-speed-fan-control-based-on-temperature/552322

Would you be so kind as to add a feature request?
I am currently out of town and donā€™t want to loose this idea, Iā€™ll look at it in a couple of days.

Here is the link

UPDATEDā€¦
2023-08-07: Updates for Home Assistant 2023.8

Selector syntax change

Condition Selector addition (where applicable)

MQTT Discovery name changes (where applicable)

Clean-up code formatting

Just wanted to post this, to help anyone who kinda struggles with the code like I do. I had to add some logic to have the fan get a ā€œfan turn onā€ and ā€œfan turn offā€ before it set the speed. And that is another change I made too, I changed the fan speed from percentages to fan mode (off, low, medium, and high). All the code is thanks to ChatGPT.
code:

- alias: Set the fan speed based on the sensor temperature
  service: >-
        {% if room_temp_now_val < (room_set_temp_val + temp_off_offset_val) %}
          fan.turn_off
        {% else %}
          fan.turn_on
        {% endif %}
  target:
    entity_id: !input fan
- alias: Set the fan speed
  service: fan.set_preset_mode
  target:
    entity_id: !input fan
  data:
    preset_mode: >-
      {% if room_temp_now_val < (room_set_temp_val + temp_off_offset_val) %}
      {# Room is cooler than set temp so turn fan OFF. #}
        off

      {% elif room_temp_now_val < (room_set_temp_val + temp_gap_1_to_2_val) %}
      {# Room is at the temp where the fan should be at LOW speed. #}
        low

      {% elif room_temp_now_val < (room_set_temp_val + temp_gap_1_to_2_val + temp_gap_2_to_3_val) %} 
      {# Room is at the temp where the fan should be at MEDIUM speed. #}
        medium

      {% else %} 
      {# Room is warm enough to be on HIGH speed, #}
        high

      {% endif %}

Just replaced the very end of the original code.
@Sir_Goodenough Thank you for an awesome blueprint

1 Like

Not to excited about the AI part, but if it works it works.
If you wanted to do a PR in my repo to add this version to the list I would support that. You would get credit and I would support it ofcourse.
The accompanying markdown file is kept the same as the top file here, so that would be edited as well to talk about the 3rd version.

NEW VERSION

:bookmark_tabs: Changelog

  • 2024-06-04: Blueprint Input Sections for enhanced Descriptions.