# Weather Script

**URL:** <https://forum.inductiveautomation.com/t/weather-script/4779>\
**Category:** Ignition\
**Created:** [July 6, 2012, 2:02pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779 "2012-07-06T14:02:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 2:02pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/1 "2012-07-06T14:02:36Z")

</div>

Jordan

I pasted this script on the gateway timer, but it does not run. it works if I paste it on a button.

What am I doing wrong?

# This code would query Yahoo Weather for the temperature at

# Inductive Automation’s headquarters in Sacramento, CA

# and then find the current temperature using a regular expression

#replace the ‘49247’ with your zipcode-- unless you want the weather in Hudson, MI…  
response = system.net.httpGet(“[http://xml.weather.yahoo.com/forecastrss?p=49247](http://xml.weather.yahoo.com/forecastrss?p=49247)”)

# import Python’s regular expression library

import re

# NOTE - if you’ve never seen regular expressions before, don’t worry, they look

# confusing even to people who use them frequently.

pattern = re.compile(’._?\<yweather:condition (._?)/\>’, re.DOTALL)  
match = pattern.match(response)

if match:  
subText = match.group(1)  
condition = re.compile(’._?text="(._?)"’).match(subText).group(1)  
temp = re.compile(’._?temp="(._?)"’).match(subText).group(1)  
code = re.compile(’._?code="(._?)"’).match(subText).group(1)  
system.tag.writeToTag(“Weather/Condition”,condition)  
system.tag.writeToTag(“Weather/Code”,code)  
system.tag.writeToTag(“Weather/Temp”,temp)  
#print "Condition: ", condition  
#print "Temperature (F): ", temp  
else:  
system.tag.writeToTag(“Weather/Condition”,“N/A”)#print ‘Weather service format changed’

pattern = re.compile(’._?\<yweather:forecast (._?)/\>’, re.DOTALL)  
match = pattern.match(response)

if match:  
subText = match.group(1)  
lowtemp = re.compile(’._?low="(._?)"’).match(subText).group(1)  
hightemp = re.compile(’._?high="(._?)"’).match(subText).group(1)  
system.tag.writeToTag(“Weather/Low”,lowtemp)  
system.tag.writeToTag(“Weather/High”,hightemp)  
#print "Condition: ", condition  
#print "Temperature (F): ", temp  
else:  
system.tag.writeToTag(“Weather/Condition”,“N/A”)#print ‘Weather service format changed’

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [July 6, 2012, 2:24pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/2 "2012-07-06T14:24:11Z")

</div>

What is the error reported in the console? You can view the console by logging into the Ignition Gateway configuration webpage and selecting Console on the left hand side.

Is it possible the Ignition server doesn’t have internet access?

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 2:32pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/3 "2012-07-06T14:32:56Z")

</div>

Travis

10:31:50 AM

TimerScriptTask

Error executing global timer script: Weather\_Update (10000) [Delay, Shared]. Repeat errors of this type will be logged as ‘debug’ messages.

Traceback (innermost last):  
File “\<TimerScript:Weather/Weather\_Update (10000) [Delay, Shared]\>”, line 5, in ?  
IOError: Connection timed out: connect

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [July 6, 2012, 2:34pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/4 "2012-07-06T14:34:46Z")

</div>

Right, that means that Ignition could not contact Yahoo on the server machine. I don’t think it has internet access.

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 2:36pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/5 "2012-07-06T14:36:02Z")

</div>

I have the same script on a button, it works Good ??

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 6, 2012, 2:49pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/6 "2012-07-06T14:49:57Z")

</div>

> [@Travis.Cox](#):
>
> Right, that means that Ignition could not contact Yahoo on the server machine. I don't think it has internet access.

Whew! Dodged that bullet... ![:mrgreen:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/d23659b203d2d24d394be983a52adb2fa6fe23d4.gif "Mr. Green")

Also did a quick check to make sure yahoo didn't change anything on us... anything's possible!

Jerry: It works on the button because the script on the button is local to the client, which apparently has internet access. Gateway scripts run local to the Igniton server. That's whay Travis was wanting to check for an internet connection on the server.

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 2:53pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/7 "2012-07-06T14:53:47Z")

</div>

I am actually on remote desktop to the server. with a Client open on the server itself.

Looking at the console I see the error about every 5 to 10 minutes, but the timer is at 15 seconds.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 6, 2012, 3:01pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/8 "2012-07-06T15:01:25Z")

</div>

Do the tags get updated, then? It sounds like an intermittent issue with the internet connection.

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 3:02pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/9 "2012-07-06T15:02:56Z")

</div>

The tags have never updated off the timer script, Tags only update , if i use the button.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 6, 2012, 6:14pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/10 "2012-07-06T18:14:17Z")

</div>

[quote=“Jerry\_H”]Travis  
10:31:50 AM

TimerScriptTask

Error executing global timer script: Weather\_Update (10000) [Delay, Shared]. Repeat errors of this type will be logged as ‘debug’ messages.

Traceback (innermost last):  
File “\<TimerScript:Weather/Weather\_Update (10000) [Delay, Shared]\>”, line 5, in ?  
IOError: Connection timed out: connect[/quote]

Ok, that explains the log behavior. All the other errors got downgraded to “debug” type. This reduces log clutter…

This will sound stupid, but it is the same url in the timer script? I’ve gotten caught with that sort of thing.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 6, 2012, 6:18pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/11 "2012-07-06T18:18:22Z")

</div>

Another thing I thought of. Do you have a firewall running?

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 6:45pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/12 "2012-07-06T18:45:22Z")

</div>

Exactly the same script–copy&pasted

Yes, there is a firewall! I added an except to yahoo but maybe it not correct.

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 6, 2012, 7:51pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/13 "2012-07-06T19:51:48Z")

</div>

Stop the firewall same issue,

Created a client timer script it does not work either.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [July 6, 2012, 10:34pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/14 "2012-07-06T22:34:44Z")

</div>

Are you getting the same error?

---

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://forum.inductiveautomation.com/u/ryans)\
**Post date:** [July 9, 2012, 8:44pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/15 "2012-07-09T20:44:40Z")

</div>

Was there a resolution to this? I would like to do the same thing.

Thanks

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 10, 2012, 2:48pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/16 "2012-07-10T14:48:53Z")

</div>

Not resolved ! Button works Gateway Timer does not.

It could be a group policy of some kind on my end?

I gave up and went a different direction using active X now and taking a screen shot and passing it on to non internet connected PC’s, shows all current conditions and radar from Weatherbug.

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [July 10, 2012, 5:24pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/17 "2012-07-10T17:24:01Z")

</div>

What version of Ignition are you running?

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 10, 2012, 5:35pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/18 "2012-07-10T17:35:10Z")

</div>

7.2.11

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 10, 2012, 5:47pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/19 "2012-07-10T17:47:11Z")

</div>

7.2.11, same as me. Or is that same as I?

I’ve been using this script for about a year and a half. If it’s working off a button but not a gateway timer, then I’d have to say the script itself is okay.

That being said, I originally put this together as a complete and separate project. In fact this original project is still running. I’ll attach it here. See if this makes any difference for you. Odder things have happened…  
[weather.proj](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/7126f62e8be231ba90275286a28aabb08f996f1a.proj) (25.1 KB)

---

<div class="post-metadata">

**Author:** ![Jerry\_H](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@Jerry\_H](https://forum.inductiveautomation.com/u/Jerry_H)\
**Post date:** [July 10, 2012, 9:37pm UTC](https://forum.inductiveautomation.com/t/weather-script/4779/20 "2012-07-10T21:37:37Z")

</div>

Downloaded and created a project.

Opened in Designer, gateway script fails to run, copied script to a button, it worked.

Saved and Opened the project…Just a blank grey screen.

Is this 32 bit or 64 bit?

I am running 64 bit with java 1.6.33

Attached is a screen shot of what I am now doing using active X

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/9aaa4b504f4857544925178b77c374f93bc3d7c4.PNG)

[Next page](https://forum.inductiveautomation.com/t/weather-script/4779.md?page=2)
