Motion sensor automation with additional features

Remove everything referring to the light.

You mean fan? I´ve deleted everything from fan. Is it right?

If there’s no light switch then the automation should not refer to a light (although I don’t understand why you want this). That’s why I suggested you remove all references to the light in the automation.

Perhaps I have not expressed myself well. I would like to use the automation also in another room where there is only a motion sensor (with light level sensor) and a light. Otherwise, could I just use a virtual switch instead of the “wall switch”?