Pushover

Latest

  • Weekend Geek Project: Create your own image hosting system

    by 
    TJ Luoma
    TJ Luoma
    06.14.2014

    For the past several years I have been trying to come up with a good way to post images to the web from my iPhone. Now that I have a Mac as my web server via MacMiniColo, it is incredibly easy. Now, I'll be completely honest, setting this up did take some time and effort. It is not as simple as clicking a button, but if you can follow some instructions, you can do it too, assuming that you have access to all of the pieces. The Goal This shouldn't be a difficult problem to solve: I have an image on my iPhone. I want to post it to the web and get an URL that I can use. I have tried all of the various image sharing services out there. They all have the same problems: either they are chock full of ads and don't want to give you just a plain URL to use, or they go out of business. Or, sometimes, both. The latest one to go under is mlkshk, which is a shame not only because they provided a great service, but when I checked the various "Terms of Service" at different image hosting companies, they had the best one. But even if there was a great service out there with a great app, I'm still not sure that it would be better than the "holy grail" solution that I have wanted: Take a picture on my iPhone using the regular camera app (or any other). Edit it (or not) using the regular photos app (or any other app). Email the picture, which gives me a chance to reduce the size (or not). Receive an URL to the direct image via push notification. Since I couldn't find the service that I wanted, I've tried rolling my own a few times, but none of them worked as fast or as easily as I wanted, until I figured out the last missing piece. The Pieces of the Puzzle I won't hold you in suspense: the last missing piece was a real Mac server. I recently signed up for MacMiniColo and I couldn't be happier with the decision unless I could get in a time machine to go back and make it sooner. Once I had a Mac server, the rest of the pieces were easy: SendToDropbox - gives you a private email address that you can use to email files and have them added to your Dropbox. Although paid accounts are available, you can start using it for free. A shell script (naturally) which will move the file from the SendToDropbox folder to the appropriate web folder, and do some other housekeeping. Pushover (or Prowl) - to send push notifications from your Mac to your iPhone. SendToDropbox Once you have created a SendToDropbox account and linked it to your Dropbox, you'll need to go to https://sendtodropbox.com/account and create a special email address just for this purpose. It will generate a random email address for you. Keep it random. That way no one else will be able to post pictures to your website via email! (For added security, see the "Whitelist" settings in SendToDropbox.) Once you have your SuperSekret SendToDropbox email address, go to the "Organization" tab, and drag the "To Address" and "Subject" from under "Available Attributes" to "Destination" so that it ends up as shown above. Make sure that the "To Address" comes before the "Subject." What this means is that every file that you send to your SuperSekret@sendtodropbox.com email address will be saved to ~/Dropbox/Apps/Attachments/SuperSekret@sendtodropbox.com/Your Subject Here/. I'll explain why that's important in a moment. launchd There is a feature in launchd called QueueDirectories which looks at a directory. It has to end up being empty, but that's OK because we are going to empty all of the files when we're done. Replace /Users/jsmith/Dropbox/Apps/Attachments/SuperSekret@sendtodropbox.com with whatever the SendToDropbox path is on your Mac: Now what about that /usr/local/bin/sendtodropbox-image.sh file? Well, that's the last piece of the puzzle. sendtodropbox-image.sh The script sendtodropbox-image.sh is going to process the files in your SendToDropbox folder ~/Dropbox/Apps/Attachments/SuperSekret@sendtodropbox.com by moving them into the folder that you use the host images, and then it's going to send you the URLs via Pushover using a shell script called posh that I have previously discussed over at GitHub. It also uses jhead to make sure that the iPhone pictures appear with the correct rotation. If you do not have it installed already, I recommend brew install jhead (or you can get it from rudix ). Now when I want to post an email, I just send an email, choose the size: and then about a minute later I'll get a confirmation with the URL And then I can use that image anywhere. Like right here, for example: You do not need a Mac server to do this if you have an "always on" Mac, you could do this and then sync it to any web server using unison or rsync. However, you'll have to figure out those steps on your own. Now that I've experienced what it's like to have a real Mac server, I can't imagine going back to anything else. If any of you scoffing at the idea that a Mac mini could be a "real" server: I am using a 2010 Mac mini (Macmini4,1) Intel Core 2 Duo with 2.66 GHz process with 4 GB of RAM and a non-SSD hard drive. Most of us would look at those specs and say that it is not "new" and not "powerful" but it rocks as a server. I've been running lots of apps on it at once, including Time Machine, Dropbox, OwnCloud, and BitTorrent Sync (I'm testing sync options for another article), as well as hosting my own websites on it, and it hasn't even blinked. Summary Recap Here's a checklist for you if you want to re-create this on your own Mac: Create a SendToDropbox account Setup an email address to be used for this purpose and configure its "Destination" as shown above (e.g. ~/Dropbox/Attachments/Foo/) Add the email address to your iPhone contacts Create a launchd plist file in your ~/Library/LaunchAgents/ folder named something like com.tjluoma.sendtodropbox.email-to-url.plist Set the QueueDirectories to the directory used by your SendToDropbox address created in step 1 ( ~/Dropbox/Attachments/Foo/) If you do not plan to put the shell script at /usr/local/bin/sendtodropbox-image.sh be sure to change the contents of the plist to point to wherever you will save the script. Load it using this command (substituting whatever name you chose): launchctl load ~/Library/LaunchAgents/com.tjluoma.sendtodropbox.email-to-url.plist Create the sendtodropbox-image.sh script, ideally at /usr/local/bin/ Change the SOURCE= line to point to the folder described in Step 1 (that is ~/Dropbox/Attachments/Foo/ or whatever you chose) Change the DIR= to the folder to your web server's path Make sure it is executable: chmod 755 /usr/local/bin/sendtodropbox-image.sh Setup Pushover Create a new account at https://pushover.net/login Generate a Token and User key at https://pushover.net/apps/build Get po.sh, configure it, make it executable Install jhead That's all. The setup will take you some time, but once you have it, you can use it with the knowledge that you never have to worry about a 3rd-party image hosting company going out of business, or changing their terms of service, or anything else they might do.

  • Belkin's WeMo: iPhone-based home automation with a taste of IFTTT

    by 
    Steve Sande
    Steve Sande
    08.10.2012

    In my futuristic dreams, I'm able to control everything in my house from my iPhone. That dream might not be too far off, thanks to the Belkin WeMo system. The WeMo currently consists of two hardware devices -- a Wi-Fi equipped power switch/outlet and a Wi-Fi equipped motion sensor -- plus a free WeMo iOS app; the entire Belkin WeMo system is an easy way to move into home automation. Let's take a look. Setting up the devices You can currently buy the WeMo switches for US$49.99 each or a set with a switch and a motion sensor for $99.99. I chose to buy the set, as I have some "experiments" I want to try. Belkin obviously looked at how other companies were doing setup of wireless devices and chose to come up with the most simple method possible. To get both switches working took me less than three minutes. %Gallery-162203% You begin by plugging the device into a standard wall outlet. At first, a small light flashes blue and red to indicate that the device isn't configured. Launching the WeMo app, you're given instructions on how to proceed. First, go to iPhone Settings, tap Wi-Fi and select the WeMo's temporary WiFi network. Next, go back to the app, where the device appears in a list. You tell the app the name of your normal home or office Wi-Fi network, enter the password for that network, and then choose whether to store the settings in the app. Doing the latter step makes set up of all other devices a real snap, as the app already knows the name and password for the network. And with that, you're done. After I played around with turning lights on and off for a while, I noticed that there was a firmware update for the WeMo boxes. The process for updating is easy. You basically tap a button on the iPhone screen and wait for about three minutes. Using the app and setting rules There's not too much to say about the app, other than once again it's simple. There are tabs for switches, sensors and rules. For the switches, you'll see a list of all WeMo switches on your network. Each switch, which you can give a custom name, has an on/off button. Tap the button, the device is turned on and the button turns green. Tap it again, the button goes back to gray and the device is turned off. With the motion sensor, there's not a lot you can do until you set up a rule. Rules are exactly that -- "turn on the living room lamp if the laundry room entrance sees motion on Mondays between 2 and 4 PM" as an example. Rules can also be used with the switches. You can choose to program a switch to go on or off at a specific time, or you can turn something on, then off again a few hours later. But the built-in rules are rather simple... WeMo, meet IFTTT Whoever the person was at Belkin who had the brilliant thought to integrate WeMo with If This Then That (IFTTT.com) should get a big raise. If you've never used IFTTT before, give it a try. There are currently 50 "channels" on IFTTT, with everything from Twitter and Facebook to ESPN and weather. You create "recipes" that perform a certain action if a specific trigger is met. For example, I use a recipe that tweets the URL of every post that I write on TUAW from my Twitter account. What does this have to do with WeMo? Well, there are IFTTT channels for the WeMo motion detector and switch. This opens up all sorts of possibilities. Say you want to receive a text message whenever your cat uses the litter pan. You set up a motion detector next to the litter pan, and every time el gato feels the need to go, you get tweeted. There are even wilder things you can set up. Plug a fan into a WeMo switch, then set up an IFTTT recipe to turn the fan on if the local outside temperature goes above 85° F (I tried this -- it works). Have IFTTT call you whenever someone enters the house (it works). And if you want to shut that fan off, you can either write another recipe or just use the WeMo app to shut it off remotely. For push notifications, mix in a dash of Pushover and those emails and phone calls you're receiving on your iPhone turn into regular old notifications. Conclusion While the components are a little pricey, the WeMo system is probably about the easiest home automation system to configure. Anyone can set up this system in minutes, then proceed to control lights, fans, appliances, and more from their iPhone anywhere there's data service. With the IFTTT integration, it's possible to set up a huge variety of recipes to mix and match apps and services to work at your command. Pros If WeMo was any more simple to set up, it would set itself up iPhone app is well written and easy to use Firmware updates are installed with one tap of a button Remote access extends your reach to your home lights and appliances to anywhere with data service Attractive design IFTTT integration turns a simple set of devices into a home automation powerhouse Cons A bit on the expensive side, but still affordable for many Who is it for? Anyone who wants to dabble with iPhone-controlled home automation but doesn't have the skills or patience to build their own hardware or write their own apps.