What do you need before you start?
- Lights: either ordinary mains-powered strings (UK 3-pin plug with a fuse fitted) or a smart string such as Twinkly, Philips Hue or Govee.
- A switch Home Assistant can control: a Wi-Fi smart plug (TP-Link Tapo, Shelly and similar) for non-smart lights. Our best smart plug UK roundup covers the options, and best outdoor smart plug UK covers garden displays.
- Home Assistant already running with your location set, because sunset times come from it. If you are still setting up, start with Home Assistant UK setup.
- A person entity (the Home Assistant companion app on your phone) if you want the lights to stay off when you are out.
Going away over the festive period? The same randomised-delay approach powers a Home Assistant holiday mode that simulates someone being home.
Step 1: Check the lights and the socket
Before any automation, check the basics, because an automation will run the lights for hours you might not otherwise have them on. Electrical Safety First says mains-powered Christmas lights must be fitted with a UK 3-pin plug and fuse, that you should not overload sockets, and that it is best not to rely on extension leads or adaptors if you can avoid them.
A smart plug counts as an adaptor, so plug it straight into a wall socket rather than into a multi-way extension. Check the lights for damage first, and look at the rating printed on the smart plug against the combined load of everything you intend to run through it. LED strings draw little, but a tree string plus an inflatable and a projector on one plug is a different sum.
For anything outdoors, Electrical Safety First says the lights must be connected via a 30mA RCD-protected socket, and that if you do not have RCD protection you should use an RCD plug on that socket. A smart plug does not replace that.
Step 2: Choose how Home Assistant will switch them
There are two routes, and the right one depends on the lights you own. A smart plug turns the whole string on or off but cannot change colour. A smart-light integration controls colour, brightness and effects, and usually still needs the lights powered all the time.
| Lights | How Home Assistant controls them | Local or cloud | What you can automate |
|---|---|---|---|
| Ordinary mains string on a Tapo plug | TP-Link integration | Local (Tapo plugs need your TP-Link account details to authenticate) | On and off only |
| Ordinary mains string on a Shelly plug | Shelly integration | Local push, no cloud needed | On and off only |
| Twinkly string | Twinkly integration | Local polling | On/off, brightness, colour, effects you saved in the app |
| Philips Hue lights | Philips Hue integration (via the bridge) | Local push | On/off, brightness, colour, Hue scenes |
| Govee lights | Govee Lights Local integration | Local push | On/off, brightness, colour (per supported model) |
If you are buying new, a smart plug is the cheapest and most reliable way to automate lights you already own, while a smart string suits anyone who wants different colours at different times of day. Our best smart fairy lights UK guide compares the strings themselves.
Step 3: Add the plug or lights to Home Assistant
Go to Settings, then Devices & services. Anything Home Assistant discovers on your network appears as Discovered, and you can add it with one click. If it does not appear, choose Add Integration and search for the brand.
- Twinkly: Home Assistant can auto-discover it. If you add it by IP address, give the string a static IP on your router. Effects only show up in Home Assistant once you have saved them in the Twinkly app, and Music mode is not supported.
- Philips Hue: add the integration and follow the prompts. Hue scenes are imported automatically as scene entities, but you create and edit them only in the Hue app.
- Govee: turn on LAN control for each device in the Govee app first, then add Govee Lights Local. Check your model against the supported list, because some scenes do not work on every model.
- Tapo or Shelly plugs: add the TP-Link or Shelly integration. Tapo devices need your TP-Link email and password to authenticate, even though control stays local.
Rename the entity to something obvious, such as "Tree lights". You will pick it from a list in the next step, and a name like switch.tapo_p100_3 is easy to get wrong.
Step 4: Switch the lights on at sunset and off at bedtime
Create a new automation in Settings, then Automations & scenes. A fixed clock time drifts out of step with the light through the winter, because sunset keeps moving, so trigger the on-switch from the sun and use a clock time only for switching off.
The sun trigger takes an event of sunset or sunrise and an optional offset, in seconds or hh:mm:ss, where a negative value fires before the event. Home Assistant's documentation also notes that twilight length changes through the year, and suggests the Dusk trigger or a sun-elevation threshold between 0° and -6° if you want the lights to match how dark it actually is.
automation:
- alias: "Christmas lights on at dusk"
triggers:
- trigger: sun
event: sunset
offset: "-00:30:00"
conditions:
- condition: state
entity_id: person.you
state: "home"
actions:
- action: switch.turn_on
target:
entity_id: switch.tree_lights
- alias: "Christmas lights off at bedtime"
triggers:
- trigger: time
at: "23:00:00"
actions:
- action: switch.turn_off
target:
entity_id: switch.tree_lights
Swap person.you for your own person entity and switch.tree_lights for your plug. If you use a smart light rather than a plug, use light.turn_on and light.turn_off with the light's entity. For a general grounding in how triggers, conditions and actions fit together, see our Home Assistant automations guide.
Step 5: Add a safety backstop so they never stay on
Electrical Safety First's advice is to switch lights off and unplug them before bed or when you go out, so the automation should enforce that rather than rely on one trigger firing. Add a second off rule that fires when everyone leaves, and treat the bedtime rule as a backstop in case your phone was offline at the time.
- alias: "Christmas lights off when nobody is home"
triggers:
- trigger: state
entity_id: zone.home
to: "0"
actions:
- action: switch.turn_off
target:
entity_id: switch.tree_lights
This uses the Home zone's person count, which drops to zero when everyone has left. If you share the house with someone who does not use Home Assistant, skip this rule or the lights will go off whenever your own phone leaves.
Step 6: Add a manual override to the dashboard
Add the plug or light entity to a dashboard card so anyone in the house can switch it by hand. Automations that fight the people living with them get disabled, so an obvious toggle matters more than it sounds. A Hue scene can also be added as a button if you want a one-tap "party" colour for guests, with the automation resuming at the next sunset.
Can you automate Christmas lights that aren't smart?
Yes, any ordinary mains-powered string works, provided the lights stay switched on at their own inline switch and the plug supplies power. The smart plug does the switching, so Home Assistant sees a simple on/off device. The limit is features: you cannot dim or recolour a basic string, and some cheap strings with built-in flashing modes restart on that mode each time power returns, so test it once before relying on it.
Is it safe to put Christmas lights on a smart plug?
It can be, with the same caution as any plug-in device. Keep the combined load within the plug's printed rating, plug it directly into a wall socket instead of an extension lead, and for outdoor use connect through a 30mA RCD-protected socket. A smart plug adds a small standby draw and a point of failure, so inspect the plug and cable as you would the lights, and stop using anything that gets warm or looks damaged.
Why won't my Christmas lights turn on at sunset?
Check the automation trace first: Settings, Automations, then the three-dot menu and Traces. It shows whether the sun trigger fired and which condition blocked it. The usual culprits are a condition that fails because your phone shows as away, a wrong entity name, or the plug having dropped off Wi-Fi so the action ran against an unavailable entity. Give a Wi-Fi plug a reserved address on your router, and check that Home Assistant's home location is correct, because sunset is calculated from it.
What should you build next?
Once the basics work, try a front-door scene that brightens outdoor lights when a parcel is detected, or tie the tree to a presence sensor so it only runs when someone is in the room. Our best smart garden lights UK guide covers outdoor options, and the Shelly Plug S review shows how a local-only plug behaves in practice.





