| Author |
Message |
|
jashaffner
Joined: Jan 14, 2007 Posts: 56
|
 Talk to Indigo via IChat on Leopard
Please feel free to throw in some ideas for this script for anyone who finds it convenient to talk to the house via IM.
You can just put script in /Library/Scripts/iChat/ and use it in iChat > Preferences > Alerts > Event: Message Received. I use separate IM account and leave it running 24/7 on machine running Indigo.
Ideas:
- get device's status
- ???
Enjoy!
- Code: Select all
using terms from application "iChat" -- handler to respond to all incoming messages. on runIndigoRemoteControl(theMessage) set theResponse to "Unknown command." try if theMessage is "flash" then tell application "IndigoServer" flash(2) end tell set theResponse to "Executing flash" else if theMessage is "bedtime" then tell application "IndigoServer" execute group "scene - bedtime" end tell set theResponse to "Executing bedtime scene" else if theMessage is "tail log" then tell application "IndigoServer" set theResponse to build event log list line count 30 end tell else if theMessage is "help" then -- display available commands on "help" set theResponse to "Available Commands: flash, bedtime, tail log, turn on/off [device], toggle [device], dim/brighten [device], all lights on/off, execute group [name], tail log, send email to [emailAddress] [with subject text] [with body text]" else tell application "IndigoServer" set result to (run script theMessage) as string end tell if result is "" then set theResponse to "Executing " & theMessage else set theResponse to result end if end if on error errorMessage set theResponse to errorMessage end try return theResponse end runIndigoRemoteControl -- When first message is received, accept the invitation and send a greeting message from Indigo Remote Control. on received text invitation theMessage from theBuddy for theChat accept theChat send "Welcome to Indigo Remote Control." to theChat set theResponse to runIndigoRemoteControl(theMessage) send theResponse to theChat end received text invitation -- On subsequent messages, pass the message directly to Indigo Remote Control. on message received theMessage from theBuddy for theChat set theResponse to runIndigoRemoteControl(theMessage) send theResponse to theChat end message received -- Sample, so you can test run this through Script Editor. display dialog "Send a command to Indigo Remote Control:" default answer "help" set theMessage to the text returned of the result set theResponse to runIndigoRemoteControl(theMessage) display dialog theResponse end using terms from
ps: borrowed a piece of code from script that came with iChat on Leopard for remote controlling iTunes.
|
| Tue Feb 26, 2008 7:17 pm |
|
 |
|
asw24b
Joined: Dec 30, 2007 Posts: 179 Location: Los Altos Hills, CA
|
 Re: Talk to Indigo via IChat on Leopard
I made one small change, which prevents anyone but me from from controlling things...
-- only allow connections from me for control -- put your name here
if the name of theBuddy is "myname@mac.com" then
accept theChat
send "Welcome to Indigo Remote Control." to theChat
set theResponse to runIndigoRemoteControl(theMessage)
send theResponse to theChat
else
log "Someone bogus tried to connect to us"
send "Bye" to theChat
decline theChat
end if
|
| Wed Feb 27, 2008 10:41 pm |
|
 |
|
jashaffner
Joined: Jan 14, 2007 Posts: 56
|
yea, I thought about restricting to certain users (ie: wife and myself) via applescript but figured that I could just use iChat's privacy level which is set to allow people only in buddylist.
|
| Thu Feb 28, 2008 8:55 am |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11692 Location: Texas
|
Great script idea -- thanks for sharing!
Matt
|
| Thu Feb 28, 2008 10:54 am |
|
 |
|
mreyn2005
Joined: Oct 06, 2006 Posts: 60
|
 random thought
It would be neat if one could incorporate an AIML bot application... Then your indigo mac could talk back! I know there are some python AIML implementations...
Matthew
|
| Thu Mar 20, 2008 10:20 pm |
|
 |
|
gregjsmith
Joined: Apr 01, 2003 Posts: 823 Location: Rio Rancho, NM
|
I've been testing ichat scripting. I found one problem, when ichat looses it's connection a bunch of dialogs pop up. You can't get rid of them without human interaction. I'm going to try this as a replacement.
http://www.macupdate.com/info.php/id/21 ... -scripting
_________________ Greg In The Desert
|
| Sun Apr 27, 2008 4:55 pm |
|
 |
|
mreyn2005
Joined: Oct 06, 2006 Posts: 60
|
gregjsmith wrote:I've been testing ichat scripting. I found one problem, when ichat looses it's connection a bunch of dialogs pop up. You can't get rid of them without human interaction. I'm going to try this as a replacement. http://www.macupdate.com/info.php/id/21 ... -scripting
the website says there is a charge for each SMS message sent?
|
| Sun Apr 27, 2008 6:18 pm |
|
 |
|
gregjsmith
Joined: Apr 01, 2003 Posts: 823 Location: Rio Rancho, NM
|
It appears you have to sign up for their SMS service. 
_________________ Greg In The Desert
|
| Sun Apr 27, 2008 7:42 pm |
|
 |
|
jnscolo
Joined: Oct 25, 2005 Posts: 10
|
Help. I copied and used this script (after commenting out the test stub at the bottom.) It works great, except, it only responds on the second inbound message (and subsequent,) not the first. No matter what I've tried, I can't get it to respond to the initial message. Anybody have any suggestions?
|
| Sun Feb 22, 2009 3:27 pm |
|
 |
|
jmesberg
Joined: Mar 24, 2006 Posts: 48 Location: Ann Arbor, MI
|
 Re: Talk to Indigo via IChat on Leopard
I realize this is a pretty old & stale thread, but I just started playing around with controlling Indigo through iChat and found that these scripts didn't quite work for me. The biggest problem was that the threads assumed that you'd be using an AIM or iChat account that was dedicated to home control. I don't think that's practical so I reworked the script to first assess whether the user is attempting to have a normal chat, or trying to control devices in the home, I also fixed the other problem that member jnscolo describes below. It requires two scripts, one that you attach to the Text Invitation event, and the other that you attach to the Message Received event (as described in this thread you attach these in the Alerts pane of the iChat preferences panel). Here is the Text Invitation event script: - Code: Select all
using terms from application "iChat" global AttemptingControl local theResponse set AttemptingControl to false set theResponse to "" on received text invitation theMessage from theBuddy for theChat accept theChat -- run parser. set theResponse to runAction(theMessage) -- determine if theBuddy is attempting Home Control if AttemptingControl is true then -- send back the response. send theResponse to theChat -- initiate Indigo action tell application "IndigoServer" execute group theResponse end tell end if end received text invitation on runAction(theMessage) set theResponse to "" set AttemptingControl to false if theMessage is "Entrance Lights on" then set AttemptingControl to true set theResponse to "Entrance Lights On" else if theMessage is "Heater On" then set AttemptingControl to true set theResponse to "Downstairs Heater On" else if theMessage is "help" then set AttemptingControl to true -- display available commands on "help" set theResponse to "Available commands: Entrance Lights On, Heater On" end if return theResponse end runAction end using terms from ...and here is the Message Received event script: - Code: Select all
using terms from application "iChat" global AttemptingControl local theResponse set AttemptingControl to false set theResponse to "" on message received theMessage from theBuddy for theChat -- run parser. set theResponse to runAction(theMessage) -- send back the response. send theResponse to theChat -- initiate Indigo action tell application "IndigoServer" execute group theResponse end tell end message received on runAction(theMessage) set theResponse to "" set AttemptingControl to false if theMessage is "Entrance Lights on" then set theResponse to "Entrance Lights On" set AttemptingControl to true else if theMessage is "Heater On" then set theResponse to "Downstairs Heater On" set AttemptingControl to true else if theMessage is "help" then -- display available commands on "help" set theResponse to "Available commands: Entrance Lights On, Heater On" set AttemptingControl to true end if return theResponse end runAction end using terms from
I am not an experienced programmer so I'm sure there is probably a more elegant way to solve these problems, but these work for me and perhaps can help someone else out there. John
|
| Mon Jan 03, 2011 7:10 pm |
|
 |
|
jmesberg
Joined: Mar 24, 2006 Posts: 48 Location: Ann Arbor, MI
|
 Re: Talk to Indigo via IChat on Leopard
apologies for the formatting above. I tried to use the Code block html formatting offered by the forum, but clearly not using it correctly. I hope to be posting some more applescripts soon, can someone tell me the right way to post code?
|
| Mon Jan 03, 2011 7:12 pm |
|
 |
|
macpro
Joined: Dec 29, 2005 Posts: 585 Location: Third byte on the right
|
 Re: Talk to Indigo via IChat on Leopard
Just look at the last line of your code. You have just /code] instead of [/code].
_________________ "I tawt I taw a puddy tat!" Tweety
|
| Tue Jan 04, 2011 12:19 am |
|
 |
|
jmesberg
Joined: Mar 24, 2006 Posts: 48 Location: Ann Arbor, MI
|
 Re: Talk to Indigo via IChat on Leopard
Thank you. Reposted here properly: ***************************************************** I realize this is a pretty old & stale thread, but I just started playing around with controlling Indigo through iChat and found that these scripts didn't quite work for me. The biggest problem was that the threads assumed that you'd be using an AIM or iChat account that was dedicated to home control. I don't think that's practical so I reworked the script to first assess whether the user is attempting to have a normal chat, or trying to control devices in the home, I also fixed the other problem that member jnscolo describes below. It requires two scripts, one that you attach to the Text Invitation event, and the other that you attach to the Message Received event (as described in this thread you attach these in the Alerts pane of the iChat preferences panel). Here is the Text Invitation event script: - Code: Select all
using terms from application "iChat"
global AttemptingControl local theResponse set AttemptingControl to false set theResponse to ""
on received text invitation theMessage from theBuddy for theChat accept theChat -- run parser. set theResponse to runAction(theMessage) -- determine if theBuddy is attempting Home Control if AttemptingControl is true then -- send back the response. send theResponse to theChat -- initiate Indigo action tell application "IndigoServer" execute group theResponse end tell end if
end received text invitation
on runAction(theMessage)
set theResponse to "" set AttemptingControl to false
if theMessage is "Entrance Lights on" then set AttemptingControl to true set theResponse to "Entrance Lights On"
else if theMessage is "Heater On" then set AttemptingControl to true set theResponse to "Downstairs Heater On"
else if theMessage is "help" then set AttemptingControl to true -- display available commands on "help" set theResponse to "Available commands: Entrance Lights On, Heater On"
end if
return theResponse
end runAction
end using terms from
...and here is the Message Received event script: - Code: Select all
using terms from application "iChat" global AttemptingControl local theResponse set AttemptingControl to false set theResponse to ""
on message received theMessage from theBuddy for theChat -- run parser. set theResponse to runAction(theMessage)
-- send back the response. send theResponse to theChat -- initiate Indigo action tell application "IndigoServer" execute group theResponse end tell
end message received
on runAction(theMessage)
set theResponse to "" set AttemptingControl to false
if theMessage is "Entrance Lights on" then
set theResponse to "Entrance Lights On" set AttemptingControl to true
else if theMessage is "Heater On" then set theResponse to "Downstairs Heater On" set AttemptingControl to true
else if theMessage is "help" then
-- display available commands on "help" set theResponse to "Available commands: Entrance Lights On, Heater On" set AttemptingControl to true
end if
return theResponse
end runAction
end using terms from
I am not an experienced programmer so I'm sure there is probably a more elegant way to solve these problems, but these work for me and perhaps can help someone else out there. John
|
| Tue Jan 04, 2011 7:27 am |
|
 |
|
chrisla23
Joined: Sep 16, 2009 Posts: 95
|
 Re: Talk to Indigo via IChat on Leopard
Does the script originally posted work? It seems to me the on/off does not as the name of the device needs to be quoted ie: - Code: Select all
turn off "bedroom lights"
It does not seem to work either way. It seems fine if I hard code in the commands per device like the later versions do, but essentially passing applescript thru as the first one appears to try to do in its final else fails. Am I missing something? Obviously the first way is nice as it's simpler and does not need to be modified each time new devices are added.
|
| Mon Mar 28, 2011 2:50 pm |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11692 Location: Texas
|
 Re: Talk to Indigo via IChat on Leopard
I'm not seeing "turn off" anywhere in the scripts posted above. Can you specify which script you are trying to to use exactly?
_________________
|
| Wed Mar 30, 2011 6:49 am |
|
|