-
-
Save bonelifer/e8a4bed44919c9ae54c1084bc2f3b997 to your computer and use it in GitHub Desktop.
HA Blueprint: Auto Fan Temperature Control for 3-Speed Fan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Auto Fan Temperature Control for 3-Speed Fan | |
author: WillCodeForCats | |
description: | |
"This sets the fan speed for a 3-speed fan based on aroom temperature | |
sensor entity. Any fan entity with 3 speeds will work with this blueprint. | |
There are action selectors for both the cycle loop and the shutdown loop for adding | |
control of heating / cooling sources, or anything else you want Home Assistant | |
to do. | |
Based on [SirGoodenough/HA_Blueprints](https://github.com/SirGoodenough/HA_Blueprints/) | |
with time-based stuff removed." | |
source_url: https://gist.github.com/WillCodeForCats/5c7dc1bb2da594d40e7791372e8dfcb6 | |
domain: automation | |
homeassistant: | |
min_version: 2023.3.0 | |
input: | |
fan: | |
name: Fan Entity | |
description: The Home Assistant Fan entity to control. | |
selector: | |
entity: | |
domain: | |
- fan | |
multiple: false | |
room_temp_now: | |
name: Room Temperature Sensor | |
description: | |
This is a temperature sensor or averaged sensor, within the same | |
room as the fan or within the fan airflow. | |
selector: | |
entity: | |
domain: | |
- sensor | |
multiple: false | |
fan_control: | |
name: Toggle to turn the auto fan function off for when away or seasonally | |
description: | |
"```input_boolean``` - If this is set to off, the Automation will | |
be disabled. | |
This Helper has to be set up in [![Open your Home Assistant instance and show | |
your helper entities.](https://my.home-assistant.io/badges/helpers.svg)](https://my.home-assistant.io/redirect/helpers/) " | |
selector: | |
entity: | |
domain: | |
- input_boolean | |
multiple: false | |
room_set_temp: | |
name: Room Target Temperature | |
description: | |
"```input_number``` - This is the target temperature of the room. | |
Use the same scale as the temperature sensor. | |
This Helper has to be set up in [![Open your Home Assistant instance and show | |
your helper entities.](https://my.home-assistant.io/badges/helpers.svg)](https://my.home-assistant.io/redirect/helpers/) " | |
selector: | |
entity: | |
domain: | |
- input_number | |
multiple: false | |
temp_gap: | |
name: Temp Hysteresis | |
description: "This keeps the fan from speed cycling too often. | |
Set it larger if the fan goes on and off too much. | |
Set it smaller if the fan doesn't change speeds fast enough." | |
default: 1.3 | |
selector: | |
number: | |
min: 0.0 | |
max: 7.0 | |
unit_of_measurement: Degrees | |
mode: slider | |
step: 0.1 | |
temp_gap_1_to_2: | |
name: Temp Gap between Low and Medium | |
description: "This is the temp swing between Low and Medium. | |
If the sensor reads between the base temperature and this number of degrees | |
warmer, the fan is on LOW. | |
Below the base temperature the fan is off." | |
default: 4.5 | |
selector: | |
number: | |
min: 1.0 | |
max: 20.0 | |
unit_of_measurement: Degrees | |
mode: slider | |
step: 0.1 | |
temp_gap_2_to_3: | |
name: Temp Gap between Medium and High | |
description: "This is the temp change between Medium and High. | |
If the sensor reads between the base temperature plus the 1 to 2 temperature | |
and this number of degrees warmer, the fan is on MEDIUM. | |
Any warmer than this and the fan is set to HIGH." | |
default: 2.0 | |
selector: | |
number: | |
min: 1.0 | |
max: 20.0 | |
unit_of_measurement: Degrees | |
mode: slider | |
step: 0.1 | |
loop_action: | |
name: User action for fan enabled condition (loop) | |
description: | |
This can be used to start an A/C unit or other device to turn on. | |
It is executed when the fan turns on or changes speeds. Leave this empty to | |
do nothing extra. | |
default: [] | |
selector: | |
action: {} | |
off_action: | |
name: User action for fan off condition (off_action) | |
description: | |
This is can be used to disable an A/C unit or other device to turn | |
off. It is executed when the fan turns off. Leave this empty to do nothing | |
extra. | |
default: [] | |
selector: | |
action: {} | |
variables: | |
temp_gap_var: !input temp_gap | |
temp_gap_val: "{{ temp_gap_var | float(1.3) }}" | |
temp_gap_1_to_2_var: !input temp_gap_1_to_2 | |
temp_gap_1_to_2_val: "{{ temp_gap_1_to_2_var | float(4.5) }}" | |
temp_gap_2_to_3_var: !input temp_gap_2_to_3 | |
temp_gap_2_to_3_val: "{{ temp_gap_2_to_3_var | float(2.0) }}" | |
room_set_temp_var: !input room_set_temp | |
room_set_temp_val: | |
"{{ expand(room_set_temp_var)[0].state | float(73.1) - temp_gap_val | |
}}" | |
room_temp_now_var: !input room_temp_now | |
room_temp_now_val: | |
"{{ expand(room_temp_now_var)[0].state | float(room_set_temp_val) | |
}}" | |
my_loop_action: !input loop_action | |
my_off_action: !input off_action | |
mode: restart | |
trigger: | |
- platform: state | |
id: go_if_the_control_is_switched_off | |
entity_id: !input fan_control | |
to: "off" | |
- platform: state | |
id: go_on_any_sensor_temp_changes | |
entity_id: !input room_temp_now | |
- platform: state | |
id: go_on_any_set_temp_changes | |
entity_id: !input room_set_temp | |
- platform: state | |
id: go_if_the_control_is_switched_on | |
entity_id: !input fan_control | |
to: "on" | |
action: | |
- choose: | |
- alias: Fan normal turn off sequence | |
conditions: | |
or: | |
- alias: The automation has been disabled | |
condition: trigger | |
id: go_if_the_control_is_switched_off | |
sequence: | |
- alias: Do something when the fan stop condition triggers | |
if: "{{ not my_off_action in ('none', 'null', 'unavailable', '') }}" | |
then: !input off_action | |
- alias: Stop the fan | |
service: fan.turn_off | |
target: | |
entity_id: !input fan | |
- alias: Normal fan run sequence | |
conditions: | |
and: | |
- alias: Make sure the Fan is enabled | |
condition: state | |
entity_id: !input fan_control | |
state: "on" | |
sequence: | |
- alias: Do something on every fan set speed condition trigger | |
if: "{{ not my_loop_action in ('none', 'null', 'unavailable', '') }}" | |
then: !input loop_action | |
- alias: Set the fan speed based on the sensor temperature | |
service: fan.set_percentage | |
target: | |
entity_id: !input fan | |
data: | |
percentage: | |
"{% if room_temp_now_val < room_set_temp_val %} 0 {% elif room_temp_now_val | |
< (room_set_temp_val + temp_gap_1_to_2_val) %} 33 {% elif room_temp_now_val | |
< (room_set_temp_val + temp_gap_1_to_2_val + temp_gap_2_to_3_val) %} 67 | |
{% else %} 100 {% endif %}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment