My Fan Speed - Temperature Automation

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 %}
1 Like

The issue here is the speed won’t change as the temps change… to solve that I have 3 triggers with the different temp thresholds…

That is a nice way to implement that function, thanks. I’m not sure I want that functionality yet. I can see my wife or a guest constantly fighting with home assistant throughout the night if my idea of ideal settings don’t match their own. :slight_smile:

“Why does that fan keep turning on?” :laughing:

I find that as the house cools down into the night that high is too high, but off is not enough. So having it ramp back as the temps go down to a lower speed helps the comfort level.