Xytronix Temperature Module AppleScript

Posted on
Wed Aug 27, 2008 1:53 pm
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

Xytronix Temperature Module AppleScript

I've found a nice little temperature reading module that can be used to get up to 4 accurate temperature readings into AppleScript where you can pass them along to Indigo. It's called a "daq Temperature Module" manufactured by Xytronix Research, Inc. and it connects to your Local Area Network (or via the internet with proper routing). I have uploaded an AppleScript for Indigo that I've been running on both a wired and wireless LAN for the past few months. The company also makes a general-purpose Analog Interface (which is somewhat more expensive) that I plan to get in the next few months, so look for a similar script for it too. Some really nice other features of the Temperature Module are that it has a built-in web server, it can send you e-mail when temperatures get above or below user defined limits, and it has two relays that it (or you) can use to turn on or off external devices (heating, cooling, or alarms). Best of all, you can modify this AppleScript to do complicated temperature control tasks based on temperature differences, trends, etc. (stuff that is too complicated for either Indigo or the Module itself to handle). The hardware/firmware is described at:

http://www.ControlByWeb.com/temperature/index.html

Enjoy,

Chris Galfo

Posted on
Wed Aug 27, 2008 2:20 pm
jay (support) offline
Site Admin
User avatar
Posts: 13274
Joined: Mar 19, 2008
Location: Austin, Texas

(No subject)

Excellent Chris, thanks for the contribution!

BTW, to delete a file w/o having to use a shell script you can tell the Finder to do it: check out the Finder's dictionary for more info...

Thanks again!
jay

Posted on
Thu Aug 28, 2008 5:04 pm
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

Finder Delete via Applescript

Hi Jay,

Yes, the Finder does have a "delete" file but it simply moves the file to the trash and doesn't actually remove it from disk. Since this would happen once a minute, the trash would soon fill up with lots of little files. If there's something I'm missing, please enlighten me.

It's not actually too important to have this script delete the temporary file, since it's very small (about 1 KB) and gets overwritten if it isn't deleted, it's just a nice thing to do so that the user doesn't wonder "where the heck did that file come from" when looking through the default directory. I was fairly surprised that AppleScript doesn't natively support deleting a file; it's a fairly serious omission IMO.

I'm hoping that I can get some Indigo user's hooked up with the Xytronix boxes since they're a very slick solution. I'm for anything that doesn't use a USB, can run stand-alone at a good distance from the computer and use under a watt of power.

-- Chris Galfo

Posted on
Thu Aug 28, 2008 6:16 pm
matt (support) offline
Site Admin
User avatar
Posts: 18006
Joined: Jan 27, 2003
Location: Texas

Re: Finder Delete via Applescript

Hi Chris,

Thanks for the sharing the script and info on the hardware. Definitely looks interesting. Now I just need a CAT5 drop down to where my turtle reptarium is...

Regards,
Matt

Posted on
Sat Sep 13, 2008 10:24 am
anode offline
Posts: 696
Joined: May 27, 2007
Location: NC

(No subject)

I know this is a older thread, but does the script work with the ModBUS protocol? I'm rather interested in ModBUS I have a bunch of stuff that will work on it.

Posted on
Sun Sep 14, 2008 9:09 am
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

(No subject)

No, the script does not use ModBUS but reads data from the web-page that the Xytronix Temperature Module generates. If you have (or know of) an AppleScript driver for ModBUS, please pass that information along, since it could (in principle) also be used to interface the Temperature Module.

-- Chris Galfo

Posted on
Sun Jan 11, 2009 2:32 pm
BobRoss offline
Posts: 88
Joined: Jan 15, 2006
Location: New Jersey

(No subject)

Hello all,

I am pulling my hair out having been unable to get the script to work.

The error message I get in indigo is:

Module 192.168.73.210:8081 is NOT responding...

The script never downloads the file from the module, but if you direct a browser at that address it comes up just fine.

I am not very good at scripting and have compared it to the original NOAA script but they are not the same. The NOAA script runs fine.

I am running the newest version of Mac OS (10.5.6) and the newest version of indigo.

Does anybody have any thoughts.

Bob

Posted on
Tue Jan 13, 2009 5:46 pm
BobRoss offline
Posts: 88
Joined: Jan 15, 2006
Location: New Jersey

(No subject)

BTW Chris Galfo is correct the "daq Temperature Module" manufactured by Xytronix Research, Inc. is solid hardware.

Doing research of the max length of cable you can get away with, using cheep cable.

I just got to figure out how to get the script to work.

Bob Ross

Posted on
Sat Jan 17, 2009 3:50 pm
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

(No subject)

Bob,

Sorry for the delay in getting back to you.. It sounds like the download is failing. Try the following:

Open the application "Script Editor" to a blank page and type in the following:

tell application "URL Access Scripting"
set temp_file to download "http://192.168.73.210:8081/index.html" to file "temp.txt"
end tell

then hit "Run"

A file called "temp.txt" should appear in your default directory and if you open the file you'll see that it contains a web page (html text) of your current temperature data. Let me know if this actually works, and we'll go from there.

I'm assuming that you have the Xytronix Temperature Module at a fixed IP address of 192.168.73.210 and its web server set to use port 8081 instead of the default port of 80.

-- Chris Galfo

Posted on
Sat Jan 17, 2009 4:31 pm
BobRoss offline
Posts: 88
Joined: Jan 15, 2006
Location: New Jersey

(No subject)

Chris Galfo wrote:
Bob,

snip...
I'm assuming that you have the Xytronix Temperature Module at a fixed IP address of 192.168.73.210 and its web server set to use port 8081 instead of the default port of 80.

-- Chris Galfo


Yes on the ip address and the port number.

I copied the script and ran it.

This was the error

URL Access Scripting got an error: An error of type -1 has occurred.

Thanks for looking at it

Bob Ross

Posted on
Sat Jan 17, 2009 5:33 pm
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

(No subject)

Bob,

I can't seem to find a list of error codes for AppleScript's URL Access Scripting that includes type -1 on-line or in my AppleScript book (Beginning AppleScript - Programmer to Programmer"). You might try going on an AppleScript user's forum and seeing if anyone knows what might be going on. In the meantime, I want to try changing my Temperature Module's port to see if I can reproduce the problem here (I already tried adding a ":80" to the end of my module's address and that works fine, so I'm guessing that the port specification doesn't have anything to do with it). I don't have Mac OS 10.5 so I'm testing under OS 10.4.

Chris Galfo

Posted on
Sat Jan 17, 2009 5:35 pm
BobRoss offline
Posts: 88
Joined: Jan 15, 2006
Location: New Jersey

(No subject)

I will.

Thanks
Bob

Posted on
Sat Jan 17, 2009 10:28 pm
BobRoss offline
Posts: 88
Joined: Jan 15, 2006
Location: New Jersey

(No subject)

Chris,

I have been playing around looking at all the code I can find on URL Access Scripting. I got a version to work, but I don't know why the original does not - could it be 10.5.6

this is your code:
Code: Select all
tell application "URL Access Scripting"
   set temp_file to download ("http://" & LAN_address & "/index." & request_str) to file ("zz_indigo_" & LAN_address) replacing yes
end tell


This is what I got to work - seems like if there is anything in front of the download command it fails.
Code: Select all
tell application "URL Access Scripting"
   set temp_file to ((path to temporary items) as string) & "temp.xml"
      download LAN_address to temp_file replacing yes
end tell

Bob Ross

Posted on
Sun Jan 18, 2009 3:45 pm
Chris Galfo offline
User avatar
Posts: 16
Joined: Aug 19, 2007
Location: Auberry, CA

(No subject)

Interesting, I'm not sure exactly what's happening either. I'll need to experiment a little more and then update the script so that it doesn't break under Mac OS 10.5. I also think that the ":" in a port specified LAN address might cause problems in the way I was naming the temporary file, so that needs to be modified too.. I'll update it and send it to you tfor testing under 10.5 if you don't mind.

Thanks,

Chris Galfo

Posted on
Sun Jan 18, 2009 5:56 pm
BobRoss offline
Posts: 88
Joined: Jan 15, 2006
Location: New Jersey

(No subject)

no problem

Bob

Who is online

Users browsing this forum: No registered users and 0 guests