Bart Simons

Bart Simons

Thoughts, stories and ideas.

Bart Simons



.net .net 5 .net core Apache C# CentOS LAMP NET Framework Pretty URLs Windows Server WireGuard access log add analysis android api at the same time authentication authorization automate automation azure azurerm backup bash basics batch bootstrap build capture cheat sheet chromium chroot class cli click to close code coverage code snippet command line commands compile compiling compression containers control controller controlling convert cpu usage create credentials csv csvparser curl data dd deployment desktop detect devices disable diskpart dism distributed diy docker dom changes dotnet core drivers ease of access encryption example export file transfer files fix folders framework generalize getting started ghost gui guide gunicorn gzip html html tables icewarp igd imagex import inotify install installation interactive ios iphone itunes java javascript jquery json kiosk kotlin linux live load data loading screen lock screen loopback audio lxc lxd lxml macos manage manually message messages minio mirrored mod_rewrite monitor monitoring mstest mutationobserver mysql net 5 nexmo nginx no oobe node node.js nodejs not installing notification notifications object storage on desktop one command openssl owncloud parallels parallels tools parse perfect philips hue play port forwarding powershell processing ps-spotify python quick raspberry pi record rip ripping rsync rtmp save save data sbapplication scraping script scripting scriptingbridge scripts security send server service sharedpreferences sms songs sonos spotify spotify api spotlight ssh stack streaming streamlink studio sudo swarm swift sync sysprep system audio systemd tables terminal testing tracking tutorial twilio ubiquiti ubuntu ubuntu 18.04 ui code unifi unlock unsplash source upnp uptime usb tethering wallpapers wasapi website websites webview windows windows 10 without itunes without oobe workaround xaml

Control Philips Hue from the command line

I recently got my hands dirty with Philips Hue lighting, and the experience has been pretty good so far. There was still one thing that really got me interested: checking out the possibilities of the Philips Hue API. Since I am a frequent user of the command line, I decided to start working on a command line application to control my Hue lighting with, just for fun. I called it huecli and in this guide I will show you how you can get it to work with your Philips Hue setup.

Huecli is a work in progress project at the time of writing this article, and already contains functionality for the following use cases:

Of course, more functionality will be added to the source code later on.

Building huecli

Huecli is made in C#, and requires the .NET Core framework to run it. Runtimes are available for macOS, Linux and Windows.

All code is available at After you cloned the repository, go to your terminal and change your directory to the cloned repo location. Run dotnet restore to restore all packages/dependencies. Now you can build executables for your platform:

# macOS
dotnet build -c Release -r osx-x64

# Linux
dotnet build -c Release -r linux-x64

# Windows
dotnet build -c Release -r win-x64

Produced binaries can be found in bin/Release/netcoreapp2.0/osx-x64. Of course, osx-x64 is my platform identifier, if you use Windows or Linux you should change that.

One handy trick is to add this location to your path environment variable, so that you don't have to type the full path to the binary everytime you want to use it.

On macOS it works like this:


Type this in your terminal (replace the path of course) and you should be good to go.


If the command huecli returns a list of available commands, you are good to go!

Scanning for available hubs using UPnP

Use the command huecli scan-hubs to get all available hubs:


Please note that this is purely for discovering hubs - this does not add your hub to the program yet. Also, this might not work if your router doesn't have UPnP. In that case you need to manually find your hub IP address to add it later on.

Adding your hub to the program

Use the command huecli add-hub hubaliashere hubipaddresshere to add your hub. The hub alias is a nickname for your hub which serves as an identifier (so it has to be unique).

So an example would be:


As you can see, all you have to do now is press the physical button on the top of your hub. Your hub should now be linked to your app.

Getting a list of lights

Want to see a list of light names with their IDs? You can use huecli get-lighting hubaliasgoeshere for that:


You'll need the light IDs for use with the light control commands. More on that in all the paragraphs below.

Turning on a light (and turning it back off)

Turning on a light is fairly easy if you can remember your light IDs. This is how I turn my bed light on:


You can replace turn-on with turn-off if you want to turn your light off.

Setting the brightness of a light

You can easily set the brightness of a specific light with the command as shown in the picture here:


mainhub is the alias of my hub, 1 is the light ID and 254 is the brightness level between a scale of 1 to 254.


Cool! Now that you can control your Hue lighting from the CLI. What's next? I am planning to implement other functionality like rooms, entertainment areas, light warmth and color in the future. The best way to stay up to date is to star and follow my GitHub repo at I hope you have learned something and as always, have a nice day 😉

Bart Simons

Bart Simons

View Comments