Build automation to cycle fan on thermostat if the system has been idle x time - A little help please

So I’m trying to make an automation that will turn the fan control to ‘on low’ if the operating_state has been idle for more than 55 min. I have used the zwave thermostat example to build sensors based on the thermostat’s status.

  • I’ve created a working sensor that has the ac_status of idle, wait, cool, or heat
  • I’ve created a working sensor that has the fan status as ‘on low’ or ‘auto low’

I added the condition that the fan status has to have been ‘auto low’ for the last 55 min. In my thinking since that will change as soon as I set the status to ‘on low’ and start a new 55 minute wait. I realized that I do not understand how for works, by my thinking whenever heat/cool has been idle for 55min, and I haven’t forced the fan or for 55min, the automation should trigger…

I have manually triggered the automation and it works. I can look at the sensors and see the minutes since the state change. I have confirmed that even when the heat or cool kicks on it does not change the fan status (It remains ‘auto low’).

I’m sorry if the YAML below is all screwed up. I tried to use the </>, Then tried to fix it manually, but think I did it wrong… Will get better. :slight_smile:

alias: Cycle Downstairs Fan
trigger:

  • entity_id: sensor.downstairs_ac_status
    for: 00:55:00
    platform: state
    to: idle
    condition:
  • condition: state
    entity_id: sensor.downstairs_fan_status
    for: 00:55:00
    state: auto
    action:
  • data:
    entity_id: climate.trane_model_tzemt400ab32maa_cooling_1
    fan_mode: On Low
    service: climate.set_fan_mode
  • delay: 00:03:00
  • data:
    entity_id: climate.trane_model_tzemt400ab32maa_cooling_1
    fan_mode: Auto Low
    service: climate.set_fan_mode

Me too because if I can’t make sense of it, I can’t help.

… and I can’t make sense of it.

says here

you should use quotes around from or to

Thanks for the feedback. I think this is correct… Let me know if there is still an impediment to the code being readable. Your help is greatly appreciated.

- id: '1551621444400'
  alias: Cycle Upstairs Fan
  trigger:
  - entity_id: sensor.upstairs_ac_status
    for: 00:05:00
    platform: state
    to: 'idle'
  condition:
  - condition: state
    entity_id: sensor.upstairs_fan_status
    for: 00:05:00
    state: 'auto'
  action:
  - data:
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1
      fan_mode: On Low
    service: climate.set_fan_mode
  - delay: 00:03:00
  - data:
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1
      fan_mode: Auto Low
    service: climate.set_fan_mode

Thanks for the feedback. I’ve tried it both ways and it doesn’t seem to make a difference. It also seems that when I put ticks around it the automation editor takes them off again.

Here’s how I interpret your automation:

Trigger when:

  • upstairs_ac has been in idle state for >= 5 minutes

but only if:

  • upstairs_fan has been in auto state for >= 5 minutes

then:

  • set cooling_1’s fan to On Low
  • wait 3 minutes
  • set cooling_1’s fan to Auto Low

Is that how you expect the automation to function?

My only concern, and it may be unfounded, is the condition section. Like the trigger it use for: to require the state to remain unchanged for a period of time. I’m not exactly sure how Home Assistant behaves when both the trigger and the condition use for:.

That is exactly what I’m trying to do (the original intent was to make it cycle every hour, but I cut it to 5 min for testing). Essentially, I’m making an automation to come on periodically and cycle the fan. I’m only using the condition because, per my understanding I cannot create a logical AND function in the trigger. I’m trying to build a trigger where it will turn on the fan for three minutes anytime it has been 5 minutes since the upstars AC has been turned and 5 minutes since I last turned the fan on. I’m trying to use the automation function, but I’m not sure if it can do what I want to do.

Are you certain this automation will cycle every X minutes?

The trigger section, as written below, means when upstairs_ac_status changes from some other state to idle and stays that way for 5 minutes, then the automation is triggered and continues to evaluate the condition section. The key point is that a state-change must occur.

  - entity_id: sensor.upstairs_ac_status
    for: 00:05:00
    platform: state
    to: 'idle'  # <--- State-change to 'idle'

Does the action section affect the state of upstairs_ac_status? I see it affects the state of fan_mode but is that sufficient to also change the state of upstairs_ac_status to something other than idle?

Thanks for the help. However, I realized that I was wasting time trying to evaluate the trigger and condition. So I went and made an additional value for the sensor.upstairs_ac_status that had a value for ‘fan’. Now, instead of trying to use two sensors (operating_state and fan_mode), I merged the operating_state and fan_mode into one sensor.

  - platform: template
    sensors:
      upstairs_ac_status:
        friendly_name: "Upstairs AC"
        value_template: >-
          {% if (is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'operation_mode', 'off') and is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'fan_mode', 'Auto Low')) %}
            off
          {% elif (is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'operating_state', 'Idle')  and is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'fan_mode', 'Auto Low')) %}
            idle
          {% elif is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'operating_state', 'Cooling') %}
            cool
          {% elif is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'operating_state', 'Pending Cool') %}
            wait
          {% elif is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'operating_state', 'Heating') %}
            heat
          {% elif is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'operating_state', 'Pending Heat') %}
            wait
          {%- elif is_state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'fan_mode', 'On Low') %}
            fan
          {% else %}
            unknown
          {% endif %}

And set the automation to trigger and cycle the fan for 3 minutes if the operating_state has been idle for the last hour. Since the new combined sensor will change to status ‘fan’ while the fan is on, when I turn it back off after the 3 minute delay, it will reset the ‘to: idle’ clock and start over again:

- id: '1551621400000'
  alias: Cycle Upstairs Fan
  trigger:
  - entity_id: sensor.upstairs_ac_status
    for: 01:00:00
    platform: state
    to: 'idle'
  condition: []
  action:
  - data:
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1
      fan_mode: On Low
    service: climate.set_fan_mode
  - delay: 00:03:00
  - data:
      entity_id: climate.trane_model_tzemt400ab32maa_cooling_1
      fan_mode: Auto Low
    service: climate.set_fan_mode

To improve clarity, consider using variables:

  - platform: template
    sensors:
      upstairs_ac_status:
        friendly_name: "Upstairs AC"
        value_template: >-
          {% set opstate = state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'operating_state') %}
          {% set fanmode = state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'fan_mode') %}
          {% set opmode = state_attr('climate.trane_model_tzemt400ab32maa_cooling_1', 'operation_mode') %}
          {% if (opmode == 'off') and (fanmode == 'Auto Low') %}
            off
          {% elif (opstate == 'Idle') and (fanmode == 'Auto Low') %}
            idle
          {% elif opstate == 'Cooling' %}
            cool
          {% elif opstate == 'Pending Cool' %}
            wait
          {% elif opstate == 'Heating' %}
            heat
          {% elif opstate == 'Pending Heat' %}
            wait
          {%- elif fanmode == 'On Low' %}
            fan
          {% else %}
            unknown
          {% endif %}