An automation has triggers (when), optional conditions (only if) and actions (do this). You can build them in the visual editor or write YAML.
- alias: Hallway light at sunset triggers: - trigger: sun event: sunset conditions: - condition: state entity_id: person.kamran state: home actions: - action: light.turn_on target: entity_id: light.hallway data: brightness_pct: 60