AccuWeather Attachment Script

Posted on
Fri Feb 23, 2007 9:26 pm
sepstein offline
Posts: 17
Joined: Jan 28, 2007

(No subject)

Very nice script, particularly for those of us with limited scripting ability.

A question - can this be modified to work with NOAA? I know there is another script for NOAA out there, but I'm running OS 10.3.9, and it does not have the automatic XML parser. Seems that the ScriptingAdditions takes care of that here.

I'm really looking for more data than AccuWeather seems to provide (like dewpoint) - I'm trying to control my humidifiers. Can't find an easy humidity sensor, so knowing the dewpoint will help determine when to run the humidfiers.

Steve

Posted on
Sat Feb 24, 2007 2:02 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

(No subject)

Yes, you can use the code from the AccuWeather script to make a NOAA Weather script.
If you know AppleScript and XML, it will probably take about an hour to do so.

Maybe I'll give it a try this weekend if I have some time left.

Posted on
Sat Feb 24, 2007 3:50 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

(No subject)

Looks like I made some time...

NOAA Weather Script 2

I have no 10.3 environment anymore so please let me know if it works.

Posted on
Sat Feb 24, 2007 12:09 pm
sepstein offline
Posts: 17
Joined: Jan 28, 2007

(No subject)

Works like a charm!

Thanks much!

Steve

Posted on
Thu May 17, 2007 10:02 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

(No subject)

czvi asked if there is a background task version of the AccuWeather Attachment. There is and you can download it here:

AccuWeather Attachment 1.4

There where no changes to the AccuWeather script so all you have to do is follow the instructions in the read me for fetching the temperature via a background task.

Posted on
Fri May 18, 2007 9:30 pm
matt (support) offline
Site Admin
User avatar
Posts: 21421
Joined: Jan 27, 2003
Location: Texas

(No subject)

Hi Paul,

Thanks for updating your script with the background addition. However, there is one small problem. Your background script calls into the attachment script (getAccuWeather()). This causes the background script to execute the main communication (curl) within Indigo's main thread, where it has potential to hang the server. For it to be truly safe and not have any chance of hanging the Indigo Server, it should call a copy of the function inside the background script itself and not an attachment function that gets loaded into Indigo (and thus executed by Indigo).

The key is you don't want to define something inside an attachment function that can potentially hang. I still use attachment functions for all sorts of things, but I try not to use them for things like: curl, soap, or remote AppleEvents.

Regards,
Matt

Posted on
Sat May 19, 2007 12:52 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

(No subject)

Thanks for the explanation Matt. I'll try to make a new version this weekend that follows your guidelines.

Posted on
Sun May 20, 2007 3:31 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

(No subject)

I've made a new version of the AccuWeather attachment that follows Matt's guidelines. You can download it here:

AccuWeather Attachment 1.5

To upgrade from previous versions, copy the URL you use to the new AccuWeather sync script and enable all the items you need.
Then remove the old AccuWeather script from the Attachments folder.

Finaly restart the Indigo Server.

Posted on
Sun May 20, 2007 2:23 pm
matt (support) offline
Site Admin
User avatar
Posts: 21421
Joined: Jan 27, 2003
Location: Texas

(No subject)

Thanks for the update!

Matt

Posted on
Wed May 30, 2007 1:45 pm
MikeB offline
Posts: 32
Joined: Nov 16, 2006
Location: Cupertino, CA

(No subject)

macpro wrote:
I've made a new version of the AccuWeather attachment that follows Matt's guidelines. You can download it here:

AccuWeather Attachment 1.5

To upgrade from previous versions, copy the URL you use to the new AccuWeather sync script and enable all the items you need.
Then remove the old AccuWeather script from the Attachments folder.

Finaly restart the Indigo Server.


Why not invoke curl with the "-m" flag, so that the operation eventually has to time out (and won't hang).

I changed the relevant line to this:

set responseXML to do shell script "curl --get -m 60 -d --url "" & weatherURL & "" "

Posted on
Mon Jun 04, 2007 3:55 am
bob72 offline
Posts: 2
Joined: Jun 04, 2007
Location: London, UK

(No subject)

Macpro, many thanks for the script.

Is there any way to strip the % sign from the Relative Humidity variable? I'm using 85% humidity as a cutoff for my irragation pump, the % sign stops the greater than / less than control from working.

All the best -bob

Posted on
Mon Jun 04, 2007 4:03 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

(No subject)

You can use AppleScript string functions to manipulate the result.
This page gives an overview of those functions.

Posted on
Tue Jun 05, 2007 4:51 am
bob72 offline
Posts: 2
Joined: Jun 04, 2007
Location: London, UK

(No subject)

Thanks Macpro, sorted it last night.

-bob

Posted on
Sat Nov 03, 2007 5:22 pm
kidney offline
Posts: 240
Joined: Jul 15, 2007

Loop error

Accuweather loop error occured: -1708, anyone know how to fix that problem?

Posted on
Sun Nov 04, 2007 3:06 am
macpro offline
User avatar
Posts: 765
Joined: Dec 29, 2005
Location: Third byte on the right

(No subject)

That one is new for me.
I have seen loops before with error number -1712 and the AccuWeather script is capable of handling these.

This is what you can try to fix it:

Open the AccuWeather sync.scpt file. It's in Library/Application Support/Perceptive Automation/Indigo 2/Scripts/Background Tasks.

Scroll down towards almost the end of the file.
You'll see this piece of code:
Code: Select all
            if errNum is -1712 then
               tell application "IndigoServer"
                  log "AccuWeather loop time out occured" using type "AccuWeather"
               end tell
            else
               tell application "IndigoServer"
                  log "AccuWeather loop error occured: " & errNum using type "AccuWeather"
               end tell
            end if

Change the line with -1712 to
Code: Select all
            if errNum is -1708 or errNum is -1712 then


Scroll down a bit more and you'll similar code like this again.
Make the same change.

Now save the script.

To get the modified script working, you'll have to stop and restart the Indigo Server.

Please let me know if this works.

[edit] Changed the logging lines to resemble the actual AccuWeather script code. [/edit]
Last edited by macpro on Sun Nov 04, 2007 9:22 am, edited 1 time in total.

Who is online

Users browsing this forum: No registered users and 6 guests

cron