Giter Club home page Giter Club logo

Comments (3)

dacarson avatar dacarson commented on July 29, 2024

I too am running into this issue.
I thought it might be because of the multihome raspberry pi that I am running it on, and the dns lookup was going the default route (I don't think sunpowerconsole.com is resolvable over the internet), so I used the parameter --hostname and passed in 172.27.153.1, and I still get the same issue.
Like @kskenyon the commands all work fine using curl.

from sunpower-pvs-exporter.

dacarson avatar dacarson commented on July 29, 2024

I found there is a way to force the python app to connect to the right interface, following information I found here:
https://stackoverflow.com/questions/28773033/python-requests-how-to-bind-to-different-source-ip-for-each-request
In exporter.py I added two lines as shown below. Note, however, the IP address needs to match the IP address that it received from the PVS unit. It could change, so, this patch is a hack to get it working.

    def __init__(self,
                 # hostname="sunpowerconsole.com",
                 hostname="172.27.153.1",
                 port=80,
                 scheme="http",
                 timeout=(5, 5),
                 use_device_data_timestamp=False,
                ):
        self.session = requests.Session()

        # The following two lines force the URL binding to happen on the PVS interface
        new_source = source.SourceAddressAdapter("172.27.153.156")
        self.session.mount('http://', new_source)

        self.use_device_data_timestamp = use_device_data_timestamp

        self.timeout = timeout
        self.url = "{scheme}://{hostname}:{port}/cgi-bin/dl_cgi".format(
            scheme=scheme,
            hostname=hostname,
            port=port
        )

from sunpower-pvs-exporter.

dacarson avatar dacarson commented on July 29, 2024

If you make the change I suggested above, make sure that you first install the python library
pip install requests_toolbelt
and also add at the top of the exporter.py file:
from requests_toolbelt.adapters import source
otherwise it will fail to run because 'source' is not defined.

from sunpower-pvs-exporter.

Related Issues (13)

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.