This blueprint is based on the work of Sam04.
I needed to add the speed level (percentage) for a mid temperature and a max temperature.
I have clearly declared the use of the fan service instead of the homeassistant service to turn/turn off on or control the speed.
Besides the Inside temperature threshold at level 1 of your fan (33%), there are a Mid-Temperature for the level 2 of your fan (66%) and a Max-Temperature for the level 3 of your fan (100%)
This was done for my personnal use and I might enhanced it.
blueprint:
name: Automatic Fan 3 Speeds Set Control based on Temperature
description:
"## Fan ON/OFF and set speed (3-speeds) Automation based on temperature,\
\ outside temperature.\n\nFan turns on if the following conditions are met:\n\
\ temperature inside greater than your set threshold value\n temperature outside\
\ is lower than your set maximum value (to prevent turning the fan on in winter)\n\
\nAnd the Fan turns off if the following conditions are met:\n temperature inside is\
\ lower than your threshold value minus the hystersis value\n What the automation\
\ **NOT** observes:\n manual fan control. Adapt the given values too your needs.\n\
\ If you manually turn the fan on and the inside temperature is below the threshold\
\ your fan will turn off soon.\n\nWhat you need:\n a fan entity. if you control\
\ your fan via a switch entity (via smart plug for example) you can create a template\
\ fan entity.\n sensor entities for inside and outside temperature. (if you want\
\ to use the weather domain than create a template sensor from the temp attribute)\n\
\ Inspired by b-0s based on the work of Sam04"
domain: automation
input:
fan:
name: Fan
description: Fan to control
selector:
target:
entity:
domain: fan
temp_inside:
name: Temperature Inside
description: Temperature to track inside your house
selector:
entity:
domain: sensor
device_class: temperature
multiple: false
temp_outside:
name: Temperature Outside
description:
Temperature outside to prevent to turn on the fan in winter for
example. Set to same Temperature Inside entity if you don't want to use it
selector:
entity:
domain: sensor
device_class: temperature
multiple: false
temp_outside_min:
name: Outside temperature
description:
outside temperature that must be reached to turn on the fan (to
prevent the fan to be turned on in winter). Set to 0 to disable
selector:
number:
min: 0.0
max: 300.0
step: 0.5
unit_of_measurement: °C | °F
mode: slider
temp_threshold_inside:
name: Inside temperature threshold
description:
inside threshold temperature that must be reached to turn on the
fan
selector:
number:
min: 0.0
max: 300.0
step: 0.5
unit_of_measurement: °C | °F
mode: slider
hysteresis:
name: Hysteresis
description:
The difference the observed value must be lower than the threshold
value before the fan is turned off
selector:
number:
min: 0.5
max: 100.0
step: 0.5
unit_of_measurement: °C | °F
mode: slider
mid_temp:
name: Mid-Temperature
description:
The temperature that must be reached to turn the level 2 speed
of the fan
selector:
number:
min: 0.0
max: 100.0
step: 0.5
unit_of_measurement: °C | °F
mode: slider
max_temp:
name: Max-Temperature
description:
The temperature that must be reached to turn the level 3 speed
of the fan
selector:
number:
min: 0.0
max: 100.0
step: 0.5
unit_of_measurement: °C | °F
mode: slider
source_url: https://community.home-assistant.io/t/automatic-fan-3-speeds-set-control-based-on-temperature/421719
variables:
fan: !input "fan"
temp_inside_entity: !input "temp_inside"
temp_inside: "{{ states[temp_inside_entity].state }}"
temp_outside_entity: !input "temp_outside"
temp_outside: "{{ states[temp_outside_entity].state }}"
temp_threshold_inside: !input "temp_threshold_inside"
temp_outside_min: !input "temp_outside_min"
hysteresis: !input "hysteresis"
mid_temp: !input "mid_temp"
max_temp: !input "max_temp"
max_exceeded: silent
trigger:
- platform: state
entity_id: !input "temp_inside"
- platform: state
entity_id: !input "temp_outside"
condition: []
action:
- choose:
- conditions:
- alias: temp inside greater than temp threshold value
condition: template
value_template: "{{ temp_inside|float > temp_threshold_inside|float }}"
- alias: temp outside greater than outside min temp
condition: template
value_template: "{{ temp_outside|float > temp_outside_min|float }}"
sequence:
- choose:
- conditions:
- "{{ temp_inside|float >= 33 }}"
sequence:
- choose:
- conditions:
- "{{ temp_inside|float >= max_temp|float }}"
sequence:
- service: fan.set_percentage
data:
percentage: 100
target: !input "fan"
- conditions:
- "{{ mid_temp <= temp_inside|float > max_temp|float }}"
sequence:
- service: fan.set_percentage
data:
percentage: 66.66
target: !input "fan"
- conditions:
- "{{ temp_threshold_inside|float <= temp_inside|float > mid_temp|float }}"
sequence:
- service: fan.set_percentage
data:
percentage: 33.33
target: !input "fan"
default: []
- conditions:
- '{{ states[fan].state == "off" }}'
sequence:
- service: homeassistant.turn_on
target: !input "fan"
default: []
- conditions:
- condition: or
conditions:
- condition: template
value_template: "{{ (temp_threshold_inside - hysteresis)|float > temp_inside|float }}"
sequence:
- service: homeassistant.turn_off
target: !input "fan"
default: []
mode: single