Automation problem - please help

Hello,

I hope someone can point out my mistake here.
I have created an automation that checks every hour if devices have been accidentally left on.
Part of the automation checks the following:

  • No movement has been detected in the room for at least three hours
    AND
  • Has the air conditioner been on for at least 3 hours (since there is no ON mode, I set the check to NOT OFF)

If both apply, the air conditioning should be switched off.

In the test, there was no movement for over 3 hours. The air conditioning has not been running for 3 hours. However, it keeps getting turned off.

Here is the code of the relevant part of the automation:

if:
  - condition: and
    conditions:
      - condition: state
        entity_id: binary_sensor.workstatt_bewegung
        state: 'off'
        for:
          hours: 2
          minutes: 0
          seconds: 0
        alias: Workstatt keine Bewegung
      - condition: not
        conditions:
          - condition: state
            entity_id: climate.daikinap06219
            state: 'off'
            for:
              hours: 3
              minutes: 0
              seconds: 0
            attribute: hvac_action
        alias: Prüfe - Klimaanlage ist NICHT aus
    alias: Prüfe UND - Workstatt keine Bewegung und Klima nicht aus
then:
  - device_id: a2afbdadffc9ab87e3a5ac3a9d0e81c5
    domain: climate
    entity_id: climate.daikinap06219
    type: set_hvac_mode
    hvac_mode: 'off'
    alias: Klimaanlage ausschalten
alias: Klimaanlage Workstatt aus bei Abwesenheit
enabled: true

The follow up says:

Executed: 19. Januar 2023 um 09:00:00
Result:

choice: then

if
Executed: 19. Januar 2023 um 09:00:00
Result:

result: true

if/condition/0
Executed: 19. Januar 2023 um 09:00:00
Result:

result: true

if/condition/0/conditions/0
Executed: 19. Januar 2023 um 09:00:00
Result:

result: true

if/condition/0/conditions/0/entity_id/0
Executed: 19. Januar 2023 um 09:00:00
Result:

result: true
state: 'off'
duration: '2023-01-19T06:00:00.142520+00:00'

if/condition/0/conditions/1
Executed: 19. Januar 2023 um 09:00:00
Result:

result: true

if/condition/0/conditions/1/conditions/0
Executed: 19. Januar 2023 um 09:00:00
Result:

result: false

if/condition/0/conditions/1/conditions/0/entity_id/0
Executed: 19. Januar 2023 um 09:00:00
Result:

result: false
state: heating
wanted_state: 'off'

Here are the air conditioning options:

hvac_modes:
  - fan_only
  - dry
  - cool
  - heat
  - heat_cool
  - 'off'
min_temp: 7
max_temp: 35
target_temp_step: 1
fan_modes:
  - Auto
  - Silence
  - '1'
  - '2'
  - '3'
  - '4'
  - '5'
preset_modes:
  - none
  - away
  - eco
  - boost
swing_modes:
  - 'Off'
  - Vertical
  - Horizontal
  - 3D
current_temperature: 9
temperature: 12
fan_mode: '4'
hvac_action: heating
preset_mode: none
swing_mode: Vertical
friendly_name: Workstatt Klimaanlage
supported_features: 57

Can someone help me where the error is?

Greetings Werner