## Save this as an applescript application with the “always open” checkbox checked. (This may be slightly different depending on your version of Mac OS.)
on idle
tell application “Finder”
set isConnected to disk “share” exists — this checks to see if “share” exists (mounted) then sets a true/false value to the variable “isConnected”.
end tell
if isConnected = false then — this checks variable “isConnected” and if “false” then it tries to mount the volume given the server name (or ip address).
try
mount volume “share” on server “rpi”
end try
end if
return 30 — this repeats the loop every 30 seconds; this value can be increased/decreased.
end idle
EPS - Mac Commander ### PLEASE WAIT WHILE YOUR DATABASE IS EXAMINED FOR EMBEDDED APPLESCRIPT, THIS MAY TAKE A MOMENT ###
EPS - Mac Commander
The following items have an embedded AppleScript:
Action Group: CALIBRATE Back Drapes
Action Group: CALIBRATE Side Drapes
Action Group: ONE SECOND - Side
Action Group: ONE SECOND - Back
Action Group: CALIBRATE Bedroom Drapes
Action Group: ONE SECOND - Master Bedroom
Action Group: New Appt
Action Group: ical test
Action Group: Todays Appointments
Action Group: Tomorrows Appointments
Action Group: Office - Toggle Torchiere
Action Group: Office - Toggle Desk
Action Group: Basement - Toggle Theater
Action Group: Basement - Toggle Sitting Area
Action Group: Stop Plex
Action Group: Start Plex
Action Group: Basement Toggle
Action Group: Basement Check
Action Group: Greatroom Check
Action Group: Greatroom Toggle
Action Group: Start Plex Main
Action Group: Stop Plex Main
Action Group: Master Bedroom sync to KPL's
Action Group: Purge Plex File Cache
Action Group: Stop Plex Main Client
Action Group: Start Plex Main Client
Action Group: Kodi - Start
Action Group: Kodi - Stop
Action Group: couchPotato - Start
Action Group: couchPotato - Stop
Action Group: Side Drapes - Close copy
Action Group: Side Drapes - Half copy
Action Group: Side Drapes - Open copy
Action Group: Side Drapes - Toggle copy
Action Group: Back Drapes - Close copy
Action Group: Back Drapes - Half copy
Action Group: Back Drapes - Open copy
Action Group: Back Drapes - Toggle copy
Action Group: Bedrom Drapes - Half copy
Action Group: Bedroom Drapes - Close copy
Action Group: Bedroom Drapes - Open copy
Schedule: Daily - Connect Airfoil Speakers
Trigger: Greatroom KPL sync to Other KPL's
Trigger: Greatroom Sectional sync to KPL's
Trigger: Greatroom Wolf Lamp sync to KPL's
Trigger: Master Bedroom Bed Button 2 On (ALL OFF)
Trigger: Master Bedroom Bed Button 1 On (ALL ON)
Trigger: Bedroom Deck sync to KPL's
Trigger: Sectional Button 3 On (Table Lamp Brighten)
Trigger: Sectional Button 4 On (Table Lamp Dim)
Trigger: Sectional Button 8 On (Company)
Trigger: Side Drape State sync to KPL's (disabled)
Trigger: Sectional Button 7 Off (Movie Time)
Trigger: Bedroom Drape State sync to KPL's
Trigger: Bedroom Vanity Sync to KPL's
Trigger: Bedroom Entryway Sync to KPL's
Trigger: Bedroom (Armoir) sync to KPL's
Trigger: Away Button Turned On
Trigger: Back Drapes sync to KPL's
Trigger: Side Drape State sync to KPL's
tell application "iTunes"
activate
beep
set thePlaylist to (get view of front window)
set trackCount to (get index of last track of thePlaylist)
set newList to {}
repeat with i from 1 to trackCount
set newList to newList & (get location of track i of thePlaylist)
end repeat
repeat with i from length of newList to 1 by -1
set current_item to (random number from 1 to i)
tell newList
set temp to item i
set item i to item current_item
set item current_item to temp
end tell
end repeat
set oldPlaylist to (get name of thePlaylist as string)
delete thePlaylist
set ranPlaylist to (make new user playlist)
set name of ranPlaylist to oldPlaylist
repeat with i from 1 to (get count of newList)
try
add item i of newList to ranPlaylist
end try
end repeat
beep
display dialog "The playlist " & (get name of ranPlaylist as string) & " with " & trackCount & " tracks was randomized."
end tell
error "iTunes got an error: Can’t get location of track 1 of user playlist id 83267 of source id 67." number -1728 from location of track 1 of user playlist id 83267 of source id 67
zwavePlugin = indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.zwave")
zwavePlugin.executeAction("assignReturnRoute", deviceId=123456)
sendir,1:1,1,37993,1,1,342,170,22,63,22,21,22,21,22,21,22,21,22,21,22,21,22,63,22,21,22,63,22,63,22,21,22,21,22,63,22,63,22,21,22,63,22,21,22,21,22,21,22,21,22,21,22,21,22,63,22,21,22,63,22,63,22,63,22,63,22,63,22,63,22,21,22,1608,342,86,21,3651,342,86,21,3651,342,86,21,3651,342,86,21,3799”)
do shell script "
echo \"sendir,1:1,1,37993,1,1,342,170,22,63,22,21,22,21,22,21,22,21,22,21,22,21,22,63,22,21,22,63,22,63,22,21,22,21,22,63,22,63,22,21,22,63,22,21,22,21,22,21,22,21,22,21,22,21,22,63,22,21,22,63,22,63,22,63,22,63,22,63,22,63,22,21,22,1608,342,86,21,3651,342,86,21,3651,342,86,21,3651,342,86,21,3799\" | /usr/local/bin/ncat -C -i 1 192.168.0.126 4998"
do shell script "curl -f '
-o ~/Desktop/IPCam/1.jpg"
do shell script "curl -f 'http://URL.CGI Syntax for my new amcrest camera to get a snapshot .jpg file' -o ~/Desktop/IPCam/1.jpg"
(*
This script controls the Foscam R2 HD PTZ camera. It's pretty simple.
1. Create a variable name for each camera you want to use. In this example it is named "Camera1_Action". This will need to be changed for each camera you use, and you will also need to create a trigger for each camera so it will fire off the correct variable. Since you probably use the same username and password for every camera, just create "Camera_Password" and "Camera_User" variables and put your password and username in those.
2. Create a control page such that the buttons modify the variable "Camera1_Action"with the appropriate command variable when the button is pressed. note that you need to use the exact spelling for your names as are listed in the script.
3. Update this script for each of your cameras with correct IP address. Also update the various instances of "Camera1_Action" in the script with your variable's name. Could probably do this in a simpler fashion...
4. Create a trigger for each camera that fires when variable "Camera1_Action" (or your camera's name) changes, with this script as the action. It all should work!
5. Finally, due to timing issues with sticking an "x" in the variable to have it reset for repeated commands (e.g. left, left,left) the IR on/off commands require a separate URL send routine.
note that by following the schema below it should be easy to add new commands. If you do so, please update the script in this thread. Also it should be easy to modify this script for other camera brands.
created by Ham Williams August 2016
*)
using terms from application "IndigoServer"
tell application "IndigoServer"
set actionOrdered to value of variable "Camera1_Action" as string
--log actionOrdered
--Cardinal Directions. Automatically stops the directional movement via delayed command at the bottom.
set actionDirections to {"Left", "Right", "Up", "Down"}
if actionDirections contains actionOrdered is true then
set theAction to "ptzMove" & actionOrdered & "'"
--log theAction
--set value of variable "Camera1_Action" to "x"
end if
--zoom in, out. Automatically stops the zoom via delayed command at the bottom.
set actionZoom to {"zoomIn", "zoomOut", "zoomStop"}
if actionZoom contains actionOrdered is true then
set theAction to actionOrdered & "'"
--log theAction
--set value of variable "Camera1_Action" to "x"
end if
--Go to Preset.
set actionPreSet to {"TopMost", "RightMost", "LeftMost", "BottomMost", "WideView"}
--I added WideView. Modify the list to add your custom preset.
if actionPreSet contains actionOrdered is true then
set theAction to "ptzGotoPresetPoint&name=" & actionOrdered & "'"
--log theAction
--set value of variable "Camera1_Action" to "x"
end if
--Need to place all non-IR commands in this list so they will execute with proper timing.
set actionListAll to {"Left", "Right", "Up", "Down", "zoomIn", "zoomOut", "zoomStop", "TopMost", "RightMost", "LeftMost", "BottomMost", "WideView"}
if actionListAll contains actionOrdered is true then
--log actionOrdered & " the list works"
set theIP to "'http://XX.XX.XX.XXX:80/cgi-bin/CGIProxy.fcgi?" --change your ip and command string here
set thePW to the value of variable "Camera_Password"
set theUser to the value of variable "Camera_User"
set theURL to theIP & "usr=" & theUser & "&" & "pwd=" & thePW & "&cmd=" & theAction --rearrange the order of the username/password and command string if necessary for your camera.
--log theURL --comment this out once it is working
set curlURL to "curl -f" & " " & theURL
set shellscript to curlURL
--log shellscript -- commment this out once it is working
do shell script shellscript
set value of variable "Camera1_Action" to "x"
end if
--This is a distinct URL send for IR LED open and close. Otherwise it does not work correctly when run as an external script.
set actionIRonOff to {"openInfraLed", "closeInfraLed"}
if actionIRonOff contains actionOrdered is true then
set theAction_IR_Only to actionOrdered & "'"
--log theAction
set theIP to "'http://XX.XX.XX.XXX:80/cgi-bin/CGIProxy.fcgi?" --change your ip and command string here
set thePW to the value of variable "Camera_Password"
set theUser to the value of variable "Camera_User"
set theURL to theIP & "usr=" & theUser & "&" & "pwd=" & thePW & "&cmd=" & theAction_IR_Only --rearrange the order of the username/password and command string if necessary for your camera.
--log theURL --comment this out once it is working
set curlURL to "curl -f" & " " & theURL
set shellscript to curlURL
--log shellscript -- commment this out once it is working
do shell script shellscript
delay 2
set value of variable "Camera1_Action" to "x"
end if
--Send "stop" URL function for directions and zoom
delay 0.5
if actionDirections contains actionOrdered is true then
set theAction to "ptz" & "StopRun" & "'"
set theIP to "'http://XX.XX.XX.XXX:80/cgi-bin/CGIProxy.fcgi?" --change your ip and command string here
set thePW to the value of variable "Camera_Password"
set theUser to the value of variable "Camera_User"
set theURL to theIP & "usr=" & theUser & "&" & "pwd=" & thePW & "&cmd=" & theAction --rearrange the order of the username/password and command string if necessary for your camera.
--log theURL --comment this out once it is working
set curlURL to "curl -f" & " " & theURL
set shellscript to curlURL
set theAction to "ptzMove" & "Stop" & "'"
do shell script shellscript
set value of variable "Camera1_Action" to "x"
end if
if actionZoom contains actionOrdered is true then
set theAction to "zoomStop" & "'"
set theURL to theIP & "usr=" & theUser & "&" & "pwd=" & thePW & "&cmd=" & theAction --rearrange the order of the username/password and command string if necessary for your camera.
--log theURL --comment this out once it is working
set curlURL to "curl -f" & " " & theURL
set shellscript to curlURL
set theAction to "ptzMove" & "Stop" & "'"
do shell script shellscript
set value of variable "Camera1_Action" to "x"
end if
end tell
end using terms from
property connectionName : "DSC864"
tell application "IndigoServer"
if value of variable "DSC_Zones_Activity" contains "Porte" then
log "True path - variable value is: " & (value of variable "DSC_Zones_Activity")
-- tell application "Serial Bridge"
--send to source connectionName byte list {48, 51, 49, 49, 67, 53, 13, 10}
-- end tell
else
log "False path - variable value is: " & (value of variable "DSC_Zones_Activity")
-- tell application "Serial Bridge"
--send to source connectionName byte list {48, 51, 48, 49, 67, 52, 13, 10}
-- end tell
end if
end tell
property connectionName : "DSC864"
if value of variable "DSC_Zones_Activity" contains "Porte" then
tell application "Serial Bridge"
send to source connectionName byte list {48, 51, 49, 49, 67, 53, 13, 10}
end tell
else
tell application "Serial Bridge"
send to source connectionName byte list {48, 51, 48, 49, 67, 52, 13, 10}
end tell
end if
if the value of variable "DSC_Status" contains "stay" then
delay 75
if value of variable "DSC_Zones_Activity" contains "Porte" then
return true
else
return false
end if
else
return false
end if
if the value of variable "DSC_Zones_Activity" contains "Porte" then delay 75 and the value of variable "DSC_Status" contains "stay"
then
return true
else
return false
end if
if theMessage does not contain "IRC:" then
if (full name of theBuddy) as string is "xxx" or (full name of theBuddy) as string is "+xxx" then
set theResponse to runIndigoRemoteControl(theMessage)
-- send back the response.
send "IRC: " & theResponse to theChat
end if
end if
do shell script "curl -f 'http://10.0.6.181:8081/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=userid&pwd=password&resolution=32' -o ~/Desktop/new.jpg"
/cgi-bin/CGIProxy.fcgi?cmd=setSnapConfig&snapPicQuality=0
do shell script "curl -f 'http://10.0.6.181:8081/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=userid&pwd=password' -o ~/Desktop/new.jpg"
/cgi-bin/CGIProxy.fcgi?cmd=setSnapConfig&snapPicQuality=2
tell application "Finder"
set this_item to get selection
set myPath to POSIX path of (this_item as text)
end tell
tell application "Image Events"
set this_image to open myPath
scale this_image to size 500
save this_image in myPath
close this_image
end tell
do shell script "curl -f 'http://10.0.6.181:8081/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=userid&pwd=password' -o ~/Desktop/IPCamRotate/R.jpg"
do shell script "curl -f 'http://10.0.6.183:8083/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=userid&pwd=mypassword' -o ~/Desktop/IPCamRotate/R.jpg"
delay 2
do shell script "curl -f 'http://10.0.6.181:8081/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=userid&pwd=mypassword' -o ~/Desktop/IPCamRotate/R.jpg"
delay 2
do shell script "curl -f 'http://10.0.6.183:8083/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=userid&pwd=mypassword' -o ~/Desktop/IPCamRotate/R.jpg"
set dFolder to "~/Desktop/IPCam/"
do shell script "mkdir -p " & dFolder
do shell script "curl -f 'http://10.0.6.181:8081/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=username&pwd=password' -o ~/Desktop/IPCam/1.jpg"
delay 2
tell application "Finder"
set folderPath to folder "Macintosh HD:Users:williammoore:Desktop:IPCam"
set theFile to first file in folderPath as alias
set fileName to name of theFile
end tell
set theAttachment1 to theFile
tell application "Messages"
send theAttachment1 to buddy "myname@gmail.com" of (service 1 whose service type is iMessage)
send theAttachment1 to buddy "mywife@gmail.com" of (service 1 whose service type is iMessage)
end tell
delay 2
tell application "Finder"
delete folder "IPCam"
end tell
set dFolder to "~/Desktop/IPCam/"
do shell script "mkdir -p " & dFolder
do shell script "curl -f 'http://10.0.6.181:8081/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=username&pwd=password' -o ~/Desktop/IPCam/1.jpg"
delay 2
tell application "Finder"
set folderPath to folder "Macintosh HD:Users:williammoore:Desktop:IPCam"
set theFile to first file in folderPath as alias
set fileName to name of theFile
end tell
set theAttachment1 to theFile
tell application "Mail"
set addressList to {"myhome@gmail.com", "mywork@hq.dhs.gov","wifehome@gmail.com"}
set nameList to {"billgmail", "millwork","wifehome"}
set newMessage to make new outgoing message with properties {subject:"Front Door", content:"Attached Image" & return & return}
tell newMessage
set visible to false
set sender to "myaccount@gmail.com"
repeat with i from 1 to count nameList
make new to recipient at end of to recipients with properties {name:item i of nameList, address:item i of addressList}
end repeat
make new attachment with properties {file name:theAttachment1} at after the last paragraph
send --<<<<---------------- change save to send to send
(* change save to send to send*)
end tell
end tell
delay 2
tell application "Finder"
delete folder "IPCam"
end tell
set recipientName to "YourName"
set recipientAddress to "youraddress@yourmailprovider.com"
set theSubject to "IP Address Changed"
set newIPAddress to word 25 of (do shell script "/usr/bin/curl checkip.dyndns.org")
if the value of variable "IPAddress" is not equal to newIPAddress then
set the value of variable "IPAddress" to newIPAddress
tell application "Mail"
##Create the message
set theMessage to make new outgoing message with properties {subject:theSubject, content: newIPAddress, visible:true}
##Set a recipient
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
##Send the Message
send
end tell
end tell
end if
(*
File: Messages Indigo Control.scpt
Abstract: This script is based on the iTunes Remote Control script which demonstrates the AppleScript "Message Received" handler for Messages. It will parse incoming messages and control Indigo in response.
Version: .1
*)
using terms from application "Messages"
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
on CapitalizeFirstLetter_ofEveryWord(InputString)
set TheString to do shell script "echo " & InputString & " | tr '[A-Z]' '[a-z]'"
set wordsofTheString to words of TheString as list
set TotalCount to count of wordsofTheString
set theCount to 1
repeat until theCount is greater than TotalCount
set theWord to item theCount of wordsofTheString
set theChars to characters of theWord as list
set Capital to item 1 of theChars
set item 1 of theChars to do shell script "echo " & Capital & " | tr '[a-z]' '[A-Z]'"
if theCount is less than TotalCount then
set theWord to (theChars as string) & " "
else
set theWord to (theChars as string)
end if
set item theCount of wordsofTheString to theWord
set theCount to theCount + 1
end repeat
set TheString to wordsofTheString as string
return TheString
end CapitalizeFirstLetter_ofEveryWord
on trim_line(this_text, trim_chars, trim_indicator)
-- 0 = beginning, 1 = end, 2 = both
set x to the length of the trim_chars
-- TRIM BEGINNING
if the trim_indicator is in {0, 2} then
repeat while this_text begins with the trim_chars
try
set this_text to characters (x + 1) thru -1 of this_text as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
end if
-- TRIM ENDING
if the trim_indicator is in {1, 2} then
repeat while this_text ends with the trim_chars
try
set this_text to characters 1 thru -(x + 1) of this_text as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
end if
return this_text
end trim_line
on getIndigoVariable(IndigoVariable)
tell application "IndigoServer"
set theVariableValue to get value of variable IndigoVariable
end tell
return theVariableValue
end getIndigoVariable
on setIndigoVariable(IndigoVariable, VariableValue)
tell application "IndigoServer"
set value of variable IndigoVariable to VariableValue
set theVariableValue to get value of variable IndigoVariable
end tell
return "Variable set to " & theVariableValue
end setIndigoVariable
on executeIndigoAction(IndigoAction)
tell application "IndigoServer"
execute group IndigoAction
end tell
return "Action " & IndigoAction & " Executed"
end executeIndigoAction
on turnonIndigoDevice(IndigoDevice)
try
tell application "IndigoServer"
turn on IndigoDevice
end tell
return IndigoDevice & " was told to turn on"
on error
return "error turning on " & IndigoDevice
end try
end turnonIndigoDevice
on turnoffIndigoDevice(IndigoDevice)
try
tell application "IndigoServer"
turn off IndigoDevice
end tell
return IndigoDevice & " was told to turn off"
on error
return "error turning off " & IndigoDevice
end try
end turnoffIndigoDevice
-- handler to respond to all incoming messages.
on runIndigoRemoteControl(theMessage)
try
-- use default "unknown" command, just in case.
set theResponse to "Unknown command."
set theMessage to trim_line(theMessage, "to ", 0)
set theMessage to replace_chars(theMessage, "the ", "")
if theMessage contains "status" then
set theResponse to "Alive and Well!"
else if theMessage is "arm alarm" then
set theResponse to setIndigoVariable("AlarmArmed", "true")
else if theMessage is "disarm alarm" then
set theResponse to setIndigoVariable("AlarmArmed", "false")
else if theMessage contains "raise heat" or theMessage contains "lower AC" or theMessage contains "raise temperature" then
set theResponse to executeIndigoAction("Thermostat Higher")
else if theMessage contains "lower heat" or theMessage contains "raise AC" or theMessage contains "lower temperature" then
set theResponse to executeIndigoAction("Thermostat Lower")
else if theMessage starts with "turn on" then
set targetDevice to CapitalizeFirstLetter_ofEveryWord(trim_line(theMessage, "turn on ", 0))
set theResponse to turnonIndigoDevice(targetDevice)
else if theMessage starts with "turn off" then
set targetDevice to CapitalizeFirstLetter_ofEveryWord(trim_line(theMessage, "turn off ", 0))
set theResponse to turnoffIndigoDevice(targetDevice)
else if theMessage starts with "execute" then
set targetAction to trim_line(theMessage, "execute ", 0)
set targetAction to trim_line(targetAction, "action ", 0)
set targetAction to trim_line(targetAction, "group ", 0)
set targetAction to CapitalizeFirstLetter_ofEveryWord(targetAction)
set theResponse to executeIndigoAction(targetAction)
else if theMessage is "help" then
-- display available commands on "help"
set theResponse to "Available commands: status, Turn on or off device, Raise or lower temperature, Arm or disarm alarm, Execute action"
end if
return theResponse
on error
return "Error processing message " & theMessage
end try
end runIndigoRemoteControl
-- When first message is received, accept the invitation and send a greeting message from iTunes Remote Control.
on received text invitation theMessage from theBuddy for theChat
if full name of theBuddy is "Matthew A. Morgano" or full name of theBuddy is "Matthew A. Morgano" then
accept theChat
end if
send "Welcome to Indigo Remote Control. " & runIndigoRemoteControl("help") to theChat
end received text invitation
-- On subsequent messages, pass the message directly to iTunes Remote Control.
on message received theMessage from theBuddy for theChat
if full name of theBuddy is "Change Name here" or full name of theBuddy is "Change Name Here" then
set theResponse to runIndigoRemoteControl(theMessage)
-- send back the response.
send theResponse to theChat
end if
end message received
--locally test commands
display dialog "Send a command to Indigo Remote Control:" default answer "status"
set theMessage to the text returned of the result
set theResponse to runIndigoRemoteControl(theMessage)
display dialog theResponse
# The following are unused but need to be defined to avoid an error
on received audio invitation theText from theBuddy for theChat
end received audio invitation
on received video invitation theText from theBuddy for theChat
end received video invitation
on received remote screen sharing invitation from theBuddy for theChat
end received remote screen sharing invitation
on received local screen sharing invitation from theBuddy for theChat
end received local screen sharing invitation
on received file transfer invitation theFileTransfer
end received file transfer invitation
on buddy authorization requested theRequest
end buddy authorization requested
on message sent theMessage for theChat
end message sent
on chat room message received theMessage from theBuddy for theChat
end chat room message received
on active chat message received theMessage
end active chat message received
on addressed chat room message received theMessage from theBuddy for theChat
end addressed chat room message received
on addressed message received theMessage from theBuddy for theChat
end addressed message received
on av chat started
end av chat started
on av chat ended
end av chat ended
on login finished for theService
end login finished
on logout finished for theService
end logout finished
on buddy became available theBuddy
end buddy became available
on buddy became unavailable theBuddy
end buddy became unavailable
on completed file transfer
end completed file transfer
end using terms from
on av chat started
end av chat started
tell application "IndigoServer"
# Add 3 days to the current date. The add operator expects seconds so multiply it out.
set nextExecutionTime to current date + (3 * (60 * 60 * 24))
# Set the trigger time to that value
set absolute trigger time of time date action "XYZ" to nextExecutionTime
end tell