Attic fan automation

Hi, this automation is not working right and I still trying to understand what is wrong, Hope you can help?
The goal is to turn On Attic fan on two conditions:

  1. If temperature above 32C for 1 hour
  2. and then after 3 hours after sunrise.

Turn off the attic fan after Sunset.

Thank you.

alias: Attic Fan
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.accuw_temperature
    for:
      hours: 1
      minutes: 0
      seconds: 0
    above: 32
conditions:
  - condition: sun
    after: sunrise
actions:
  - delay:
      hours: 3
      minutes: 0
      seconds: 0
      milliseconds: 0
  - type: turn_on
    device_id: 055ff299bcb8c1c6bd1df5d8518e13f1
    entity_id: 46016ef65d1dcde284aefde88efb4642
    domain: switch
  - wait_for_trigger:
      - trigger: sun
        event: sunset
        offset: 0
  - type: turn_off
    device_id: 055ff299bcb8c1c6bd1df5d8518e13f1
    entity_id: 46016ef65d1dcde284aefde88efb4642
    domain: switch
mode: single

Hello strobes,

As you wrote this, both have to be true to allow actions. Not one or the other.
It will trigger, then check if it’s after sunrise, wait 3 hours, then turn on the switch.

I suggest getting rid of the long delay, as if HA reboots or something happens, the automation will die and nothing will run.

Yes, Thank you, I was planning to start using Timers.
I’d like to re-define logic, hope you can point me to correct implementation.
Two conditions required to turn On the fan:
(sunrise+delay) AND temperature outside reaching 32C.

Meaning that the fan will turn On any time after (sunrise+delay) if temperature will reach 32C. And turn Off if the temperature may get below 32C or turn Off after sunset.
Thank you.