Automation doen't work, need some help

hi, tried voth variations of this automation, and it doesn’t work, any ideas ?

alias: aab kitchen
description: ''
trigger:
  - platform: device
    type: turned_on
    device_id: 041960b0924702197c0a049508eb7b24
    entity_id: switch.kitchen_ceiling
    domain: switch
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition: []
action:
  - type: turn_off
    device_id: 041960b0924702197c0a049508eb7b24
    entity_id: switch.kitchen_ceiling
    domain: switch
mode: single

and this

alias: aab kitchen
description: ''
trigger:
  - platform: state
    entity_id: switch.kitchen_ceiling
    to: 'on'
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition: []
action:
  - data:
      entity_id: 
      - switch.kitchen_ceiling
    service: switch.turn_off
mode: single

Try this:

alias: aab kitchen
description: ''
trigger:
  - platform: state
    entity_id: switch.kitchen_ceiling
    to: 'on'
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition: []
action:
  - service: switch.turn_off
    target:
      entity_id: switch.kitchen_ceiling
mode: single

This should turn off the fan after it has been on for five minutes.

1 Like

Look at the indentation, this should work:

alias: aab kitchen
description: ''
trigger:
- platform: state
  entity_id: switch.kitchen_ceiling
  to: 'on'
  for:
    hours: 0
    minutes: 5
    seconds: 0
condition: []
action:
- service: switch.turn_off
  target:
    entity_id: switch.kitchen_ceiling
mode: single

You can also use the GUI to build this automation, so no mistakes are made.