Strange Timing problems

I have got a tradfri motion sensor.
So far so good. sadly the device stores the motion detected status for minutes.

now my problem, i have setup two automations.
the first one switched on a hue lamp.
the second on waits 3:30minutes and switch off the lamp, when another lamp is not also on.

the 3:30 minutes timer di not work corectly. sometimes it works, sometimes it takes 10 minutes to switch off and sometimes the lamp keeps on.

id: '1601914136527'
  alias: BWMFlur1An
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: 0d910838068711ebbef09d3e2ac0387c
    entity_id: binary_sensor.tradfribwm1_occupancy
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 1
  condition:
  - condition: device
    type: is_off
    device_id: 9df3f4c3068611eb9b9d43a2ba28e81a
    entity_id: light.hue_iris_1
    domain: light
  action:
  - type: turn_on
    device_id: 9df3f4c3068611eb9b9d43a2ba28e81a
    entity_id: light.hue_iris_1
    domain: light
    brightness_pct: 8
    flash: short
  mode: single

and the code for off:

- id: '1601914506571'
  alias: BWMFlur1Aus
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: 0d910838068711ebbef09d3e2ac0387c
    entity_id: binary_sensor.tradfribwm1_occupancy
    domain: binary_sensor
    for:
      hours: 0
      minutes: 3
      seconds: 30
  condition:
  - condition: device
    type: is_on
    device_id: 9df3f4c3068611eb9b9d43a2ba28e81a
    entity_id: light.hue_iris_1
    domain: light
  - condition: and
    conditions:
    - condition: device
      type: is_off
      device_id: f3fbd57c068411eba869091fddec9166
      entity_id: light.livingcolors_1
      domain: light
  action:
  - type: turn_off
    device_id: 9df3f4c3068611eb9b9d43a2ba28e81a
    entity_id: light.hue_iris_1
    domain: light
  mode: single

Your conditions do not look correct:

  condition:
  - condition: device
    type: is_on
    device_id: 9df3f4c3068611eb9b9d43a2ba28e81a
    entity_id: light.hue_iris_1
    domain: light
  - condition: and
    conditions:
    - condition: device
      type: is_off
      device_id: f3fbd57c068411eba869091fddec9166
      entity_id: light.livingcolors_1
      domain: light

Try:

  condition:
  - condition: device
    type: is_on
    device_id: 9df3f4c3068611eb9b9d43a2ba28e81a
    entity_id: light.hue_iris_1
    domain: light
  - condition: device
    type: is_off
    device_id: f3fbd57c068411eba869091fddec9166
    entity_id: light.livingcolors_1
    domain: light

Conditions are AND by default.

Thank you!

I will checkā€¦
Strange thing, this condition was build with the editor not coded