script type="text/javascript"> jQuery(document).ready(function(){ jQuery("article.et_pb_post").each(function(){ jQuery(">a:first-child, .et_pb_image_container", this).insertAfter(jQuery(".post-meta", this)); }); });
Select Page

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/