How can we help?


Ambient Weather Parser Error

Comments

16 comments

  • Avatar
    RainMachine Nicholas

    Hi Zach,

    We're thrilled that some one looks at Ambient Weather integration !

    First you could, instead of return json.loads() print the output to console with log.info(json.loads(d.read())

    Secondly enclose the entire block in a try/except like this:

    try:

        d = self.openURL(url)

        if d isNone:

            return

       log.info(json.loads(d.read()))

    except Exception, e:

       log.error(e)
     
    I seen that the actual error isn't shown on your output maybe this will give more information about what's going on.
    0
    Comment actions Permalink
  • Avatar
    Zach

    That is actually the exact code I currently have, I removed the log to simplify it. It doesn't get to the log line because it is throwing the error at self.openurl and moved to the exception block.

    I also tried with urllib2 but still got an exception with no error message. I'm not sure what else to try.

    0
    Comment actions Permalink
  • Avatar
    RainMachine Nicholas

    Can you try a simple HTTP not HTTPS request to check if your platform doesn't have some issues with SSL ?

    Maybe use this url: http://demo.labs.rainmachine.com/js/highcharts-custom.js to check if you get the data ?

    Then try HTTPS with this url: https://demo.labs.rainmachine.com:18080/api/4/apiVer

     

    0
    Comment actions Permalink
  • Avatar
    Zach

    Both of those URLS returned data successfully.  Is there anything else I can check on the rainmachine end?

    0
    Comment actions Permalink
  • Avatar
    RainMachine Nicholas

    If those work it means that provided openURL() function is working correctly for both HTTP and HTTPS calls. I'm not sure at this moment what's wrong.

    I have requested an application key for one of our stations from Ambient Weather so I can check it too.

    0
    Comment actions Permalink
  • Avatar
    Zach

    I wrote a script to call the URL and ran it on my computer which is running python 3 and it returned data but couldn't parse it to a json object. Then I changed it to use the requests library to make the call and parse the json and it worked great.

    It seems like the python version on the rainmachine unit is 2.x, is that going to change in the near future? Also, would it be possible to make the requests library available for use?

    0
    Comment actions Permalink
  • Avatar
    RainMachine Nicholas

    If it works with requests library should work with urllib2 library too, maybe some headers are not automatically filled by urllib2.

    As for python3/requests library, I'm not sure, some of our models are very space constrained so probably we won't see python3 on those.

    0
    Comment actions Permalink
  • Avatar
    Jens Jungmann (Edited )

    I am having the EXACT same problem - Ambient Weather - working in pyCharm, URLs work in Browser, but on the RainMachine I get the exact same error of:

    I also get nothing after the "error:".

    I was wondering if the length of the URL is maybe causing a problem?

     

     

     

    0
    Comment actions Permalink
  • Avatar
    Jens Jungmann (Edited )

    Additional Information:  I added code to "catch" URLError and got the following additional information on the error:

    • ... reason: [Errno 1] _ssl.c:510: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error

    Looks like SSL related but I have not idea what to do about this.

    0
    Comment actions Permalink
  • Avatar
    RainMachine Nicholas

    The SSL on RainMachine might be older than expected by ambient server. We'll check if we can add it to our update list.

    P.S. I will rename the thread to be more meaningful to people to look for same issue.

    0
    Comment actions Permalink
  • Avatar
    RainMachine Nicholas

    I tested with a newer version of python (2.7.14) and urllib2 and still doesn't work:

    >>> j = urllib2.urlopen(u)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
    File "/usr/lib/python2.7/urllib2.py", line 429, in open
    File "/usr/lib/python2.7/urllib2.py", line 447, in _open
    File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    File "/usr/lib/python2.7/urllib2.py", line 1241, in https_open
    File "/usr/lib/python2.7/urllib2.py", line 1198, in do_open
    urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] unknown error (_ssl.c:661)>

     

    We'll check what requests lib does better vs urllib2 regarding this https calls.

     

    0
    Comment actions Permalink
  • Avatar
    Zach

    I saw a firmware update was applied today but still no luck on the parser.  Are there plans to update the SSL version?

    0
    Comment actions Permalink
  • Avatar
    RainMachine Nicholas

    Yes but I can't give you an exact timeframe at this moment. The current beta update will come soon as stable and it won't contain SSL update just yet. Probably the following beta after stable will.

    0
    Comment actions Permalink
  • Avatar
    Michael (Edited )

    I am having the exact same problem.  I've written a parser for an Ambient Weather PWS in python (because Weatherunderground doesn't do free APIs anymore ... grr).  When I test the script from my computer it works perfectly.  When I upload it to the Rain Machine, I am getting the same error Jens identified above. 

    I traced that error to what I thought was an incompatibility with the version of Python that you have on the HD-12 currently.  For Ambient Weather, the API call to api.ambientweather.net must be using https, and this site works only with SNI (Server Name Indication) support.  I was able to SSH into the HD-12 and saw that you currently have Python 2.7.8 on the HD-12 right now, and SNI is not supported in Python until 2.7.9 or later.  So I was thinking that an upgrade to the version of Python would help, but it looks like you already tried that above. 

    I would still upgrade the Python version in the HD-12, but is there any word on the upcoming SSL update so that I (and others) can get the Ambient Weather parsers working?

    0
    Comment actions Permalink
  • Avatar
    GHammer

    It doesn't address this issue, but there is a weewx extension that pushes the data to my Mini-8.

    With weewx, it really doesn't matter what kind of weather station you have. As long as you have at least a Pi available to run weewx on.

     

    0
    Comment actions Permalink
  • Avatar
    Gregory Feiner

    FYI. A new AmbientWeather parse was posted here: https://support.rainmachine.com/hc/en-us/community/posts/360029128293-Ambient-Weather-Parser  I tried it.  It appears to be working.

    0
    Comment actions Permalink

Please sign in to leave a comment.