Help needed: Hunter SIMPLEconnect fan on with HVAC fan

I am trying to create an automation to turn on a ceiling fan whenever the HVAC (nest) turns on and set the direction of the fan to match the mode of the HVAC. In other words, when HVAC is in cool mode, set the fan rotation to forward and turn the fan on. When HVAC is heat mode, set the rotation to reverse and turn the fan on. But I cannot get this working…can someone shed some light on this?

The complete automation is here:

- id: '1632679342958'
  alias: Fan on with HVAC
  description: Run fan (if not running already) when HVAC comes on...and in the proper
  - platform: state
    entity_id: binary_sensor.hallway_thermostat_fan
    to: 'on'
  - condition: device
    device_id: d357b590254c124fd2f67105b6e248a4
    domain: fan
    entity_id: fan.simpleconnect_fan_b19217
    type: is_off
  - service: fan.set_direction
    data_template: >
      {% if is_state("climate.hallway", "cool") -%}
      direction: forward
      {%- else %}
      direction: reverse
      {%- endif %}
      entity_id: fan.simpleconnect_fan_b19217
  - device_id: d357b590254c124fd2f67105b6e248a4
    domain: fan
    entity_id: fan.simpleconnect_fan_b19217
    type: turn_on
  mode: single

If I hardcode the data part of the fan.set_direction, the automation works fine.

Anyone have any thoughts?

Well, this is sort of anti-climatic, but I just used the Visual Editor in HA and used a Choose action to make this work. Sorry for the noise.

Cool idea for an automation. Just curious - Did you use the HomeKit Controller integration, or were you able to directly add the fan to HA?

Also curious about this too @meisner as I’m looking at buying some!

I have had a couple of them for several years. The fans are work well. They are quiet and move a lot of air. Although they both periodically decide they no longer want to be connected to wifi. I have to cut the power at the breaker, and when the come back up they are fine again.

The native Hunter app looks and works like it was created by a 4 year old. It is embarrassing. But the HomeKit/HomeKit Controller integration is pretty good.