Or you can use a Blueprint specifically designed to perform the task. You just fill in the Blueprint's fields and it generates the automation.
Here are two examples (for a light controlled by motion and other things) but there are others in the Blueprints Exchange section.