Introduction
As we enter the holiday season and daylight hours become shorter, many of us are thinking about how to automate our festive lighting displays. Whether you're setting up Halloween decorations or preparing for Christmas, having your lights turn on automatically at the right times can make the season more magical (and save you some daily hassle!).In this guide, I'll show you how to create a single, elegant automation in Home Assistant that will:
- Turn on your lights at sunset
- Turn them on again before sunrise (perfect for those dark winter mornings!)
- Automatically turn them off after two hours to save energy
We'll be using the Theengs Plug, an excellent smart plug that works great with Home Assistant, and we'll set everything up using the Home Assistant UI - no YAML required!
Prerequisites
Before we begin, make sure you have:- A Theengs Plug successfully integrated with Home Assistant
- Your plug should be visible in Settings -> Devices & Services -> Devices
- Basic familiarity with Home Assistant's interface
Creating the Automation
Let's create our automation step by step using Home Assistant's automation UI:1. Go to Settings -> Automations & Scenes
2. Click the "+ Add Automation" button
3. Choose "Create new automation"
4. Add a name: "Holiday Lights Automation"
Adding Triggers
We'll add two triggers to control when the lights turn on:1. First Trigger (Sunset):
- Click "Add Trigger"
- Select "Sun" as the trigger type
- Event: Select "Sunset"
- Offset: Leave at 0
2. Second Trigger (Pre-sunrise):
- Click "Add Trigger" again
- Select "Sun" as the trigger type
- Event: Select "Sunrise"
- Offset: Set to "-1:00:00" (one hour before sunrise)
Adding Actions
Now let's set up the actions:1. Initial Action (Turn On):
- Click "Add Action"
- Select "Device"
- Choose your Theengs Plug
- Select "Turn on <plug ID> actuatorONOFF"
2. Delay Action:
- Click "Add Action"
- Select "Delay"
- Set to 2 hours
3. Final Action (Turn Off):
- Click "Add Action"
- Select "Device"
- Choose your Theengs Plug
- Select "Turn off <plug ID> actuatorONOFF"
Testing Your Automation
Once your automation is set up, you can test it immediately:1. Save your automation
2. Click the "Run Actions" button (three dots menu)
3. Watch as your lights:
- Turn on immediately
- Stay on for two hours
- Turn off automatically
How It Should Look
In the automation editor, your setup should look something like this:Alternatively, you can also edit it in YAML:
alias: Turn on holiday lights
description: ""
triggers:
- event: sunset
offset: 0
trigger: sun
- trigger: sun
event: sunrise
offset: "-2:00:00"
conditions: []
actions:
- type: turn_on
device_id: 9e059a90dc8bddd8ba47d7aff9b69
entity_id: faffb14f96c1adb7d79e130ae39a3
domain: switch
- delay:
hours: 2
minutes: 0
seconds: 0
milliseconds: 0
- type: turn_off
device_id: 9e059a90dc8bddd94a47d7aff9b69
entity_id: faffb14f96c1adb9679e130ae39a3
domain: switch
mode: single
You can verify everything is working correctly by checking the automation's Trace Timeline tab, which will show you when it last ran and what actions were performed.
Conclusion
With this automation in place, your holiday lights will now:- Turn on automatically at sunset
- Turn on again one hour before sunrise
- Turn off automatically after two hours in both cases
- Save energy by not running continuously
The best part? You can easily adjust the timing by modifying the triggers' offsets or the delay duration. And since we used the Home Assistant UI to set this up, making changes is just a few clicks away.
This setup is perfect for holiday decorations, but you can use the same principle for other lighting needs throughout the year. The Theengs Plug makes it all possible with reliable control and easy integration with Home Assistant.
Happy automating!