Imagine a hallway light that turns on when you arrive after dark. The first version sounds simple, but ordinary life adds questions. Should it run during the day? What if someone has already set the light? What happens when the motion sensor stops reporting?
Write the intended behavior in plain language before opening the editor. Include the exceptions that matter to the people who use the room.
Separate the event from the decision
Home Assistant automations combine triggers, conditions, and actions. A trigger starts the evaluation; conditions decide whether the actions should proceed. In this example, detected motion could be the trigger, a darkness check a condition, and turning on the hallway light the action.
Keep those parts understandable. A small automation is easier to adjust when you can point to the exact decision behind its behavior.
Keep a manual option
Make it clear how a person can change the lighting without fighting the routine. Consider guests and anyone who will not open an app to find out what happened. Observe the routine for a few evenings before expanding it to other rooms.
Use the official automation documentation to translate your plan into the current editor. This example describes the design; the exact controls depend on your devices.