Automatically turn off light in 5 minutes

Hey there, I’m really new to Home Assistant and i cant really get my code to work. My code is suppost to turn off my light switch 5 minutes after turning on. I’d have to do it this way because the lights are controlled by multiple sensors.

Bildschirmfoto 2022-03-29 um 10.14.22

Any help would be appreciated!

Have a look here

what is the sensor? if you are using the motion sensor you will need to be carefull on how to set it off.

I have my setup using aqara motion sensor which need 1:30 secs to refresh so again there are many considerations

Create a sensor group and use the group as a trigger

Notwithstanding the comments above about how to do this better, the error you get is down to inconsistent spacing in your yaml (from line 2 onward)

Can I ask why you are trying to edit the YAML directly?

Use the UI to create scripts/automations etc. and you’ll avoid lots of these forms of issues - it looks like you have an issue with the whitespace. So I’m assuming it’s a rogue and/or missing space or tab on one of the lines?

there is nothing wrong with trying to learn the yaml coding for the automation. You just need to make sure you understand the syntax, including indentation/etc.

Also to make it easier to help you you need to post the properly formatted code in text form. that way way we don’t need to re-type everything by hand to correct the mistakes. Instead we can just copy-edit the existing code.

If you will do that I’ll show you where you went wrong.

It also looks like you are trying to create an automation, but try to execute it as a script. I also think there is an issue.
I would suggest to create the automation using the UI, and then look at the YAML editor for that. At least it will show you how the YAML code should look. But…editing and creating this automation is easier just via the UI and will also probably give you less issues.