Alrighty, for a proof of concept I integrated IFTTT with my mochad. You could however just as easily integrate it with the sample switch app, or any other software on the Almond+. I will post my method of doing so here, but follow at your own risk. usual disclaimer applies, I am not responsible if this bricks your router, your friend's router, or your enemy's router. It worked for me, but I am almost certainly leaving out at least one step. Also, this uses a Wordpress API xmlrpc hack, and I don't know if IFTTT dislikes this practice.
I tried to make this have as few dependencies as possible (to the point where I rewrote the script in perl, then even replaced the Switch function to not rely on that). As such, I believe this actually has _no_ package dependencies. Also, this was tested on R065, I haven't installed R066 yet.
The only dependency my current setup has is that it relies on having a hostname for lighttpd to do some external service restrictions. You can formulate your own if you want.
Install perl script on Almond+:
I put it in
/www/iftttn/xmlrpc.pl
If you want to put it somewhere else, you should modify things later to suit.
mkdir /www/iftttn
cd /www/iftttn
wget http://remote.thejanky.org/mirrors/almondplus/code/xmlrpc.pl
chmod +x xmlrpc.pl
You can edit this file to create a username and password (at the top of the script). Obviously this is not great security, someone should probably change this to be better.
Modify lighttpd conf:
No clue if this is actually necessary, but I haven't tested if it works without it, so I put it here anyway. Add the following line somewhere, as I believe the usual xmlrpc connection is done with php, but we're going to fake it with our perl script (so we don't have to install php).
alias.url = ( "/xmlrpc.php" => "/www/iftttn/xmlrpc.pl" )
I also add a host-based restriction (change "my.hostname.com" to your hostname):
$HTTP["host"] == "my.hostname.com" {
server.document-root = "/www/iftttn/"
$HTTP["url"] !~ "^/xmlrpc.p(hp|l)" {
url.access-deny = ( "" )
}
}
Don't forget to restart lighttpd after these changes:
/etc/init.d/lighttpd restart
Then opened up the firewall. You can do so via the web interface. The relevant part of /etc/config/firewall for me was:
config 'rule'
option 'target' 'ACCEPT'
option 'src' 'wan'
option 'proto' 'tcp'
option 'name' 'routerwww'
option 'dest_port' '80'
If you change the conf directly, I imagine you'll have to restart /etc/init.d/firewall.
Then just add it to IFTTT as a Wordpress installation. There are screenshots here of what to do:
https://github.com/captn3m0/ifttt-webhook/URL: my.hostname.com/iftttn/
Username: whatever you set in the script
Password: whatever you set in the script
Finally, create your rules. If you're using mochad, you just pass a mochad command in the body of the wordpress post, the rest of the fields are ignored. If not, you should modify the process_command function in xmlrpc.pl to do whatever you want (currently the body is stored in $obj->{url}, modify/use at will).
For info on setting up mochad, see the forum post on it:
http://forum.securifi.com/index.php/topic,615.msg7006.html#msg7006I believe that is everything. Let me know when it doesn't work and I will try to help figure out what I invariably left out of the instructions. I probably won't actually use this, so I'm not sure I'll support it long term, but I wanted to see how hard it would be to do, so here it is.