How to Set Up a Smart Lighting Schedule with Adjustable Brightness

I’ve been exploring ways to optimize my smart lighting setup, and I wanted to share my experience in case it helps anyone else. My goal was to create a lighting schedule that adjusts brightness based on the time of day, especially for motion-activated lights. Here’s how I approached it:

The Challenge
I have a Raspberry Pi 3 with a Conbee2 stick controlling two groups of IKEA lights using motion sensors. While the lights turn on when motion is detected, I wanted more control over their brightness. Specifically, I wanted the lights to be brighter during the day (7 AM to midnight) and dimmer at night (midnight to 7 AM) for a softer glow when waking up or moving around late at night.

The Solution
Phoscon, the software I was using, only offered basic day and night settings, which didn’t fit my needs. After some research, I discovered that I could use a combination of Phoscon and a simple Python script to achieve the desired brightness adjustments. Here’s a breakdown of what I did:

  1. Setting Up the Schedule

    • I configured Phoscon to handle the basic on/off functionality based on motion detection.
    • I wrote a Python script that runs as a cron job on my Raspberry Pi. This script adjusts the brightness of the lights based on the current time.
  2. The Python Script

    • The script checks the current time and sets the brightness to 100% during the day and 15% at night.
    • It uses the deCONZ REST API to communicate with the Conbee2 stick and adjust the light settings.
  3. Implementation

    • I installed Python and the necessary libraries on my Raspberry Pi.
    • I set up the script to run every hour using cron, ensuring the brightness adjusts smoothly throughout the day.

Tips and Tricks

  • Automation: If you’re not comfortable with scripting, you can use Home Assistant or other smart home platforms to automate brightness adjustments.
  • Testing: Start with smaller adjustments and test them over a few days to ensure everything works as expected.
  • Energy Efficiency: Lowering brightness at night not only creates a softer environment but also saves energy.

Conclusion
This setup has been a game-changer for me. It provides the perfect balance between functionality and comfort, and it’s been a great learning experience to boot! If anyone has questions or needs help setting something similar up, feel free to reach out. Happy automating! :rocket: