I used to think that automating my curtains and blinds was a bit of a gimmick, but now that I’ve automated my curtains and blinds to close at sunset I’ve totally changed my mind.
Home Assistant includes a Sun integration that allows you to trigger automations in relation to the sunrise and sunset time, meaning that you don’t need to update them as the season’s change. There’s just something magical about the blinds automatically closing and the lights fading in as the sun goes down outside.
In this example I will show you an automation that lowers a blind 10 minutes before sunset, but it can be easily adapted to open a curtain at sunrise or any other time of the day.
To create this automation you will need:
- A working Home Assistant installation
- Some automated curtain or blind controllers set up in Home Assistant as Cover entities
This automation is triggered 10 minutes before sunset each day using the Sun trigger. I make use of the Offset parameter as well, which you can enter in the formation HH:MM:SS (HH = Two digit hour, MM = Two digit minutes, SS = two digit seconds)
I use an offset of “-00:10:00” which is minus ten minutes, or ten minutes BEFORE sunset. If you did “+00:10:00” then this automation would trigger 10 minutes after sunset, or “-01:00:00” would trigger 1 hour before sunset.
Changing the event to Sunrise would trigger the automation 10 minutes before the sun rises.
If you wanted to trigger this automation at the same time each day, regardless of what the sun is doing, you can use the Time trigger type.
Here is the sunset automation trigger in YAML format:
platform: sun event: sunset offset: '-00:10:00'
This automation uses a Service call action to call the cover.close service. A cover in Home Assistant is any curtain, blind, awning or garage door device. This will then close the blind, curtain or whatever you have chosen as the target entity.
I’ve added a few extra steps to my automation to make it also turn on the lights if we are home.
The next part of the action is a condition action. This condition will check if the residents are home or away, and if they are home continue on with the automation actions to turn on the light.
And that’s all there is to it! You can easily adapt this automation to open or close different curtains and blinds at different times of the day. You can also add more actions together so that lots of different things happen at sunrise or sunset.
Full automation in YAML
alias: 'Blind: Close bedroom blind at sunset and turn on bed head light' description: '' trigger: - platform: sun event: sunset offset: '-00:10:00' condition:  action: - service: cover.close_cover target: entity_id: cover.bedroom_blind_motor - condition: state entity_id: group.residents state: home - service: light.turn_on target: device_id: 0de04fa9b5cbac5626d4a8241d73ee22 data: transition: 10 color_temp: 375 brightness_pct: 80 mode: single