How To: Control your LIFX Lights from Twitch Conversation using IFTTT

Today my girlfriend HelloMissPotter (who streams a variety of games on Twitch) was sent a few LIFX Bulbs and a ZStrip from LIFX for her to show off to her followers. I thought it would be cool for her stream viewers to be able to change the color of the lights backside her as she streamed.

A bit of background for my usual readers: on Twitch, viewers blazon into a chat window, and often streamers enable commands to do cool stuff, such as make song requests, find out how long the streamer has been streaming for, and much more. This unremarkably takes the class of !command.

And then, here's what you'll need.

  1. A Twitch account

  2. A Nightbot account (Sign in with your Twitch business relationship)

  3. An IFTTT account

  4. A LIFX Account (make this on the mobile app when you prepare the bulbs)

  5. A LIFX Seedling or ZStrip

Function One: Setting up IFTTT

First up, we want to go into IFTTT and create a new applet. We want to search and notice Webhook. (This is a fancy term for website that triggers things).

Screen Shot 2019-06-22 at 5.39.10 PM.png

Then choose Receive a spider web request

Screen Shot 2019-06-22 at 5.39.20 PM.png

Since you can use this as many times as you desire in IFTTT, you lot accept to enter a unique proper noun. I chose lifx_color, simply you can call it whatever you like, such every bit your dogs name. Retrieve it for later.

Screen Shot 2019-06-22 at 5.39.31 PM.png

And then, that's the "If This" part washed. In this case, nosotros've called "if webhook with the event name lifx_color". At present information technology'due south time for the "And then That" part. In our case, its interacting with a LIFX bulb, so go alee and search and detect that.

Screen Shot 2019-06-22 at 5.39.42 PM.png

Hither you lot'll demand to sign into your LIFX business relationship. In one case that is done, you'll run into the menu of possible deportment. For this, we will choose Change color of lights, but you could explore the other options subsequently.

Screen Shot 2019-06-22 at 6.20.22 PM.png

In the setup, choose your lite. This will take a moment to load every bit IFTTT asks LIFX for a list of your lights.

Now, leave most unchanged, and scroll to the lesser of the card.

Screen Shot 2019-06-22 at 6.20.55 PM.png

In the Avant-garde options field blazon "color: " (no u), then click on the Add together Ingredient button. Cull Value1. Then type a semicolon to close off the minor bit of lawmaking. Nosotros'll populate value1 with a color value afterwards on.

Screen Shot 2019-06-22 at 6.21.27 PM.png

The last issue should await like colour: ;
(The underline and 1 are a browser plugin I have installed for spelling. Colour is the right way to spell this in my part of the world.)

Screen Shot 2019-06-22 at 6.21.42 PM.png

Side by side upward is to excerpt the Webhook URL from IFTTT for use later in Nightbot/Twitch.
Click Services

(I have been tinkering more than you might have…)

(I have been tinkering more you might take…)

Screen Shot 2019-06-22 at 6.45.24 PM.png

Click Documentation and you'll encounter this rather scary page. I've blacked out my keys so you don't fiddle with my lights. Call up: with this, you've exposed to the whole world the ability to change your lights, only you need a rather long and obscure URL, and then you're probably rubber.

In the first red box, enter the name of the webhook issue you chose, remember we went with lifx_color above.
In the next, type 'cherry'.
At present, the moment of truth, click Examination It. In no more than 20 seconds, your lights should change to red.
(Hint: For LIFX, make sure the lights are not cerise, and the app is closed - they tend to fight for control).

Huzzah! You should exist successful. If not, double check these instructions. Brand sure the upshot names match, you chose Value1, and you typed the code correctly as per the screenshot.

Screen Shot 2019-06-22 at 6.45.52 PM.png

From here, yous have a URL to use. However, to include the color, you need to add a bit to the end of it. And that is ?value1=red. (Or your colour of choice)

So, your full Webhook URL for NightBot/Twitch will be:
https://maker.ifttt.com/trigger/lifx_color/with/key/XXXXXXXXXXXXXXXX?value1=colour


Part Two: Setting upwardly NightBot

Next upward, log into NightBot and navigate to Commands, Custom. Click + Add Control.


In hither, choose a proper name for your command, I will utilise !color and my chat participants will blazon !color red, !colour greenish … etc.

In the bulletin field, we will use the urlfetch control, which basically access a website. Huzzah, early we ready a wehbook which is also a website, which when accessed changes our lights color! This hopefully should be starting to brand sense.

Now we need to write the command and add a chip of code to pass the name of the color through. The control is:

$(urlfetch <url_from_earlier>?value1=$(querystring))

Notice how I substituted red for $(querystring), this ways "put what the person typed later on !color in here". So if they type !color green, the outcome will be:
$(urlfetch <url_from_earlier>?value1=green))Here's a full screenshot to show my working control.

You can also change other settings like user level (Mod, Sub, You, Anyone etc) and Cooldown.

You tin too change other settings similar user level (Modernistic, Sub, Yous, Anyone etc) and Cooldown.

Next up, you need to add Nightbot to your twitch chat as a moderator, so in Nightbot'southward Dashboard you need to click Join Aqueduct, and follow the instructions provided to make Nightbot a moderator.

At present, head to your twitch chat and type the control and a colour afterwards, and over again expect upward to 20 seconds for the command to work and run across your lights change!

In this post, we used red and green equally colour options, but yous tin also do: white, red, orange, xanthous, cyan, green, blue, purple, or pink. You can read more here, where you tin can examination fifty-fifty more.

For experts who know hex colors, you can also use these, fifty-fifty in your command, then !color ff0000 will fix the red. Google is your friend for finding more than options.

To suppress the output (eg "Congratulations! You've fired the lifx_color event") from the API, you tin can put your ain result such every bit "You changed my lights! (give it a sec…)" in another command, such as !colorresult, and the put !colorresult in the Alias field in the dialog higher up.