To write an automation to switch off the light every day at 10 PM in YAML, you can use the following syntax:
- id: 'turn_off_light'
alias: Turn off light
description: 'Turn off light every day at 10 PM'
trigger:
- platform: time
at: '22:00:00'
action:
- service: light.turn_off
entity_id: light.bedroom
This automation will turn off the light with the entity ID light.bedroom
every day at 10 PM.
Here’s an explanation of each part of the automation:
id
: A unique ID for the automation.alias
: A friendly name for the automation.description
: A description of the automation.trigger
: The conditions that will cause the automation to be triggered. In this case, the trigger is the time being 10 PM.action
: The action that will be performed when the automation is triggered. In this case, the action is to turn off the light with the entity IDlight.bedroom
.