Reply
New Member
Posts: 14
Registered: ‎01-29-2016
Kudos: 4

[SOLVED] Any support or work arounds for Amazon Echo?

[ Edited ]

Hello, 

 

Wondering if anyone knows any ways to get Amazon Echo to somehow work with mfi? 

I've seen some possibly promising things with UCI portal or IFTTT.  Or even get mfi to integrate with phillips hue hub? 

 

I am by no means a programmer or coder, but I have a pretty sweet setup over the past year in my house with about 10 dimmers, several outlets, motion sensor, some door sensors, AP, router, and switch, all managed with mfi and unifi controller.  

 

Now my mother in law just bought me an amazon echo for Christmas :/ 

Any thoughts or help would be greatly appreciated 

Highlighted
New Member
Posts: 14
Registered: ‎01-29-2016
Kudos: 4

Re: Any support or work arounds for Amazon Echo?

[ Edited ]

OK I got it working!!!!!

Can now run any scene throughout my whole house by telling alexa to do it.  Woohoo!

 

So......heres the tutorial for anyone interested.  first off, Its a little hacky, but now that its all setup, it works quite well, and takes me about 1 minute to create a new scene and make alexa start controlling it.  I spent several days trying to get this to work on OSX, and kept having SSL protocol errors when trying to cURL from terminal.  So I did a fresh install of ubuntu 14.04, and voila, no more ssl protocol errors.  So I highly encourage anyone wanting to do this to be using ubuntu. 

 

In this tutorial I am going to provide some links of sources which I used to help me figure this all out, so thank you to all the people who's work I am linking to.

 

General Overview:

1. You will need an amazon echo (obviously)

2. IFTTT account (www.ifttt.com) with the ifttt skill enabled in alexa app

3. Dropbox installed on your ubuntu machine and dropbox account linked to your IFTTT account

4. Create a script which will cURL to your mfi controller and run a scene

5. using incrontab to monitor directories and run a script each time a file is added to a directory

6. then in IFTTT create a new applet, "IF" alexa > "say a specific phrase" "THEN" dropbox > create a new text file. 

 

Now when you say "Alexa, trigger kitchen lights," a new file will be created in a dropbox directory you specified which incron will trigger a specified script to run, which will then curl to mfi controller and run a scene!

 

For this tutorial i will show you how to run a scene to turn my kitchen lights on and another scene to turn my kitchen lights off, using the amazon echo. 

 

1. Creating a scene and finding the scene URL/ID

 

 First, create your scene in mfi controller, name it whatever you like, I prefer to be organized, so i'm going to call my scene "kitchen lights on."

 

Using google chrome, Tools>developer tools, click "network" tab, then in the filter type in "run"

 

Now play your scene, you will see the URL called, see here for details: scene ID

 

2. Install Dropbox on your ubuntu machine

 

see here for details: Installing dropbox

 

in your home dropbox folder, creat a new folder called "IFTTT", then a folder inside that called "mfi", then a folder in that called "kitchen_lights"

**Important - you need a different directory for each individual scene**

The full path should be /home/USERNAME/Dropbox/IFTTT/mfi/kitchen_lights/

 

3. Creating the bash script

 

Create a new directory in your ubuntu home folder called "mfiscenes"

- the full path should be /home/USERNAME/mfiscenes"

 

in this directory, make a new script called "kitchen_lights.sh"

 

use this example, replace your info where needed where you see "XXX", etc

 

#!/bin/sh

 username=XXX    
 password=XXX    
 baseurl=https://192.168.X.XXX:6443  
 
 curl_cmd="curl --cookie /tmp/mficookie --cookie-jar /tmp/mficookie --insecure " 
 
 # authenticate against mFi controller 
 $curl_cmd --data "login=login" --data "username=XXX" --data "password=XXX" https://192.168.X.XXX:6443/login 
 
 # run a scene
 $curl_cmd -X POST https://192.168.X.XXX:6443/api/v2.0/scene/XXXXXXXX/run                           
  
 # logout 
 $curl_cmd https://192.168.X.XXX/logout
 
 exit 0

*Note the scene ID is the code you get when monitoring chrome developer tools when you run a scene*

 

4. Modify incrontab to monitor a directory and run a bash script each time a new file is added to your dropbox directory

 

see here for details: IFTTT and dropbox integration

 

example:

 

incrontab -e

 

inside your incrontab file paste:

 

/home/XXX/Dropbox/IFTTT/mfi/kitchen_lights/ IN_MODIFY,IN_CREATE,IN_MOVED_TO /home/XXX/mfiscenes/kitchen_lights.sh stop

 

when adding more scenes, for example, "kitchen_lights_off", your incrontab file will look like this

 

/home/XXX/Dropbox/IFTTT/mfi/kitchen_lights/ IN_MODIFY,IN_CREATE,IN_MOVED_TO /home/XXX/mfiscenes/kitchen_lights.sh stop
/home/XXX/Dropbox/IFTTT/mfi/kitchen_lights_off/ IN_MODIFY,IN_CREATE,IN_MOVED_TO /home/XXX/mfiscenes/kitchen_lights_off.sh stop

**note the new directory for each individual scene

**VERY IMPORTANT, make sure to add "stop" to the end of each incrontab entry, or else, only the first entry will run.

 

5. Creating a new IFTTT recipe

 

login to your IFTTT account

 

Creat a new applet

 

IF_THIS choose "Amazon Alexa"

choose "say a specific phrase"

type in "kitchen lights"

 

IF_THAT choose "Dropbox"

create a text file

for the text file name, type "kitchen_lights"

for the content, type whatever you like

for the folder path, type "IFTTT/mfi/kitchen_lights"

click save, then finish

 

example:

ifttt-dropbox.jpg

 

6. All done! now time to test

 

go to your Echo and say "Alexa, trigger kitchen lights", alexa will reply "sending that to IFTTT" (which is the only really annoying thing about this)

 

and VOILA! , you just controlled your mfi scene with Alexa!

*note, you must say "Alexa, trigger" in order for the echo to send the request to IFTTT

hopefully they will make an option to change the reply that alexa gives, because each time you say Alexa trigger XXX, she replies with "Sending that to IFTTT"

 

Have fun!

New Member
Posts: 8
Registered: ‎10-07-2016

Re: Any support or work arounds for Amazon Echo?

Hi 

Established Member
Posts: 1,278
Registered: ‎05-25-2016
Kudos: 226
Solutions: 11

Re: Any support or work arounds for Amazon Echo?


DrMilzie wrote:

OK I got it working!!!!!

Can now run any scene throughout my whole house by telling alexa to do it.  Woohoo!

 

So......heres the tutorial for anyone interested.  first off, Its a little hacky, but now that its all setup, it works quite well, and takes me about 1 minute to create a new scene and make alexa start controlling it.  I spent several days trying to get this to work on OSX, and kept having SSL protocol errors when trying to cURL from terminal.  So I did a fresh install of ubuntu 14.04, and voila, no more ssl protocol errors.  So I highly encourage anyone wanting to do this to be using ubuntu. 

 

In this tutorial I am going to provide some links of sources which I used to help me figure this all out, so thank you to all the people who's work I am linking to.

 

General Overview:

1. You will need an amazon echo (obviously)

2. IFTTT account (www.ifttt.com) with the ifttt skill enabled in alexa app

3. Dropbox installed on your ubuntu machine and dropbox account linked to your IFTTT account

4. Create a script which will cURL to your mfi controller and run a scene

5. using incrontab to monitor directories and run a script each time a file is added to a directory

6. then in IFTTT create a new applet, "IF" alexa > "say a specific phrase" "THEN" dropbox > create a new text file. 

 

Now when you say "Alexa, trigger kitchen lights," a new file will be created in a dropbox directory you specified which incron will trigger a specified script to run, which will then curl to mfi controller and run a scene!

 

For this tutorial i will show you how to run a scene to turn my kitchen lights on and another scene to turn my kitchen lights off, using the amazon echo. 

 

1. Creating a scene and finding the scene URL/ID

 

 First, create your scene in mfi controller, name it whatever you like, I prefer to be organized, so i'm going to call my scene "kitchen lights on."

 

Using google chrome, Tools>developer tools, click "network" tab, then in the filter type in "run"

 

Now play your scene, you will see the URL called, see here for details: scene ID

 

2. Install Dropbox on your ubuntu machine

 

see here for details: Installing dropbox

 

in your home dropbox folder, creat a new folder called "IFTTT", then a folder inside that called "mfi", then a folder in that called "kitchen_lights"

**Important - you need a different directory for each individual scene**

The full path should be /home/USERNAME/Dropbox/IFTTT/mfi/kitchen_lights/

 

3. Creating the bash script

 

Create a new directory in your ubuntu home folder called "mfiscenes"

- the full path should be /home/USERNAME/mfiscenes"

 

in this directory, make a new script called "kitchen_lights.sh"

 

use this example, replace your info where needed where you see "XXX", etc

 

#!/bin/sh

 username=XXX    
 password=XXX    
 baseurl=https://192.168.X.XXX:6443  
 
 curl_cmd="curl --cookie /tmp/mficookie --cookie-jar /tmp/mficookie --insecure " 
 
 # authenticate against mFi controller 
 $curl_cmd --data "login=login" --data "username=XXX" --data "password=XXX" https://192.168.X.XXX:6443/login 
 
 # run a scene
 $curl_cmd -X POST https://192.168.X.XXX:6443/api/v2.0/scene/XXXXXXXX/run                           
  
 # logout 
 $curl_cmd https://192.168.X.XXX/logout
 
 exit 0

*Note the scene ID is the code you get when monitoring chrome developer tools when you run a scene*

 

4. Modify incrontab to monitor a directory and run a bash script each time a new file is added to your dropbox directory

 

see here for details: IFTTT and dropbox integration

 

example:

 

incrontab -e

 

inside your incrontab file paste:

 

/home/XXX/Dropbox/IFTTT/mfi/kitchen_lights/ IN_MODIFY,IN_CREATE,IN_MOVED_TO /home/XXX/mfiscenes/kitchen_lights.sh stop

 

when adding more scenes, for example, "kitchen_lights_off", your incrontab file will look like this

 

/home/XXX/Dropbox/IFTTT/mfi/kitchen_lights/ IN_MODIFY,IN_CREATE,IN_MOVED_TO /home/XXX/mfiscenes/kitchen_lights.sh stop
/home/XXX/Dropbox/IFTTT/mfi/kitchen_lights_off/ IN_MODIFY,IN_CREATE,IN_MOVED_TO /home/XXX/mfiscenes/kitchen_lights_off.sh stop

**note the new directory for each individual scene

**VERY IMPORTANT, make sure to add "stop" to the end of each incrontab entry, or else, only the first entry will run.

 

5. Creating a new IFTTT recipe

 

login to your IFTTT account

 

Creat a new applet

 

IF_THIS choose "Amazon Alexa"

choose "say a specific phrase"

type in "kitchen lights"

 

IF_THAT choose "Dropbox"

create a text file

for the text file name, type "kitchen_lights"

for the content, type whatever you like

for the folder path, type "IFTTT/mfi/kitchen_lights"

click save, then finish

 

example:

ifttt-dropbox.jpg

 

6. All done! now time to test

 

go to your Echo and say "Alexa, trigger kitchen lights", alexa will reply "sending that to IFTTT" (which is the only really annoying thing about this)

 

and VOILA! , you just controlled your mfi scene with Alexa!

*note, you must say "Alexa, trigger" in order for the echo to send the request to IFTTT

hopefully they will make an option to change the reply that alexa gives, because each time you say Alexa trigger XXX, she replies with "Sending that to IFTTT"

 

Have fun!


 

GREAT guide.

 

 

im about to change my light's to Philips Hue? in regards to controlling lights, would this way be of any benefit in regards to going with MFI and regular led over the hue system?

 

other than mfi can do other things and phillips hue is limited to lightning

New Member
Posts: 14
Registered: ‎01-29-2016
Kudos: 4

Re: Any support or work arounds for Amazon Echo?

[ Edited ]

Depends on your needs, hard to truly compare mfi to hue.  Hue is very "user freindly" however I like having a physical dimmer switch (they are extremely modern and industrial looking, great for my house remodeling I've been doing over the years) without an actual physical switch/dimmer -> I dont have an amazon echo in every room in my house, and sometimes I want to be quiet and not talk to alexa, and sometimes I dont want to carry my phone with me everywhere I go and get it out everytime I want to turn on a light.  

 

technically you could use both, but going with mfi is way cheaper option as well.  for example in my kitchen I have 12 recessed lights in the ceiling, spent $60 for the led gu10 lights, and spent $50 dollars for the dimmer switch = $110 total.  Whereas if you wanted all hue lights, it would cost ~ $600.  and thats just one room.  If you want just a single lamp in the bedroom then hue would be fine, but for your "everyday" lights, a physical switch makes much more sense.  

 

Also, if you just want a single bulb or two, you should check out Yeelight.  they're basically the chinese version of hue, works out the box with alexa, IFTTT, etc, but less than half the price.  I have some, they're great, that i use in combination with mfi outlets and dimmer switches. 

Reply