Xytronix Temperature Module AppleScript

Posted on
Wed Jul 20, 2011 6:19 pm
pbmike offline
Posts: 6
Joined: Mar 17, 2010

Re: Xytronix Temperature Module AppleScript

Tried copying over "URL Access Scripting.app" from 10.6.X -- no dice, finds the App now, but still doesn't work.

Posted on
Wed Jul 20, 2011 7:57 pm
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

Re: Xytronix Temperature Module AppleScript

Oh, that does suck! :evil: Mike, sorry you had to discover that the hard way! Ditching "URL Access Scripting.app" is going to kill many useful scripts and I see no work-around for the moment (any ideas Jay?). I always wait a while before updating to the latest OS. I may never update to Lion if this isn't resolved since it renders much of my hardware & software unusable.

Mike, I guess you'll need to restore the appropriately named "Snow Leopard" to keep your Greenhouse cool for now!

Stay cool 8) ,

Chris

Posted on
Wed Jul 20, 2011 7:59 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Xytronix Temperature Module AppleScript

Agreed this is going to be a problem for multiple scripts. We are going to start looking for workarounds on this one tomorrow.

Image

Posted on
Wed Jul 20, 2011 11:21 pm
chrisla23 offline
Posts: 97
Joined: Sep 16, 2009

Re: Xytronix Temperature Module AppleScript

Been using one of these non-stop in the datacenter at work for about 5-6 years, great devices.

-Chris

Posted on
Wed Jul 20, 2011 11:59 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Xytronix Temperature Module AppleScript

How about using curl?

Posted on
Thu Jul 21, 2011 3:06 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Xytronix Temperature Module AppleScript

So, fortunately it's relatively simple to change your scripts to use the curl command rather than URL Access Scripting application. After doing some research and finding no suitable Lion replacement app (c'mon Apple), I converted the NOAA weather script ot use curl - it'll be included with the next releases of 4 and 5 but if you need a copy before then send me an email at indigo DASH support AT perceptiveautomation DOT com and I'll mail it to you.

Here's an example of the change:

Code: Select all
-- Using URL Access Scripting
set myFile to ((path to temporary items) as string) & "url_access_file.xml"
tell application "URL Access Scripting"
   download "http://www.nws.noaa.gov/data/current_obs/KATT.xml" to file myFile
end tell

-- Using curl
set myFile to (POSIX path of (path to temporary items)) & "curl_file.xml"
do shell script "curl -L " & "http://www.nws.noaa.gov/data/current_obs/KATT.xml" & " -o " & myFile

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jul 21, 2011 3:26 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Xytronix Temperature Module AppleScript

In the end, I have found curl to be more reliable. With URL Access Scripting I would get seemingly random connection errors, Curl also allows a lot better control over the connection - though, the man page is a bit daunting and getting the do shell script call right for complex curl commands can be a frustrating exercise in escaping and quoting. Another nice side benefit of curl is that you can easily test, and debug, the curl command from the shell (terminal).

Posted on
Thu Jul 21, 2011 7:53 pm
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

Re: Xytronix Temperature Module AppleScript

Essentially we're just trying to fix a single thing involving the lack of "URL Access Scripting" support in Lion. The rest of the AppleScript is debugged and has been working for years. AppleScript does have a "do shell script" functionality, so is there a way to use that to do whatever it is that you're doing with curl?

Posted on
Thu Jul 21, 2011 8:24 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Xytronix Temperature Module AppleScript

Totally. Look at Jay's code above. He has an example that uses URL Access Scripting, then another example that does the exact same thing using curl. If you have problems getting it working doing a similar substitution, then post both the before and after code and we'll give it a look.

Image

Posted on
Sat Jul 23, 2011 10:01 am
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

Re: Xytronix Temperature Module AppleScript

Thanks guys! In the past I've used "do shell script" to extend AppleScripts capabilities so I was thinking it could be useful to do a little "lion Taming" magic but didn't know exactly how. I did a quick test yesterday with he "curl -L" command and it worked on the first try. Today I've had it running for the past few hours under Indigo 4 and OS X 10.6.4 (Snow Leopard) and it's humming along on my more complex version of the script. Someone else will have to test it under 10.7 (Lion) to verify full functionality. Mike, are you up for letting the Lion loos in your Greenhouse again?

Here is the potential fix. The idea is to replace THIS code in the Xytronix Temperature Module AppleScript version 1.2:

--------------------------
tell application "URL Access Scripting"
-- The following web-page request downloads the page and places the html code in a temporary file to be read and parsed.
download ("http://" & LAN_address & "/index." & request_str) ¬
to file temp_file replacing yes
end tell
--------------------------

with THIS code:

--------------------------
-- "URL Access Scripting" disappeared in Apple's OS X 10.7 (Lion)
-- These two lines do the same thing (and also work in OS X 10.6)

set temp_path to POSIX path of temp_file
-- The following web-page request downloads the page and places the html code in a temporary file to be read and parsed.
do shell script "curl -L " & "http://" & LAN_address & "/index." & request_str ¬
& " -o " & temp_path
--------------------------

If I can independently verify that the rest of the script has no problems with Lion, I'll incorporate this into a script update.

-- Chris Galfo

Posted on
Sat Jul 23, 2011 10:33 am
pbmike offline
Posts: 6
Joined: Mar 17, 2010

Re: Xytronix Temperature Module AppleScript

Thanks Chris! You are the man!

Running this on Lion with the posted CURL modifications.

So far so good. Variables being passed to Indigo as expected. :)

Posted on
Sat Jul 23, 2011 11:10 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Xytronix Temperature Module AppleScript

Chris Galfo wrote:
...I've had it running for the past few hours under Indigo 4 and OS X 10.6.4 (Snow Leopard) and it's humming along on my more complex version of the script. Someone else will have to test it under 10.7 (Lion)...


FYI, I am not sure about the Xytronix script itself, but the change from URL Access Scripting to do shell script...curl should work in any version of AppleScript (well, at least under OS-X).

Posted on
Tue Aug 09, 2011 10:38 am
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

Re: Xytronix Temperature Module AppleScript

Greetings all,

I just posted Version 2.0 of the Xytronix Temperature Module script for Indigo (it should appear in a day or two, after Perceptive Automation looks it over. I when from version 1.2 directly to 2.0 because I needed to change the way it gets data from the Xytronix Temperature Module due to recent changes they have made in their firmware and that entailed rewriting the parsing code. Here's a list of changes and improvements:

- Changes in Version 2.0 :

    Fixed a compatibility issue with Mac OS-X 10.7 (Lion)
    (The version 1.x scripts stopped working when Apple eliminated support for "URL Access Scripting" -- compatibility verified by Mike Brede, thank you!)

    Could no longer use "/index.html" web-page returned by the Xytronix Temperature Module because the latest product revisions now depend heavily on JavaScript code. Switched to requesting the "/state.xml" page. This change means that the temperature alarm states can no longer be read.

    Completely rewrote the parsing code so that it would retrieve data from the "/state.xml" page to pass on to Indigo and added better parsing error messages. (compatibility verified by Richard Calfee, thank you!)

-- Chris Galfo

Posted on
Tue Aug 09, 2011 11:34 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Xytronix Temperature Module AppleScript

Already approved and available. :)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Aug 09, 2011 12:14 pm
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

Re: Xytronix Temperature Module AppleScript

Thanks Jay, that was FAST! Lion users and anyone who just purchased one of the new temperature modules will appreciate it! :)

Who is online

Users browsing this forum: No registered users and 1 guest

cron