How to Control Your Philips Hue Lights with Keyboard Shortcuts

With the ability to flip your lights on and off together with your voice is among the best things about having a smart home. Should you don’t have an Amazon Echo or Google Residence, although—or simply want keyboard shortcuts—you need to use an AutoHotkey script to regulate your Philips Hue lights out of your pc.

For this information, we’re going to be utilizing AutoHotkey, a tremendous little program that allows you to write customized automation scripts and even remap keys in your keyboard. In the event you’re not accustomed to AutoHotkey or have to obtain it to your Home windows machine, take a look at our beginner’s guide here.

What You’ll Want

We’re going to point out you a primary script that you should use to show a set of lights on and off (which you'll be able to customise later). Earlier than we do this, you’ll want a couple of issues.

  • A Home windows machine with AutoHotkey put in: In the event you haven’t already, you'll be able to download AutoHotkey here. It’s solely out there for Home windows machines, sadly. The appliance will run within the background and interpret the scripts you create (often in a program like Notepad).
  • Your Philips Hue Bridge IP tackle: You’ll have to enter your Bridge’s IP handle into the script to ensure that it to work. We’ll stroll you thru the right way to discover this info under.
  • A Philips Hue Developer API username: The script we’re utilizing additionally makes use of the developer API. So as to make use of it, you’ll have to have an account and know your developer API username. As soon as once more, we’ll present you tips on how to get an account and discover your ID under.
  • The AutoHotkey script: Within the subsequent giant part under, we’ll have the script we’re basing this information off of. Reddit consumer tarrosion created a template that we’ll be basing ours off of here if you wish to dive slightly deeper. Nevertheless, we’ve tweaked this script to simplify it. Copy the script from the part under, paste it in a clean Notepad doc, after which reserve it with a reputation like hueshortcut.ahk .

In case you already know your bridge IP tackle and API username, then you possibly can skip forward.

How you can Discover your Bridge IP Tackle

Your bridge IP tackle is comparatively easy to seek out. Head to this link and signal into your Philips Hue account.

Alongside the highest of the web page, click on Bridge.

Click on the “Present extra bridge particulars” button.

Make a remark of your Inner IP Handle. You’ll want it later.

Cling on to this for the subsequent part.

Tips on how to Get a Hue Developer API Account

For those who don’t have already got a Hue Developer account, or for those who’ve forgotten your API username, you’ll have to get one now. This half is a bit more difficult, however should you’re snug utilizing a couple of textual content instructions it must be simple. Begin by heading here and creating a brand new developer account with Hue.

You’ll get an e mail asking you to verify your account and create a password. As soon as that’s accomplished, head to the next URL, changing <bridge ip handle> with the IP tackle you grabbed from the earlier part.

http://<bridge ip handle>/debug/clip.html

Right here, you’ll see a software that allows you to manually ship instructions to your Hue bridge. In case you don’t perceive every little thing on this web page, that’s alright. You solely want to make use of this device to get your API username. To try this, enter /api/ within the URL field. Underneath Message Physique, enter "devicetype":"my_hue_app#iphone peter"  changing iphone peter with no matter descriptor you need, ideally one which describes the system you’re utilizing it on.

Once you’ve entered all the data, faucet the hyperlink button in your Hue bridge. This can be a safety step to ensure that solely you or somebody inside your own home can create purposes to regulate your lights. When you’ve pressed the hyperlink button in your bridge, click on POST.

Within the Command Response field, you must see a outcome that appears just like the one under (minus the censor blur, naturally). You’ll be given a lengthy, randomized username. Copy this down someplace and reserve it. You’ll want it for the script afterward.

Now that you've these two items of data, you’re able to arrange your script!

The way to Set Up the AutoHotkey Script

As I discussed earlier, for this information, we’re utilizing a modified model of this script from redditor tarrosion. We’ve tweaked it so as to add shortcuts so you possibly can flip a gaggle of lights on and off directly as an alternative of each mild in your home. Listed here are the next hotkeys you’ll have the ability to use with this script:

  • Ctrl+Alt+L: Toggle all your lights on or off.
  • Ctrl+Alt+I: Flip all lights off.
  • Ctrl+Alt+O: Flip the present group of lights on.
  • Ctrl+Alt+I: Flip the present group of lights off.
  • Ctrl+Alt+1: Change to Group 1.
  • Ctrl+Alt+2: Change to Group 2.
  • Ctrl+Alt+Up: Improve heat of present group of lights (requires Colour or Ambiance bulbs).
  • Ctrl+Alt+Down: Lower heat of present group of lights (requires Shade or Ambiance bulbs).
  • Ctrl+Alt+Left: Improve brightness of present group of lights.
  • Ctrl+Alt+Proper: Lower brightness of present group of lights.

You possibly can create or modify as many teams of lights as you want. For this instance, I’ve created two teams of two lights every: one for an workplace and one for the lounge. You possibly can change the names of those as you see match. You additionally may have to vary the values of every group relying on what number of lights you could have.

First, copy the script under right into a Notepad doc and reserve it as one thing like “huelights.ahk” ensuring to exchange the .txt extension with .ahk. With out that, Notepad will reserve it as a .txt file and AutoHotkey gained’t be capable of run it.

WinHTTP := ComObjCreate("WinHTTP.WinHttpRequest.5.1")
lightsOn := 1
workplace := [1,2]
livingroom := [3,4]
curgroup := workplace lightoff(mild, ByRef WinHTTP)  WinHTTP.Open("PUT", "http://<your-bridge-IP-address>/api/<your-api-username>/lights/" . mild . "/state", zero) bodytext = "on" : false WinHTTP.Ship(bodytext) return  lighton(mild, ByRef WinHTTP)  WinHTTP.Open("PUT", "http://<your-bridge-IP-address>/api/<your-api-username>/lights/" . mild . "/state", zero) bodytext = "on" : true WinHTTP.Ship(bodytext) return  setlightct(mild, newct, ByRef WinHTTP)  WinHTTP.Open("PUT", "http://<your-bridge-IP-address>/api/<your-api-username>/lights/" . mild . "/state", zero) bodytext = "ct" : %newct% WinHTTP.Ship(bodytext)  modifylightct(mild, quantity, ByRef WinHTTP)  WinHTTP.Open("PUT", "http://<your-bridge-IP-address>/api/<your-api-username>/lights/" . mild . "/state", zero) bodytext = "ct_inc" : %quantity%, "transitiontime" : 2 WinHTTP.Ship(bodytext)  modifylightbrightness(mild, quantity, ByRef WinHTTP)  WinHTTP.Open("PUT", "http://<your-bridge-IP-address>/api/<your-api-username>/lights/" . mild . "/state", zero) bodytext = "bri_inc" : %quantity%, "transitiontime" : 2 WinHTTP.Ship(bodytext)  ;ctrl-alt-1: change to group 1 ^!1:: curgroup := workplace return ;ctrl-alt-2: change to group 2 ^!2:: curgroup := livingroom return ;ctrl-alt-o: flip group lights on ^!o:: for _, mild in curgroup lighton(mild, WinHTTP) return ;ctrl-alt-i: flip group lights off ^!i:: for _, mild in curgroup lightoff(mild, WinHTTP) return ;ctrl-alt-l: toggle all lights ^!l:: WinHTTP.Open("PUT", "http://<your-bridge-IP-address>/api/<your-api-username>/teams/zero/motion", zero) if lightsOn > zero bodytext = "on" : false else bodytext = "on" : true WinHTTP.Ship(bodytext) lightsOn := 1 - lightsOn return ; ctrl-alt-k : all lights off ^!okay:: WinHTTP.Open("PUT", "http://<your-bridge-IP-address>/api/<your-api-username>/teams/zero/motion", zero) bodytext = "on" : false WinHTTP.Ship(bodytext) lightsOn := zero return ;ctrl-alt-Up: improve heat of present mild group ^!Up:: for _, mild in curgroup modifylightct(mild, 43, WinHTTP) return ;ctrl-alt-Down: lower heat of present mild group ^!Down:: for _, mild in curgroup modifylightct(mild, -43, WinHTTP) return ;ctrl-alt-Left: improve brightness of sunshine group ^!Left:: for _, mild in curgroup modifylightbrightness(mild, -32, WinHTTP) return ;ctrl-alt-Proper: lower brightness of sunshine group ^!Proper:: for _, mild in curgroup modifylightbrightness(mild, 32, WinHTTP) return

Now, you’ll have to make a few changes. First, within the script, change each occasion of <your-bridge-ip-address> to the IP tackle you bought out of your bridge earlier. Subsequent, substitute <your-api-username> together with your Hue API username. There ought to be seven situations of every within the script above.

Subsequent, you’ll see a piece on the prime that defines the teams you'll be able to management. That part appears like this:

workplace := [1,2]
livingroom := [3,4]

The primary two strains outline your teams of lights. Every bulb is assigned a quantity, although it’s not all the time apparent what quantity every of your lights corresponds to. The simplest method to examine is to open up your Hue app and faucet Settings, then faucet Mild Setup.

 

Right here, you’ll see an inventory of all of your lights. Rely every one down to be able to work out which quantity your lights are. For instance, the 2 lights in my workplace are on the prime, so they might be 1 and a couple of. Under which are my front room lights, so these must be three and four. In case you’ve eliminated and added new lights out of your setup, these numbers might shift a bit, so check your scripts and use slightly trial and error to ensure you’re utilizing the correct lights.

When you’ve discovered the numbers that correspond to your lights, change them within the two strains above. You may also change the identify of every of the teams if you wish to. Simply be certain that to vary each occasion of that group identify within the script. If you wish to add a 3rd group (or extra), create a brand new line under the primary two utilizing the next format, changing X, Y with the numbers of the lights you need to add to that group:

roomname := [X, Y]

You’ll additionally want so as to add one other shortcut to have the ability to change to the third group. Choose the next block of textual content within the script above and make a replica of it under this textual content block, altering all of the 2s to 3s and alter “livingroom” (or no matter identify you gave your second group) to the identify of the third group:

;ctrl-alt-2: change to group 2
 ^!2::
 curgroup := livingroom
 return

In case you’re acquainted with AutoHotkey, you'll be able to tweak this script much more so as to add new shortcuts or management your lights in several methods. Take a look at the AutoHotkey documentation in the event you need assistance. You may also take a look at the Philips Hue API here for extra instructions you'll be able to combine into your script.



from TechFishNews http://ift.tt/2f36Ztc

Comments