Page 1 of 1
Is This Convertible?
Posted:
Fri Nov 29, 2019 4:09 pm
by ckeyes888
Hey,
I use a phone app called Dialectic to trigger actions in Indigo using an AS that is executed on an incoming call.
- Code: Select all
(*
This script will turn on a device controlled by Indigo when an incoming call is detected.
For more information on Indigo, please see:
http://www.perceptiveautomation.com/
If you don't adjust the device_name property at the top o the script, you will be prompted for the
device to turn on each time the script is triggered.
*)
on handle_incoming_call_action(contact_name, contact_number, phone_or_modem_name)
try
tell application "IndigoServer"
# Log the number so we can see what it is
log "call from " & (contact_number as string)
log "call from " & (contact_name as string)
set the value of variable "CIDname" to (contact_name as string)
set longPhoneNumber to contact_number
set AppleScript's text item delimiters to "-"
set shortPhoneNumber to (text items 2 thru -1 of longPhoneNumber) as text
set the value of variable "CIDnumber" to shortPhoneNumber
end tell
on error the_error
activate
display dialog "Error: " & the_error buttons {"OK"} default button 1 with icon 0 giving up after 20
end try
end handle_incoming_call_action
Can this be converted and possibly executed as an Automator app? Dialectic will only run an AS or launch an app on an incoming call.
Really appreciate any ideas.
Thanks,
Carl
Re: Is This Convertible?
Posted:
Sat Nov 30, 2019 8:54 am
by howartp
It could be converted to an external python script that targets Indigo, but does Dialetic pass phone number etc to the external app/script like it does AS?
Sent from my iPhone using Tapatalk Pro
Re: Is This Convertible?
Posted:
Sat Nov 30, 2019 3:55 pm
by matt (support)
Take a look at the
Indigo Control AppleScript. We made it for cases like this where you really need AppleScript to be able to communicate to Indigo Server running on the same Mac.
Once you copy/paste the
contents of IndigoControl.applescript into the top of the script, you should be able to modify it like this to update the variables in Indigo:
- Code: Select all
on handle_incoming_call_action(contact_name, contact_number, phone_or_modem_name)
try
set longPhoneNumber to contact_number
set AppleScript's text item delimiters to "-"
set shortPhoneNumber to (text items 2 thru -1 of longPhoneNumber) as text
updateVariable_byName("CIDname", (contact_name as string))
updateVariable_byName("CIDnumber", shortPhoneNumber)
on error the_error
activate
display dialog "Error: " & the_error buttons {"OK"} default button 1 with icon 0 giving up after 20
end try
end handle_incoming_call_action
Note I had to remove the Indigo log calls since there isn't a handler for that defined in
IndigoControl.applescript. If you really want that logged in Indigo you could create Triggers in Indigo on variable value changed to catch when the values update then have the action in that Trigger log the current value.
Re: Is This Convertible?
Posted:
Sat Nov 30, 2019 4:13 pm
by howartp
Ps - looks like the .applescript filecheck stops at iph72...
Sent from my iPad using Tapatalk Pro
Re: Is This Convertible?
Posted:
Sat Nov 30, 2019 4:16 pm
by matt (support)
Newer than that and the /usr/local/indigo/indigo-host file should exist (which is checked first).
Re: Is This Convertible?
Posted:
Sat Nov 30, 2019 4:44 pm
by howartp
Ah!
Sent from my iPad using Tapatalk Pro
Re: Is This Convertible?
Posted:
Sun Dec 01, 2019 4:15 pm
by ckeyes888
Thanks! Look forward to trying it out.
Carl
Re: Is This Convertible?
Posted:
Mon Dec 02, 2019 7:15 pm
by ckeyes888
Lost here in how the script gets put together.
- Code: Select all
(*
This script will turn on a device controlled by Indigo when an incoming call is detected.
For more information on Indigo, please see:
http://www.perceptiveautomation.com/
If you don't adjust the device_name property at the top o the script, you will be prompted for the
device to turn on each time the script is triggered.
*)
-- Internal functions for dispatching commands to Indigo's python scripting engine:
on _getIphPath()
set iph to "/usr/local/indigo/indigo-host"
set iph72 to "/Library/Application Support/Perceptive Automation/Indigo 7.2/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost"
set iph7 to "/Library/Application Support/Perceptive Automation/Indigo 7/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost"
set iph6 to "/Library/Application Support/Perceptive Automation/Indigo 6/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost"
set iph5 to "/Library/Application Support/Perceptive Automation/Indigo 5/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost"
tell application "System Events"
if exists file iph then
return iph
else if exists file iph72 then
return iph72
else if exists file iph7 then
return iph7
else if exists file iph6 then
return iph6
else if exists file iph5 then
return iph5
else
error "Indigo Server not installed"
end if
end tell
end _getIphPath
on _executeIphCommand(command)
set iphPath to _getIphPath()
do shell script quoted form of iphPath & " -e " & quoted form of command
end _executeIphCommand
on handle_incoming_call_action(contact_name, contact_number, phone_or_modem_name)
try
set longPhoneNumber to contact_number
set AppleScript's text item delimiters to "-"
set shortPhoneNumber to (text items 2 thru -1 of longPhoneNumber) as text
updateVariable_byName("CIDname", (contact_name as string))
updateVariable_byName("CIDnumber", shortPhoneNumber)
on error the_error
activate
display dialog "Error: " & the_error buttons {"OK"} default button 1 with icon 0 giving up after 20
end try
end handle_incoming_call_action
This attempt won't compile...doesn't like the "end tell" in the top section.
Appreciate any help,
Carl
Re: Is This Convertible?
Posted:
Tue Dec 03, 2019 10:44 am
by matt (support)
Hi Carl,
Sorry, looks like there was a syntax problem with the if/else clause up there. I've corrected both the version in github as well as what you posted above, so if you just try copy/pasting out of your post into the script I think it will work.
Re: Is This Convertible?
Posted:
Tue Dec 03, 2019 1:49 pm
by ckeyes888
The script now seems to be running but am getting this error.
Thanks,
Carl
Re: Is This Convertible?
Posted:
Tue Dec 03, 2019 2:15 pm
by matt (support)
Looks like you didn't copy the entire contents of the IndigoControl.appleScript file into your script. If you are just updating variables you don't have to get it all, but be sure and get the updateVariable_by* functions.
Re: Is This Convertible?
Posted:
Tue Dec 03, 2019 8:17 pm
by ckeyes888
Doh...that was it. Working great!
Many thanks,
Carl