Wunderground script error

Posted on
Mon Feb 18, 2013 3:08 am
bmoraes offline
Posts: 47
Joined: Feb 05, 2007
Location: Rio de Janeiro, Brazil

Wunderground script error

I'm trying to install the Wunderground script (2.5.3) in Indigo 6 (beta5)

It created all the variables in Indigo, but all have "no value". I tried several APT and PWS stations.

From the AppleScript editor I get the following message:
error "Can’t make \"0.0\" into type number, date or text." number -1700 from "0.0" to number, date or text

and it is happening on the first line of:

if precip_1hr_m < 0 then
--set precip_1hr_m to precip_1hr_m as real
set precip_1hr_m to 0
end if

If I comment out the "if" above and also the following metric "if" (precip_today_m) the script works.

Any ideas?

Thanks, Bruno

Posted on
Tue Feb 19, 2013 1:08 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Wunderground script error

Without seeing a full trace of the program and a copy of the actual XML file from the Weather Underground, it is hard to diagnose the problem. However, it sounds like you are not getting data for the metric precipitation fields in the XML feeds.

You can try this: At the top of the script, under the comment -- The following fields are available from airport and personal weather stations
Change the 2 metric precipitation properties to:
property GetPrecip_1hr_m : ""
property GetPrecip_today_m : ""

If that does not solve the problem, please copy the full Events/Replies window from the AppleScript Editor and post them here.

Posted on
Tue Feb 19, 2013 7:43 pm
bmoraes offline
Posts: 47
Joined: Feb 05, 2007
Location: Rio de Janeiro, Brazil

Re: Wunderground script error

Thank you for the reply.

I understand that the solution you suggested would mean I would not get these data from the stations, right? I'd really like to get them, as I use it in my irrigation system logic.

Without making the changes the events/replies results show:

tell current application
do shell script "ps axww|grep -e \"osascript.*Wunderground\"|grep -v grep|wc -l"
--> " 0"
end tell
tell application "IndigoServer"
exists variable "Wunderground_Observation_Time_rfc822"
--> true
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Wed, 13 Feb 2013 04:00:05 GMT"
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Wed, 13 Feb 2013 04:00:05 GMT"
get value of variable "isDaylight"
--> false
exists variable "_Wunderground_APT"
--> true
get value of variable "_Wunderground_APT"
--> "SBRJ"
exists variable "_Wunderground_PWS_List"
--> true
get value of variable "_Wunderground_PWS_List"
--> "IRJRIODE13"
end tell
tell current application
do shell script "> /var/tmp/wunderground_SBRJ_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/auto/wui/ge ... query=SBRJ >/var/tmp/wunderground_SBRJ_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>SBRJ</station_id>\" /var/tmp/wunderground_SBRJ_sync_temp.xml"
--> " <station_id>SBRJ</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_SBRJ_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
get XML element "display_location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
--> XML element 5 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml" whose name = "weather"
--> {"Mostly Cloudy"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml" whose name = "icon"
--> {"mostlycloudy"}
end tell
tell current application
do shell script "> /var/tmp/wunderground_PWS_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/weatherstat ... IRJRIODE13 >/var/tmp/wunderground_PWS_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>IRJRIODE13</station_id>\" /var/tmp/wunderground_PWS_sync_temp.xml"
--> " <station_id>IRJRIODE13</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get XML element "location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time"
--> {"Last Updated on February 19, 10:35 PM BRT"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time_rfc822"
--> {"Wed, 20 Feb 2013 01:35:07 GMT"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "station_id"
--> {"IRJRIODE13"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temperature_string"
--> {"76.9 F (24.9 C)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temp_c"
--> {"24.9"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "relative_humidity"
--> {"79"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_string"
--> {"Calm"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_dir"
--> {"SSE"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_degrees"
--> {"167"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_mph"
--> {"0.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_gust_mph"
--> {"6.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_string"
--> {"29.95\" (1014.1 mb)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_mb"
--> {"1014.1"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "heat_index_c"
--> {missing value}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_1hr_string"
--> {"14.40 in (36.6 mm)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_1hr_metric"
--> {"36.6"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_string"
--> {"81.96 in (208.2 cm)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_metric"
--> {"208.2 cm"}
get value of every XML element of XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "full"
--> {"CSCVL rampa Pedra Bonita, Rio De Janeiro, RJ"}
get value of every XML element of XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "neighborhood"
--> {"CSCVL rampa Pedra Bonita"}
get value of every XML element of XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "city"
--> {"Rio De Janeiro"}
end tell
tell current application
do shell script "/bin/date -j -f \"%a, %d %B %Y %T %Z\" \"Wed, 13 Feb 2013 04:00:05 GMT\" \"+%s\""
--> "1360728005"
do shell script "/bin/date -j -f \"%a, %d %B %Y %T %Z\" \"Wed, 20 Feb 2013 01:35:07 GMT\" \"+%s\""
--> "1361324107"
Result:
error "Can’t make \"36.6\" into type number, date or text." number -1700 from "36.6" to number, date or text

Thanks a lot, Bruno

Posted on
Tue Feb 19, 2013 9:23 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Wunderground script error

bmoraes wrote:
...
http://api.wunderground.com/weatherstat ... IRJRIODE13
... ...
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_metric"
--> {"208.2 cm"}

Ok. That is what I needed. Thanks. It turns out there is a bug the the Wunderground XML data. They attach the string " cm" to the daily metric precipitation value. This is not done for the English units or the hourly metric total. I added a quick hack to clean up the data and it should work fine now. At least it tested Ok here - but, then it's amazing what tests well for a developer and crashes once its out there in the wild.

A new version, 2.5.4 in on dropbox and should be posted to the Contributions Library soon. Let me know if this works for you.

Posted on
Sat Feb 23, 2013 9:05 am
bmoraes offline
Posts: 47
Joined: Feb 05, 2007
Location: Rio de Janeiro, Brazil

Re: Wunderground script error

Thanks a lot for the fix.... I saw you had to remove the "cm" string, but I'm still getting the error here....


tell current application
do shell script "ps axww|grep -e \"osascript.*Wunderground\"|grep -v grep|wc -l"
--> " 0"
end tell
tell application "IndigoServer"
exists variable "Wunderground_Observation_Time_rfc822"
--> true
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Sun, 17 Feb 2013 23:16:15 GMT"
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Sun, 17 Feb 2013 23:16:15 GMT"
get value of variable "isDaylight"
--> true
exists variable "_Wunderground_APT"
--> true
get value of variable "_Wunderground_APT"
--> "SBRJ"
exists variable "_Wunderground_PWS_List"
--> true
get value of variable "_Wunderground_PWS_List"
--> "IRJRIODE13"
end tell
tell current application
do shell script "> /var/tmp/wunderground_SBRJ_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/auto/wui/ge ... query=SBRJ >/var/tmp/wunderground_SBRJ_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>SBRJ</station_id>\" /var/tmp/wunderground_SBRJ_sync_temp.xml"
--> " <station_id>SBRJ</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_SBRJ_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
get XML element "display_location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
--> XML element 5 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml" whose name = "weather"
--> {"Partly Cloudy"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml" whose name = "icon"
--> {"partlycloudy"}
end tell
tell current application
do shell script "> /var/tmp/wunderground_PWS_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/weatherstat ... IRJRIODE13 >/var/tmp/wunderground_PWS_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>IRJRIODE13</station_id>\" /var/tmp/wunderground_PWS_sync_temp.xml"
--> " <station_id>IRJRIODE13</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get XML element "location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time"
--> {"Last Updated on February 23, 11:53 AM BRT"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time_rfc822"
--> {"Sat, 23 Feb 2013 14:53:55 GMT"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "station_id"
--> {"IRJRIODE13"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temperature_string"
--> {"76.1 F (24.5 C)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temp_c"
--> {"24.5"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "relative_humidity"
--> {"91"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_string"
--> {"From the WSW at 5.0 MPH Gusting to 8.0 MPH"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_dir"
--> {"WSW"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_degrees"
--> {"256"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_mph"
--> {"5.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_gust_mph"
--> {"8.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_string"
--> {"29.94\" (1013.8 mb)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_mb"
--> {"1013.8"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "dewpoint_string"
--> {"73.3 F (22.9 C)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "dewpoint_f"
--> {"73.3"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "heat_index_c"
--> {missing value}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "windchill_c"
--> {missing value}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_1hr_metric"
--> {"0.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_metric"
--> {"0.0 cm"}
end tell
tell current application
do shell script "/bin/echo \"0.0 cm\" |/usr/bin/sed -e \"s/[ a-zA-Z]//g\""
--> "0.0"
end tell
tell application "System Events"
get value of every XML element of XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "full"
--> {"CSCVL rampa Pedra Bonita, Rio De Janeiro, RJ"}
get value of every XML element of XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "neighborhood"
--> {"CSCVL rampa Pedra Bonita"}
get value of every XML element of XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "city"
--> {"Rio De Janeiro"}
get value of every XML element of XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "elevation"
--> {"1700 ft"}
end tell
tell current application
do shell script "/bin/date -j -f \"%a, %d %B %Y %T %Z\" \"Sun, 17 Feb 2013 23:16:15 GMT\" \"+%s\""
--> "1361142975"
do shell script "/bin/date -j -f \"%a, %d %B %Y %T %Z\" \"Sat, 23 Feb 2013 14:53:55 GMT\" \"+%s\""
--> "1361631235"
Result:
error "Can’t make \"0.0\" into type number, date or text." number -1700 from "0.0" to number, date or text

Posted on
Sat Feb 23, 2013 11:26 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Wunderground script error

bmoraes wrote:
Thanks a lot for the fix.... I saw you had to remove the "cm" string, but I'm still getting the error here....

I checked the code again using your two station IDs SBRJ and IRJRIODE13. I was unable to successfully retrieve data for SBRJ. For some reason the XML returned by the Wunderground contained the station code SBGL. When I used SBGL, it worked and I did not get the error you observed.

Please try again with the SBGL station ID and let me know what you get.

Posted on
Mon Feb 25, 2013 6:17 am
bmoraes offline
Posts: 47
Joined: Feb 05, 2007
Location: Rio de Janeiro, Brazil

Re: Wunderground script error

Interesting.... I'm getting the same error regardless of the station I choose. Actually the property where I see the error is in a PWS station (SBRJ and SBGJ are airport stations).

This is the first part of the script (user defined variables) and I have changed it slightly from what I got from you....


-- The following fields are available from airport and personal weather stations
property GetDewpointC : ""
property GetDewpointF : "PWS"
property GetDewpointString : "PWS"
property GetElevation : "PWS"
property GetHeatIndexC : "PWS"
property GetHeatIndexF : ""
property GetHeatIndexString : ""
property GetObservationTime : "PWS"
property GetPrecip_1hr_in : ""
property GetPrecip_1hr_m : "PWS"
property GetPrecip_1hr_string : ""
property GetPrecip_today_in : ""
property GetPrecip_today_m : "PWS"
property GetPrecip_today_string : ""
property GetPressureIN : ""
property GetPressureMB : "PWS"
property GetPressureString : "PWS"
property GetRelativeHumidity : "PWS"
property GetTempC : "PWS"
property GetTempF : ""
property GetTempString : "PWS"
property GetWindDegrees : "PWS"
property GetWindDirection : "PWS"
property GetWindGustMPH : "PWS"
property GetWindMPH : "PWS"
property GetWindString : "PWS"
property GetWindchillC : "PWS"
property GetWindchillF : ""
property GetWindchillString : ""
property GetObservationTimerfc822 : "PWS"
property GetStationID : "PWS"
property GetFull : "PWS"
property GetNeighborhood : "PWS"
property GetCity : "PWS"
property GetState : ""
property GetZip : ""
property GetLatitude : ""
property GetLongitude : ""

-- The following fields are usually only available from an airport station
property GetWeather : "APT"
property GetIcon : "APT"

Posted on
Mon Feb 25, 2013 4:43 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Wunderground script error

It is strange that I get different results than you do when using SBRJ and also for the PWS, even with the same property settings. Which OS version are you running? I have been testing this under 10.8.2. There are AppleScript differences in each OS version, so maybe that is part of the problem I am having testing this here.

So, since I cannot reproduce the error, I need to take some calculated guesses as to the cause of the problem. I have posted a new version (2.5.5) on dropbox in which the hourly metric result is forced into a number. What I see here is that this version results in "0" instead of "0.0" so, maybe that will fix the issue you are seeing.

bmoraes wrote:
Interesting.... I'm getting the same error regardless of the station I choose. Actually the property where I see the error is in a PWS station (SBRJ and SBGJ are airport stations).

This is the first part of the script (user defined variables) and I have changed it slightly from what I got from you....


-- The following fields are available from airport and personal weather stations
...
property GetPrecip_1hr_in : ""
property GetPrecip_1hr_m : "PWS"
property GetPrecip_1hr_string : ""
property GetPrecip_today_in : ""
property GetPrecip_today_m : "PWS"
...

Posted on
Mon Feb 25, 2013 6:42 pm
bmoraes offline
Posts: 47
Joined: Feb 05, 2007
Location: Rio de Janeiro, Brazil

Re: Wunderground script error

That is indeed quite strange.

I'm running 10.8.2 too (and Indigo 6.0.0 b5). I copied the new version, deleted all the Wunderground created variables from indigo (except for the _Wunderground_APT and _Wunderground_PWS_List) to make sure we were on a clean slate.

I copied the new version from dropbox and did not make any changes. I tested several stations and always got the same error. Below the results with the stations KSFO (APT) and MSFOC1 (PWS).

tell current application
do shell script "ps axww|grep -e \"osascript.*Wunderground\"|grep -v grep|wc -l"
--> " 0"
end tell
tell application "IndigoServer"
exists variable "Wunderground_Observation_Time_rfc822"
--> true
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Fri, 1 January 2010 00:00:00 GMT"
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Fri, 1 January 2010 00:00:00 GMT"
get value of variable "isDaylight"
--> false
exists variable "_Wunderground_APT"
--> true
get value of variable "_Wunderground_APT"
--> "KSFO"
exists variable "_Wunderground_PWS_List"
--> true
get value of variable "_Wunderground_PWS_List"
--> "MSFOC1"
end tell
tell current application
do shell script "> /var/tmp/wunderground_KSFO_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/auto/wui/ge ... query=KSFO >/var/tmp/wunderground_KSFO_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>KSFO</station_id>\" /var/tmp/wunderground_KSFO_sync_temp.xml"
--> " <station_id>KSFO</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_KSFO_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_ksfo_sync_temp.xml"
get XML element "display_location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_ksfo_sync_temp.xml"
--> XML element 5 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_ksfo_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_ksfo_sync_temp.xml" whose name = "weather"
--> {"Partly Cloudy"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_ksfo_sync_temp.xml" whose name = "icon"
--> {"partlycloudy"}
end tell
tell current application
do shell script "> /var/tmp/wunderground_PWS_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/weatherstat ... ?ID=MSFOC1 >/var/tmp/wunderground_PWS_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>MSFOC1</station_id>\" /var/tmp/wunderground_PWS_sync_temp.xml"
--> " <station_id>MSFOC1</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get XML element "location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time"
--> {"Last Updated on February 25, 3:43 PM PST"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time_rfc822"
--> {"Mon, 25 Feb 2013 23:43:00 GMT"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "station_id"
--> {"MSFOC1"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temperature_string"
--> {"55.0 F (12.8 C)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temp_f"
--> {"55.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temp_c"
--> {"12.8"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "relative_humidity"
--> {"66"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_string"
--> {"Calm"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_dir"
--> {"North"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_degrees"
--> {"0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_mph"
--> {"0.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_gust_mph"
--> {"0.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_string"
--> {"0.00\" (0.0 mb)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_in"
--> {"0.00"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "dewpoint_string"
--> {"44.0 F (6.7 C)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "dewpoint_f"
--> {"44.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "heat_index_f"
--> {missing value}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_1hr_metric"
--> {"0.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_in"
--> {"0.00"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_metric"
--> {"0.0 cm"}
end tell
tell current application
do shell script "/bin/echo \"0.0 cm\" |/usr/bin/sed -e \"s/[ a-zA-Z]//g\""
--> "0.0"
end tell
tell application "IndigoServer"
log "ParseXML:Can’t make \"0.0\" into type number.(-1700)" using type "Wunderground"
log "Null data from Station 1: MSFOC1" using type "Wunderground"
Result:
error "Can’t make \"0.0\" into type number, date or text." number -1700 from "0.0" to number, date or text

Posted on
Mon Feb 25, 2013 7:07 pm
bmoraes offline
Posts: 47
Joined: Feb 05, 2007
Location: Rio de Janeiro, Brazil

Re: Wunderground script error

I found the reason of the error. The problem is my computer is set to region "Portuguese>Brazil" and here the decimal separator is "," and the thousands separator is "."

If I manually change that to the US standard ("." for decimal and "," for thousands) the script works well..... but everything else is misconfigured. So I really don't know how to solve the issue.

Another suggestion for the script, if I may, the way it is written now the High and Low temp are only recorded in F. It would be great if there were a way to record that in C as well.

Posted on
Mon Feb 25, 2013 7:49 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Wunderground script error

Good catch! Though, I am still confused where the local settings are getting involved.

Wunderground reports:
    <precip_1hr_string>0.00 in (0.0 mm)</precip_1hr_string>
    <precip_1hr_in>0.00</precip_1hr_in>
    <precip_1hr_metric>0.0</precip_1hr_metric>
    <precip_today_string>0.00 in (0.0 cm)</precip_today_string>
    <precip_today_in>0.00</precip_today_in>
    <precip_today_metric>0.0 cm</precip_today_metric>

and the script never passes any of those values to the OS for interpretation. Can you do this. At the bottom of the script. Change:
Code: Select all
on cleanText(stringToClean)
   set returnString to (do shell script ("/bin/echo \"" & stringToClean & "\" |/usr/bin/sed -e \"s/[ a-zA-Z]//g\"")) as number
   return returnString
end cleanText
to:
Code: Select all
on cleanText(stringToClean)
        log stringToClean
   set returnString to (do shell script ("/bin/echo \"" & stringToClean & "\" |/usr/bin/sed -e \"s/[ a-zA-Z]//g\"")) as number
        log returnString
   return returnString
end cleanText


And send me the messages from the output. If that is where the comma is being inserted, I can try removing the zero as text.

Posted on
Mon Feb 25, 2013 8:14 pm
bmoraes offline
Posts: 47
Joined: Feb 05, 2007
Location: Rio de Janeiro, Brazil

Re: Wunderground script error

See below the results (and my comments at the end)


tell current application
do shell script "ps axww|grep -e \"osascript.*Wunderground\"|grep -v grep|wc -l"
--> " 0"
end tell
tell application "IndigoServer"
exists variable "Wunderground_Observation_Time_rfc822"
--> true
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Tue, 26 Feb 2013 02:04:17 GMT"
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Tue, 26 Feb 2013 02:04:17 GMT"
get value of variable "isDaylight"
--> false
exists variable "_Wunderground_APT"
--> true
get value of variable "_Wunderground_APT"
--> "SBRJ"
exists variable "_Wunderground_PWS_List"
--> true
get value of variable "_Wunderground_PWS_List"
--> "IRJRIODE13"
end tell
tell current application
do shell script "> /var/tmp/wunderground_SBRJ_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/auto/wui/ge ... query=SBRJ >/var/tmp/wunderground_SBRJ_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>SBRJ</station_id>\" /var/tmp/wunderground_SBRJ_sync_temp.xml"
--> " <station_id>SBRJ</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_SBRJ_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
get XML element "display_location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
--> XML element 5 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml" whose name = "weather"
--> {"Clear"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml" whose name = "icon"
--> {"clear"}
end tell
tell current application
do shell script "> /var/tmp/wunderground_PWS_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/weatherstat ... IRJRIODE13 >/var/tmp/wunderground_PWS_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>IRJRIODE13</station_id>\" /var/tmp/wunderground_PWS_sync_temp.xml"
--> " <station_id>IRJRIODE13</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get XML element "location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time"
--> {"Last Updated on February 25, 11:05 PM BRT"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time_rfc822"
--> {"Tue, 26 Feb 2013 02:05:20 GMT"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "station_id"
--> {"IRJRIODE13"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temperature_string"
--> {"81.9 F (27.7 C)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temp_f"
--> {"81.9"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temp_c"
--> {"27.7"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "relative_humidity"
--> {"63"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_string"
--> {"From the NNW at 6.0 MPH Gusting to 7.0 MPH"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_dir"
--> {"NNW"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_degrees"
--> {"333"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_mph"
--> {"6.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_gust_mph"
--> {"7.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_string"
--> {"29.78\" (1008.4 mb)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_in"
--> {"29.78"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "dewpoint_string"
--> {"68.1 F (20.1 C)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "dewpoint_f"
--> {"68.1"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "heat_index_f"
--> {"85"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_1hr_metric"
--> {"0.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_in"
--> {"0.00"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_metric"
--> {"0.0 cm"}
end tell
(*0.0 cm*)
tell current application
do shell script "/bin/echo \"0.0 cm\" |/usr/bin/sed -e \"s/[ a-zA-Z]//g\""
--> "0.0"
end tell
tell application "IndigoServer"
log "ParseXML:Can’t make \"0.0\" into type number.(-1700)" using type "Wunderground"
log "Null data from Station 1: IRJRIODE13" using type "Wunderground"
Result:
error "Can’t make \"0.0\" into type number, date or text." number -1700 from "0.0" to number, date or text

The error occurs in the line:
"if precip_1hr_m < 0 then"

If i comment the line above I get an error on the next if clause
"if precip_today_in < 0 then" and the error is "error "Can’t make \"0.00\" into type number, date or text." number -1700 from "0.00" to number, date or text"

If I comment it as well the error moves to the next if clause
"if precip_today_m < 0 then" and the error is "error "Can’t make \"0.0 cm\" into type number, date or text." number -1700 from "0.0 cm" to number, date or text"

If I comment it as well the error happens now in
"set currentTemp to temp_f as number" and the error is error "Can’t make \"81.8\" into type number." number -1700 from "81.8" to number

Posted on
Mon Feb 25, 2013 8:33 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Wunderground script error

bmoraes wrote:
...
(*0.0 cm*)
tell current application...


Actually, that's quite helpful. The error is happening in the shell script execution - you never reached the second log command. Try replacing the on cleanText handler with this:
Code: Select all
on cleanText(stringToClean)
   log stringToClean
   set returnString to (do shell script ("/bin/echo \"" & stringToClean & "\" |/usr/bin/sed -e \"s/[ a-zA-Z]//g\""))
   log returnString
   set returnString to returnString as number
   log returnString
   return returnString
end cleanText

Posted on
Mon Feb 25, 2013 8:46 pm
bmoraes offline
Posts: 47
Joined: Feb 05, 2007
Location: Rio de Janeiro, Brazil

Re: Wunderground script error

I did not notice any change...


tell current application
do shell script "ps axww|grep -e \"osascript.*Wunderground\"|grep -v grep|wc -l"
--> " 0"
end tell
tell application "IndigoServer"
exists variable "Wunderground_Observation_Time_rfc822"
--> true
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Tue, 26 Feb 2013 02:11:13 GMT"
get value of variable "Wunderground_Observation_Time_rfc822"
--> "Tue, 26 Feb 2013 02:11:13 GMT"
get value of variable "isDaylight"
--> false
exists variable "_Wunderground_APT"
--> true
get value of variable "_Wunderground_APT"
--> "SBRJ"
exists variable "_Wunderground_PWS_List"
--> true
get value of variable "_Wunderground_PWS_List"
--> "IRJRIODE13"
end tell
tell current application
do shell script "> /var/tmp/wunderground_SBRJ_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/auto/wui/ge ... query=SBRJ >/var/tmp/wunderground_SBRJ_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>SBRJ</station_id>\" /var/tmp/wunderground_SBRJ_sync_temp.xml"
--> " <station_id>SBRJ</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_SBRJ_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
get XML element "display_location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
--> XML element 5 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml" whose name = "weather"
--> {"Clear"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_SBRJ_sync_temp.xml" whose name = "icon"
--> {"clear"}
end tell
tell current application
do shell script "> /var/tmp/wunderground_PWS_sync_temp.xml;/usr/bin/curl -s -S -m 30 http://api.wunderground.com/weatherstat ... IRJRIODE13 >/var/tmp/wunderground_PWS_sync_temp.xml"
--> ""
do shell script "/usr/bin/egrep \"<station_id>IRJRIODE13</station_id>\" /var/tmp/wunderground_PWS_sync_temp.xml"
--> " <station_id>IRJRIODE13</station_id>"
end tell
tell application "System Events"
get XML element 1 of XML file "var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get XML element "location" of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
--> XML element 4 of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml"
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time"
--> {"Last Updated on February 25, 11:42 PM BRT"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "observation_time_rfc822"
--> {"Tue, 26 Feb 2013 02:42:22 GMT"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "station_id"
--> {"IRJRIODE13"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temperature_string"
--> {"82.2 F (27.9 C)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temp_f"
--> {"82.2"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "temp_c"
--> {"27.9"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "relative_humidity"
--> {"60"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_string"
--> {"From the NNW at 5.0 MPH Gusting to 6.0 MPH"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_dir"
--> {"NNW"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_degrees"
--> {"334"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_mph"
--> {"5.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "wind_gust_mph"
--> {"6.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_string"
--> {"29.78\" (1008.4 mb)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "pressure_in"
--> {"29.78"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "dewpoint_string"
--> {"66.9 F (19.4 C)"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "dewpoint_f"
--> {"66.9"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "heat_index_f"
--> {"85"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_1hr_metric"
--> {"0.0"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_in"
--> {"0.00"}
get value of every XML element of XML element 1 of contents of XML file "Macintosh HD:private:var:tmp:wunderground_PWS_sync_temp.xml" whose name = "precip_today_metric"
--> {"0.0 cm"}
end tell
(*0.0 cm*)
tell current application
do shell script "/bin/echo \"0.0 cm\" |/usr/bin/sed -e \"s/[ a-zA-Z]//g\""
--> "0.0"
(*0.0*)
end tell
tell application "IndigoServer"
log "ParseXML:Can’t make \"0.0\" into type number.(-1700)" using type "Wunderground"
log "Null data from Station 1: IRJRIODE13" using type "Wunderground"
Result:
error "Can’t make \"0.0\" into type number, date or text." number -1700 from "0.0" to number, date or text

Posted on
Mon Feb 25, 2013 8:58 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Wunderground script error

bmoraes wrote:
I did not notice any change...
...do shell script "/bin/echo \"0.0 cm\" |/usr/bin/sed -e \"s/[ a-zA-Z]//g\""
--> "0.0"
(*0.0*)
end tell...

Yes, there was a change, and this was very helpful. The script completes the shell script call and is failing in the conversion to number, and now I understand why!

Your system is trying to convert "0.0" to a number. But, it is expecting 0,0 and that is why it fails

I need to do some research to figure out how to get the location information in the script and then I can fix this.

In the meantime, just comment out the entire section where the code checks for data < 0. Like:
Code: Select all
   (*   
   if precip_1hr_in < 0 then
      --set precip_1hr_in to precip_1hr_in as real
      set precip_1hr_in to 0
   end if
   
   if precip_1hr_m < 0 then
      --set precip_1hr_m to precip_1hr_m as real
      set precip_1hr_m to 0
   end if
   
   if precip_today_in < 0 then
      --set precip_today_in to precip_today_in as real
      set precip_today_in to 0
   end if
   
   if precip_today_m < 0 then
      --set precip_today_m to precip_today_m
      set precip_today_m to 0
   end if
*)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 33 guests