My first attempt at this was pretty clunky and used 3 separate automations for the three fan speeds. I was pretty happy to get this worked out.
- id: master_fan_sleep
alias: 'Master Fan Sleep'
trigger:
# Time For Sleep Scene is called before going to bed every night
- platform: event
event_type: call_service
event_data:
service_data:
entity_id: [scene.time_for_sleep]
domain: scene
service: turn_on
# Input Boolean Used for Initial Testing
- platform: state
entity_id: input_boolean.test1
from: 'off'
to: 'on'
# Fan turned on if master bedroom temperature sensor (Ecobee Remote Sensor) is above 71 degrees
condition:
- condition: template
value_template: '{{ states.sensor.master_bedroom_temperature.state | float > 71.0 }}'
action:
# Fan speed depends on temperature
service: fan.set_speed
entity_id: fan.master_fan_level
data_template:
speed: >
{% if states.sensor.master_bedroom_temperature.state | float > 73.0 %}
high
{% elif states.sensor.master_bedroom_temperature.state | float > 72.0 %}
medium
{% else %}
low
{% endif %}