Page 1
Standard

HowTo SiriControl with Raspberry Pi 3

We can use Siri for a lot of things on our Apple device, but you can also use Siri to control IoT things that dont have support for HomeKit! This can be done by using SiriControl! SiriControl is a Python script that runs on your Raspberry and polls your Gmail account for newly created notes.

Notes? How does it work?

You can use Siri to make notes for you, and we can also use Gmail to store the notes. Now we have Siri that can store commands on a Cloud Based system like Gmail. As Gmail is IMAP aware we can use a python script to read the notes. This is the basic of SiriControl.

How to…

Below the steps you need to take to setup SiriControl on your Raspberry and the requirements for you Gmail account.

Create a Gmail account

Lets start with creating a Gmail account. Due to security reasons I recommend to use a new Gmail account because you have to enter your e-mail address and password in a Phyton script (yes unencrypted ūüôĀ ).

After creating make sure you do the following:

  1. Enable Less Secure Apps for you newly created account
  2. Enable IMAP in your settings so your iOS device can push the Notes

Add Gmail to your iOS device

Now we have created a Gmail account, we have to make sure that if we tell Siri to make a note for our command it gets send to Gmail. So grab your¬†iOS device and go to:¬†Settings –> Notes –> Accounts –> Add Account and create a new Google account on your device. Make sure it only Syncs the Notes! After creating the account set this account as Default Notes account in your iOS device under¬†Settings –> Notes.

Now the fun part begins!

Get your Raspberry Pi up and running!

Now we have to configure the Python script to run on the Raspberry Pi. Follow below steps.

  1. Make sure python is installed
  2. Copy the files from Github https://github.com/theraspberryguy/SiriControl-System to your Raspberry
    1. Don’t forget to also copy the modules folder and the included files!
  3. Modify siricontrol.py to include your Gmail account credentials
  4. Run the script!
    # python siricontrol.py

It will now run in your SSH session, you can run this also by Cronjob in the background for example on boot.

What did I do with SiriControl? (some ideas)

As I’m using Kodi (LibreElec) in my home for watching movies / photos / listening music from my NAS and Kodi on Raspberry i would like to update the library as needed and not auto every x hours because I might be watching a movie and slowing down the performance or whatever. Now Python as a library for XBMC, called xbmc-json.

Also I’m trying to figure out if I can connect Volumio some way. Because Volumio has an App for iOS it should be possible as the system is receiving commands through some interface. Just have to figure out how this works so I can build a module for this.

Kodi and python

First of all we need a library and then we can connecti with a remote kodi setup through json.

  1. Install xbmc-json (if you havent done yet)
    Run the following as root / or with sudo
    # pip install xbmc-json
  2. Create your own script for SiriControl and import the module with:
    from xbmcjson import XBMC
  3. Next make a connection to your Kodi system so you can start giving commands (change the IP to your Kodi systems IP)
    xbmc = XBMC(“http://192.168.1.11/jsonrpc”)
    If you are using authentication your can also pass it with http://<user>:<pass>@192.168.1.11/jsonrpc and if you are using a custom port like 8080 add :8080 to the end of the ip address.
  4. enter the commands, for example for scanning a VideoLibrary for new content
    xbmc.VideoLibrary.Scan()

Volumio and SiriControl

As volumio has a REST API you can call it by simple HTTP requests like play and stop. Also you can start a Playlist (you have to configure one before), but just calling this with the import subprocess and then subprocess.call wget <volumio.local/api/v1/?cmd=… you can start and control it by Siri!

https://volumio.github.io/docs/API/REST_API.html

Some usefull links:

https://www.cyberciti.biz/faq/python-execute-unix-linux-command-examples/

https://howchoo.com/g/zdi2zgq2mjb/how-to-use-siri-to-control-anything-from-iftt-to-custom-programs-and-devices

http://www.instructables.com/id/SiriControl-Add-Siri-Voice-Control-to-Any-Raspberr/

Standard

My Home Automation

While browsing on the interwebs I did find a great post about a MagicMirror by Michael Teeuw http://michaelteeuw.nl/. This gave me the cool idea to use my old iPad for my own Home Automation system.

As I moved to my new house in september 2015 I would like to automate as mutch as possible, just because it is funny and because i’m interested in those tech thingies.

With the Magic Mirror page as a base I started brainstoming what to do. After some weeks (yes i have to work on a daily base so this is an evening project) I have a funny system up and running from my Raspberry Pi B+ model.

The following support is now included in this webpage:
Based on MagicMirror

  • iCloud Agenda
  • Latest headlines from Nu.nl
  • Weather information

Additions to this system

  • Tech info about the RPi (voltage / temp / mhz)
  • Kodi (OpenElec) latest movies and 4 controls for scanning / playing files
  • E-mail Management (See if there are new mails)
  • Philips Hue management (manage my Hue lights

These functions are now included and maybe more to come. Still looking for some sensors about the temperature and humidity in my house, but this will be a project for later on.

Some screenshots

Home Screen RPi info Email info Kodi system Philips Hue