The easiest way to get the code is to update your SD card by running the DI Software Update utility. You will need to have an internet connection on your Pi for this step.
Do not plug the lights in yet.
Once the SD card has been updated, open up a terminal window and enter the following:
sudo python holidays.py
The code will start running. Depending on your current environment, the relay may or may not click right away. You can cover the light sensor with your hand to simulate night time, or put the motion sensor (the PIR sensor) under a mug so it won’t detect movement. To stop the code, use Ctrl-C to interrupt it.
Of course, since the lights are not plugged in, they won’t turn on, but you can hear the relay click on and off, and there’s a tiny red LED on the relay board to let you know when it’s on.
The code is written in such a way that the lights will turn on at dusk and run for five hours. Then the wreath will rest for six hours. You can adapt to your environment and desired usage by editing the code and changing two variables.
sudo nano holidays.py
Scroll down a bit until you find the following:
light_threshold might need to be adjusted based on the wreath’s environment.
hours_after_sunset represents how many hours will the lights be on once they are turned on automatically due to darkness.
hours_of_sleep represents how many hours will the wreath be inactive at night.
To save your changes, press Ctrl-X, followed by Y, and the Enter key