Have you ever awoken and thought “Damn, I really wished these lights would automatically turn on and adjust to the upcoming day”? This thought process that I had led me to working with some Philips Hue lights- a “smart lightbulb”.

—

The Goal

—

Create an interface with a Hue API to automatically turn on the lightbulbs in the AM and adjust to outside variables.

—

The Solution

—

Lightbulbs in different scenarios

—

Unfortunately this had to be written in a MS Batch file. I wanted to use python but the server this would be running on is 32bit and can’t support Python 3.

Therefore, using hue-batch as an API I was able to write a batch file to pull from a weather website and adjust the color of the lights to the outside temperature. Then, the light closest to my eyes reflects the color of the weather which is something like “Rainy” or “Fair”. This is all called by Windows Task Scheduler to turn them on weekdays at 6am.

The batch file can be found here — expect it to be updated with more features later

setlocal EnableDelayedExpansion curl http://w1.weather.gov/xml/current_obs/KBFI.xml>File.xml for /F "delims=" %%a in ('findstr /i "temp_f" file.xml') do set temp=%%a set /a temp=!temp:~9,-11! set /a temp=temp*3+98 for /F "delims=" %%a in ('findstr /i "<weather>" file.xml') do set weather=%%a set weather=%weather:~10,-10% IF "%weather%"=="Partly Cloudy" (set wea_hue=12200) IF "%weather%"=="Rainy" (set wea_hue=40000) hue.bat -k <secretcode> -l "1 2 3" -on true -l "2" -c %temp% -h %wea_hue% -s 255 -l "1 3" -h 1 -s 1 -c %temp%