Siri Shortcuts

Siri Shortcuts

Probably one of the most interesting features of iOS12 was the release of Siri Shorcuts. Siri shortcuts allow you to basically make your own scripts. Initially, I was not expecting much since Apple is usually strict on accessing parts of the OS. To my surprise, after looking into it more today, you have the ability to turn your WiFi on/off, execute JavaScript in Safari, and even run commands over SSH. There is even support for third party apps which opens up a lot of possibilities.

The Garage

I recently got a car, but unfortunately I don’t have a remote for my garage and programming it would mean having to reprogram my entire family’s cars and remotes. Luckily, I installed a my-q chamberlain device that allows me to open the garage with my phone. While this works, it’s a hassle to open the garage via the app (Usually takes around 30 seconds). After learning about Siri Shortcuts, I figured out a way to open and close it much quickly and safer.

The Idea

Using the run commands over SSH shortcut, you can execute a python file which opens/closes your garage door. The outline of the script will look something like this:

  • Turn off WiFi (just to make sure you have a good connection and aren’t on a weak connection)
  • Run script
  • Turn on WiFi
  • Say the garage door was opened/closed

Getting Started

You will need the following:

  • An iPhone with iOS12+
  • A Raspberry Pi (Zero works as well) or a small Linux VM
  • Already installed MY-Q device

Setting up the server

Run the following commands: sudo apt-get update && sudo apt-get upgrade -y sudo apt-get install python3-pip git clone https://github.com/arraylabs/pymyq.git pip3 install pymyq

From here, you can use the example.py file located in the cloned repository. Add in your username and password and try running it. Once it works, you can modify the file to do whatever you want. In my case, I just have a simple open/close function, but you could get creative.

I won’t go into securing your server, but you need to make sure you do. Something I considered doing was implementing port knocking, but there are a few challenges with that (currently no good way to do that via shortcuts or external apps). There is a possibility it may work with Javascript in the browser, but that’s an extra step and will slow down the process

Network Configuration

There are only two things you need to do here. The first is opening up a port to access SSH. I set SSH to a different port and opened that, but you could get away with using the default 22. Once you do that, the next optional step is to set up DNS so that if you IP address changes, you won’t have issues. I recommend following the guide on duckdns.org

Once you do all of that, everything should work!