Christmas Lights Automation: Rainy Day Solution

Christmas is just around the corner, and I wanted to share a fun automation I set up to manage my holiday lights. I’ve always loved the festive glow, but one thing I wanted to avoid was leaving the lights on during a rainstorm. After some research and experimentation, I came up with a solution using LUA scripting that I’d like to share.

The setup is pretty straightforward: I created two scenes. The first one turns the lights on 15 minutes before sunset and an hour before sunrise, but only if it’s not raining. The second scene checks every 5 minutes for rain conditions and turns the lights off if it starts raining. I also added a third scene to ensure the lights turn off at midnight and 15 minutes after sunrise to save energy.

Here’s the LUA code I used for the first scene:

lua
local lul_tmp = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”,“Condition”,9)
if (lul_tmp == “Showers” or lul_tmp == “Rain” or lul_tmp == “Rain Showers” or lul_tmp == “Thunderstorm” or lul_tmp == “Scattered Showers” or lul_tmp == “Light rain” or lul_tmp == “Heavy Rain” or lul_tmp == “Rain and Snow”) then
else
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },15)
end

And here’s the code for the second scene:

lua
local lul_tmp = luup.variable_get(“urn:upnp-micasaverde-com:serviceId:Weather1”,“Condition”,9)
if (lul_tmp == “Showers” or lul_tmp == “Rain” or lul_tmp == “Rain Showers” or lul_tmp == “Thunderstorm” or lul_tmp == “Scattered Showers” or lul_tmp == “Light rain” or lul_tmp == “Heavy Rain” or lul_tmp == “Rain and Snow”) then
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },15)
end

I’d love to hear if anyone has suggestions for improving this script or if you’ve implemented something similar in your own setup. It’s been a great way to enjoy the festive lights while keeping things energy-efficient and weather-aware!

Happy holidays to everyone! :christmas_tree::sparkles: