Python library with local server

Hello everyone,
I have a Blynk Local server. I saw blynk’s python library and tried that on my Raspberry Pi (this device is not working as server). Upon searching on forum I found that we have change the server parameters in BlynkLib.py file. So I located that file and saw this.

    def __init__(self, auth, **kwargs):
        self.server = kwargs.pop('server', 'blynk-cloud.com')
        self.port = kwargs.pop('port', 80)
        BlynkProtocol.__init__(self, auth, **kwargs)

So I changed it according to my server. So it looks like this now:

    def __init__(self, auth, **kwargs):
        self.server = kwargs.pop('server', '35.154.12.218')
        self.port = kwargs.pop('port', 8080)
        BlynkProtocol.__init__(self, auth, **kwargs)

But after running the sample code given on Github page, i get error as Invalid auth token. I even checked my auth token and I am sure that I have copied it correctly.

So am I missing something here?

Old directions for previous version of the Python library.

Blynk Python 0.2.0 only needs this code in your sketch for Local Server use…

# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH,
                       server='xxx.xxx.xxx.xxx', # set server address
                       port=8080,              # set server port
                       heartbeat=30,           # set heartbeat to 30 secs
                       )
1 Like

There are example files, if you use official python lib, those are working here:

1 Like

Thanks @Gunner @demlak for help. Now it is working fine.