| Author |
Message |
|
nsheldon
Joined: Aug 09, 2010 Posts: 787 Location: CA
|
 How to Use AppleScript to Display Logs in Indigo Touch
Example: How to Use AppleScript and Time/Date Actions to Show Recent Logs in Indigo TouchThough this isn't as good as a built-in option to view recent log activity within the Indigo Touch app (and web interface), it does allow you to view the last 5 lines of the log (this is adjustable), updated every minute. Note that this will only work with Indigo Pro. Here's how to set it up. Create a new Time/Date Action within the Indigo 4 Pro client with the following parameters: Name: Update Recent Activity Variables Time/Date Trigger tab:
Time: Every 0 hours 1.00 minutes Date: Every 1 days Randomize by +/-: 0 minutes Starts on: (make sure the date here is the current date). CHECKED Suppress logging NOT CHECKED Auto delete after trigger Condition tab:
Upon trigger do actions Always Actions tab:
Type: Execute AppleScript Embedded
- Code: Select all
set the ActivityLog to do shell script "tail -5 \"/Library/Application Support/Perceptive Automation/Indigo 5/Logs/indigo_log.txt\"" set the TotalNumberOfLines to the count of paragraphs in the ActivityLog set the CurrentLine to 1 repeat while the CurrentLine is less than or equal to the TotalNumberOfLines set the TextOfTheCurrentLine to paragraph CurrentLine of the ActivityLog set the variableName to ("RecentActivity" & CurrentLine) as string if not (variable variableName exists) then make new variable with properties {name:variableName, value:TextOfTheCurrentLine} else set the value of the variable variableName to the TextOfTheCurrentLine end if set the CurrentLine to (the CurrentLine + 1) end repeat
NOT CHECKED Delay by ... minutes. If you want more than 5 lines, simply change the "-5" after the "tail" command on the first line of the AppleScript to the number of lines (and corresponding "RecentActivity#" variables) you want. Allow the trigger to run at least once (which should happen within a minute after clicking the OK button in the new Time/Date Action dialog). This will create a "RecentActivity#" variable for each of the lines of log data. You can then go into the Control Pages section and edit an existing page (or create a new one) and place a new Variable Value object for each line of the log anywhere you like on the page. The variables will be named "RecentActivity1" through "RecentActivity5" (or up to whatever number of lines you set above). NOTE that text does not wrap on control pages, so be sure your control page is wide enough to show all of each line.
|
| Tue Aug 10, 2010 8:40 pm |
|
 |
|
hamw
Joined: Mar 31, 2008 Posts: 777
|
 Re: How to Use AppleScript to Display Logs in Indigo Touch
That is very cool. Great idea.
|
| Fri Sep 03, 2010 12:38 pm |
|
 |
|
hamw
Joined: Mar 31, 2008 Posts: 777
|
 Re: How to Use AppleScript to Display Logs in Indigo Touch
This will get rid of the date stamp, which takes up a lot of room on the variable output. Change character start, currently at 12, to 20 or so if you want to get rid of the time too. - Code: Select all
set the ActivityLog to do shell script "tail -9 \"/Library/Application Support/Perceptive Automation/Indigo 6/Logs/indigo_log.txt\"" set the TotalNumberOfLines to the count of paragraphs in the ActivityLog set the CurrentLine to 1 repeat while the CurrentLine is less than or equal to the TotalNumberOfLines set stringTextOfTheCurrentLine to paragraph CurrentLine of the ActivityLog as string set TextOfTheCurrentLine to (characters 12 through -1 of stringTextOfTheCurrentLine as string) set the variableName to ("RecentActivity" & CurrentLine) as string if not (variable variableName exists) then make new variable with properties {name:variableName, value:TextOfTheCurrentLine} else set the value of the variable variableName to the TextOfTheCurrentLine end if set the CurrentLine to (the CurrentLine + 1) end repeat
edited for Indigo 6.
Last edited by hamw on Sun Jan 13, 2013 8:58 pm, edited 1 time in total.
|
| Sat Sep 04, 2010 10:00 am |
|
 |
|
nsheldon
Joined: Aug 09, 2010 Posts: 787 Location: CA
|
 Re: How to Use AppleScript to Display Logs in Indigo Touch
Nice modification, hamw. Very handy to not have the time stamps all the time.
|
| Mon Sep 06, 2010 7:22 pm |
|
 |
|
hamw
Joined: Mar 31, 2008 Posts: 777
|
 Re: How to Use AppleScript to Display Logs in Indigo Touch
The other thing I did was add a button to the top of the control page to execute the time date action so that the log would update immediately instead of having to wait a minute. - Code: Select all
execute time date action "Update Recent Activity Variables"
Oddly I am occasionally getting a bunch of colons in the spaces between numbers and words. A reboot of the server fixes it. Are you seeing the same thing?
|
| Sat Sep 11, 2010 6:40 am |
|
 |
|
hamw
Joined: Mar 31, 2008 Posts: 777
|
 Re: How to Use AppleScript to Display Logs in Indigo Touch
Here's an example:
1:1:::3:1:::4:0: :W:e:b:S:e:r:v:e:r: :I:n:d:i:g:o: :T:o:u:c:h: :c:l:i:e:n:t: :c:o:n:n:e:c:t:e:d: :f:r:o:m: :1:0:.:0:.:1:.:2:0:0
any thoughts as to why this would happen? Otherwise this is a great script.
|
| Sat Dec 18, 2010 10:55 am |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6848 Location: Austin, Texas
|
 Re: How to Use AppleScript to Display Logs in Indigo Touch
Add this line: - Code: Select all
set AppleScript's text item delimiters to ""
at the top of the script and see if that helps. The line that cuts out the date is reassembling the string by using text item replacements and you probably have another embedded script that periodically runs that's setting the delimiter to ":". That would cause what you're seeing. No guarantee but I suspect that's it.
_________________ Jay (Indigo Support)
|
| Sat Dec 18, 2010 11:20 am |
|
 |
|
hamw
Joined: Mar 31, 2008 Posts: 777
|
 Re: How to Use AppleScript to Display Logs in Indigo Touch
Right you are, Jay. In my script for setting a timer variable for a whole house alarm clock, the set text item delimiter is there. - Code: Select all
using terms from application "IndigoServer" set theCurrentDateTime to absolute trigger time of time date action "Radio WakeUP Actual WakeUp Time" set AppleScript's text item delimiters to ":" set theTargetTime to value of variable "RadioWakeUpDisplay" set hours of theCurrentDateTime to (text item 1 of theTargetTime) as number set minutes of theCurrentDateTime to (text item 2 of theTargetTime) as number set absolute trigger time of time date action "Radio WakeUP Actual WakeUp Time" to theCurrentDateTime set the value of the variable "RadioWakeUpEnabled" to "Yes, Actual Time" end using terms from
All fixed up!
|
| Sat Dec 18, 2010 2:18 pm |
|
 |
|
hamw
Joined: Mar 31, 2008 Posts: 777
|
 Re: How to Use AppleScript to Display Logs in Indigo Touch
If you have upgraded to Indigo 5,change the Indigo 4 in the first line to Indigo 5. Will work fine.
|
| Sun May 22, 2011 6:48 am |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11814 Location: Texas
|
 Re: How to Use AppleScript to Display Logs in Indigo Touch
I've updated the script in the original post with your suggestion. Thanks.
_________________
|
| Sun May 22, 2011 8:42 am |
|
|