Simple Automation not functioning

Could anyone help me figure out why this automation isn’t working?

Any help or pointers is appreciated. HA is new to me


alias: Powder Bath Fan Timer
description: ''
trigger:
  - platform: device
    type: turned_on
    device_id: f0d21edd934d1514a8cce0a809518f61
    entity_id: light.powder_bath_fan
    domain: light
    id: PB Fan Timer
    for:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
condition:
  - condition: device
    type: is_on
    device_id: f0d21edd934d1514a8cce0a809518f61
    entity_id: light.powder_bath_fan
    domain: light
    for:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
action:
  - type: turn_off
    device_id: f0d21edd934d1514a8cce0a809518f61
    entity_id: light.powder_bath_fan
    domain: light
mode: single

I think the trigger is inaccurate-
The trigger should be “Light is on for 10 minutes”

Can you try the following?

alias: New Automation
description: ''
mode: single
trigger:
  - platform: state
    entity_id: light.powder_bath_fan
    for: '00:10:00'
    to: 'on'
condition:
  - condition: state
    entity_id: light.powder_bath_fan
    state: 'on'
action:
  - service: light.turn_off
    target:
      entity_id: light.powder_bath_fan

Edit: added condition to prevent the automation from running unless the light is on.

2 Likes

The automation will check the conditions right away and just stops when they are not met. It will not wait. Aka, if you trigger on a light going on but have a condition that the light should be on for 10 minutes that can never be true the moment the condition is check the moment the light turned on. Aka, just remove the condition and switch the time offset to the trigger.

For now, no condition is needed because you only have the same condition as a trigger. You may want to add a condition if you add other triggers but it depends on what you would like the achieve.

alias: New Automation
description: ''
mode: single
trigger:
  - platform: state
    entity_id: light.powder_bath_fan
    for: '00:10:00'
    to: 'on'
condition: []
action:
  - service: light.turn_off
    target:
      entity_id: light.powder_bath_fan
2 Likes

That was it!

That makes sense thank you!

Thank you for that explanation!