Coder Social home page Coder Social logo

alertme2plotwatt's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

alertme2plotwatt's Issues

plotwattapi.PlotwattError: Plotwatt Error: 422 Unprocessable Entity

When calling push_readings I always get an error. I added some more print statements into the plot watt-api:

def _request(self, url, data=None):
    """ make a request to plotwatt.com """
    print "INFO calling urllib2.Request..."
    req = urllib2.Request(self.baseurl + url)
    req.add_header("Authorization", self.authheader)
    print "INFO req = ", str(req)
    print "INFO data = ", str(data)
    print "INFO method = ", req.get_method()
    try :
        print "INFO calling urllib2.urlopen..."
        #return urllib2.urlopen(req, data, 5)
        response = urllib2.urlopen(req, data, 5)
        print "INFO url = ", response.geturl()
        print "INFO method = ", req.get_method()
        print "INFO data = ", req.get_data()
        print "INFO code = ", response.code
        #html = response.read()
        #print "INFO html = ", str(html)
        return response
    except urllib2.HTTPError, e :
        if e.code == 422 :
            raise PlotwattError(e.read())
        raise e

The output is:

INFO calling urllib2.Request...
INFO req = urllib2.Request instance at 0x1d17c60 (NOTE: removed <> encosures as with them it doesn't show up after posting)
INFO data = 70363,1.007,1258826400,70363,1.0,1258826460,70363,1.006,1258826520,70363,1.009,1258826580,70363,1.001,1258826640,70363,1.007,1258826700,70363,0.997,1258826760,70363,1.003,1258826820,70363,1.001,1258826880,70363,1.007,1258826940,70363,1.004,1258827000,70363,1.0,1258827060,70363,1.004,1258827120,70363,0.987,1258827180,70363,0.949,1258827240,70363,0.936,1258827300,70363,0.929,1258827360,70363,0.929,1258827420,70363,0.933,1258827480,70363,0.932,1258827540,70363,0.922,1258827600,70363,0.879,1258827660,70363,0.878,1258827720,70363,0.876,1258827780,70363,0.854,1258827840,70363,0.802,1258827900,70363,0.792,1258827960,70363,0.792,1258828020,70363,0.798,1258828080,70363,0.81,1258828140,70363,0.793,1258828200,70363,0.789,1258828260,70363,0.855,1258828320,70363,0.907,1258828380,70363,0.897,1258828440,70363,0.901,1258828500,70363,1.084,1258828560,70363,1.08,1258828620,70363,1.11,1258828680,70363,1.08,1258828740,70363,1.083,1258828800,70363,1.082,1258828860,70363,1.084,1258828920,70363,1.121,1258828980,70363,1.193,1258829040,70363,1.263,1258829100,70363,1.33,1258829160,70363,1.325,1258829220,70363,1.901,1258829280,70363,3.037,1258829340,70363,2.964,1258829400,70363,2.888,1258829460,70363,2.735,1258829520,70363,1.247,1258829580,70363,1.232,1258829640,70363,1.169,1258829700,70363,1.799,1258829760,70363,1.832,1258829820,70363,1.163,1258829880,70363,1.161,1258829940
INFO method = GET
INFO calling urllib2.urlopen...
Traceback (most recent call last):
File "/home/pi/alertme2plotwatt/alertme.py", line 316, in
PW_METER_ID=options.PW_METER_ID)
File "/home/pi/alertme2plotwatt/alertme.py", line 278, in transfer
push_readings_to_pw(pw, PW_METER_ID,data,timestamps)
File "/home/pi/alertme2plotwatt/alertme.py", line 179, in push_readings_to_pw
pw.push_readings(PW_METER_ID,data,timestamps)
File "/home/pi/plotwatt-api/plotwattapi.py", line 98, in push_readings
res = self._request(self.push_readings_url, data)
File "/home/pi/plotwatt-api/plotwattapi.py", line 60, in _request
raise PlotwattError(e.read())
plotwattapi.PlotwattError: Plotwatt Error: 422 Unprocessable Entity

Is there something wrong with the data I'm feeding into push_readings or is there an issue with push_readings itself? I'm thinking it's more a data issue as plotwatt-api uploads readings fine with the test.py it comes with.

Cheers
Michael

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.