control indigo with siri voice commands

Posted on
Thu Mar 28, 2013 11:38 pm
dtich offline
Posts: 806
Joined: Sep 24, 2005

control indigo with siri voice commands

i ran across an ascript someone (steven sande) posted on tuaw--he was inspired by someone doing something similar--in effect it uses siri's ability to make a note from your voice commands and the cloud's habit of syncing those notes to your various computing devices to make a pretty useable voice command interface for various (basically anything scriptable) tasks.

i thought it was clever and to try to use it to interface with indigo... so, this script, when saved as a standalone app and running on a computer with the notes app set to sync with a cloud account (the same acct your iphone uses), will scan your notes for specifically named ones and when it's received it will send the corresponding command to indigo, and then delete the note (vice versa actually).

it's a bit silly, but you know what, it works. i did this in bed in the middle of the night, so it's just a rudimentary start, but it could be a workable interface if you don't mind saying 'make a note' to siri every time you give a command... :) the lag is dependent on your internet service and apple's server health, but in the first day i've seen basically a one or two second lag between command and action.

i scripted only a few commands so far, but it's easy enough to expand, as you'll see. thought i'd post it in case anyone's interested...

this script currently will do commands* for my house/setup, but a cursory look at the code will show how it works and that it's easily mod'able in seconds to work for your setup. i made the commands start with 'tell indigo' to ensure it wouldn't misinterpret any other kind of note i might write.

*
lights on/off
party macros on/off
tv on/off
itunes on/off
bedtime
etc..

have fun.

[note: i needed to make it standalone and run via remote machining because my server doesn't have notes or my cloud accounts enabled, but it could be used as a background script if your indigo server and notes are on the same machine...fwiw.)



Code: Select all
(*    

   SiriNotesListener2.0
   based on Siri Listener by Steven Sande
   mods by dtich  3.27.13
   
*)


on run
   -- just here to get things started...
end run


on idle
   
   tell application "Notes"
      if exists note "What apps are running" then
         delete note "What apps are running"
         tell application "Finder"
            set myRunningApps to name of every process whose visible is true
            tell application "Notes"
               if exists note "Running Apps:" then
                  delete note "Running Apps:"
               end if
               set noteTitle to "Running Apps:"
               set AppleScript's text item delimiters to ", "
               set appsList to myRunningApps as text
               make new note at folder "Notes" with properties {name:noteTitle, body:appsList}
            end tell
         end tell
         
      else if exists note "Shut down" then
         delete note "Shut down"
         tell application "Finder" to quit
      else if exists note "Go to sleep" then
         delete note "Go to sleep"
         tell application "Finder" to sleep
      else if exists note "Restart my mac" then
         delete note "Restart my mac"
         tell application "Finder" to restart
         
         
      else if exists note "tell indigo lights on" then
         delete note "tell indigo lights on"
         tell application "indigoserver" of machine "eppc://user:pass@192.168.0.10"
            execute group "lighting/living, den, guest - NORMAL (SCENE 3)"
         end tell
         
      else if exists note "tell indigo lights off" then
         delete note "tell indigo lights off"
         tell application "indigoserver" of machine "eppc://user:pass@192.168.0.10"
            execute group "lighting/all lights OFF"
         end tell
         
      else if exists note "tell indigo watch tv" then
         delete note "tell indigo watch tv"
         tell application "indigoserver" of machine "eppc://user:pass@192.168.0.10"
            execute group "av/watch tv"
         end tell
         
      else if exists note "tell indigo itunes" then
         delete note "tell indigo itunes"
         tell application "indigoserver" of machine "eppc://user:pass@192.168.0.10"
            execute group "av/itunes in lr"
         end tell
         
      else if exists note "tell indigo av off" then
         delete note "tell indigo av off"
         tell application "indigoserver" of machine "eppc://user:pass@192.168.0.10"
            execute group "av/regular OFF"
         end tell
         
      else if exists note "tell indigo party" then
         delete note "tell indigo party"
         tell application "indigoserver" of machine "eppc://user:pass@192.168.0.10"
            execute group "lighting/living, den, guest - PARTY (SCENE 4)"
         end tell
         
      else if exists note "tell indigo all off" then
         delete note "tell indigo all off"
         tell application "indigoserver" of machine "eppc://user:pass@192.168.0.10"
            execute group "lighting/all lights OFF"
         end tell
         
      else if exists note "tell indigo bedtime" then
         delete note "tell indigo bedtime"
         tell application "indigoserver" of machine "eppc://user:pass@192.168.0.10"
            execute group "bedtime routine guest LOGIC"
         end tell
         
      else if exists note "tell indigo fan" then
         delete note "tell indigo fan"
         tell application "indigoserver" of machine "eppc://user:pass@192.168.0.10"
            execute group "hvac/fan run for 10 mins"
         end tell
         
         
      end if
   end tell
   return 1
end idle

Posted on
Fri Mar 29, 2013 3:50 pm
matt (support) offline
Site Admin
User avatar
Posts: 21424
Joined: Jan 27, 2003
Location: Texas

Re: control indigo with siri voice commands

Hah -- great hack/technique. I'm impressed the lag is as low as a couple of seconds. Pretty cool.

Apple *really* needs to provide a Siri API. :-)

Image

Posted on
Sat Mar 30, 2013 1:27 am
dtich offline
Posts: 806
Joined: Sep 24, 2005

Re: control indigo with siri voice commands

i know, i was surprised at the reaction time too! and that's iPhone to cloud server, cloud server push to desktop, script run, desktop remote to server, indigo to plc/control units. pretty dang good.

amen on the siri api. losers. could be so useful. and how about desktop integration?

i would think this system will also work using dictation and the notes app, without siri. so you can voice control from the desktop. but, bypassing the notes app is the thing to do. i'm sure an interface for, say, simpletext, using a similar continuous scan routine, or better yet a full on command recorder simply scanning all input for indexed command phrases... seems very possible with existing api's... don't know.


edit: i mean textedit! d'oh, blast from the past...

Posted on
Sat Mar 30, 2013 1:35 am
dtich offline
Posts: 806
Joined: Sep 24, 2005

Re: control indigo with siri voice commands

just tried it via dictation through the notes app on my laptop, and indeed works fine, and mighty fast, barely finish speaking the command before it happens. very cool.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests