Git Product home page Git Product logo

blynk-library-python's Introduction

SWUbanner

vshymanskyy's GitHub stats

Publications

Recognition

blynk-library-python's People

Contributors

bradenm avatar jfperusse avatar jsikorsky avatar vshymanskyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blynk-library-python's Issues

Notify

add notify back to BlynkLib.py 1.0.0

Send Unicode character

Hi,
is there a way to send Unicode character to blynk app... ?
When I use it i got an error...
Thank a lot

Attribute error

Traceback (most recent call last):
File "", line 22, in
AttributeError: 'Blynk' object has no attribute 'on'

error on blynk.on

Hi,
i try examples , each time blynk.on is used i have the same error

" @blynk.on("connected")
TypeError: on() takes exactly 3 arguments (2 given)"

why ?, thanks for replies
regards

Every python program takes 100% CPU on my raspi

In contrast to the C version which only takes about 1% CPU, the python version saturates a full CPU core all the time even for the smallest setups (only one virtual port with polling interval of 30 s).

Invalid Token RPi4b

Hi i have problem with connecting my raspi with blynk.cloud via python3 i get invalid token information all the time. For now im only trying to connect and see if device is online.

blynk1

import BlynkLib
BLYNK_AUTH = 'CEliuHR*************1AafR9G9__k'
blynk = BlynkLib.Blynk(BLYNK_AUTH, server='blynk-cloud.com', port=8080)

while True:
    blynk.run()

and i got
blynk2

what i did :

pip install blynk-library-python

i also cloned this git and run

sudo python3 setup.py

i also tried to install other python blynk libraries from git but i have the same problem

Triplicates messages for Text input widgets/

Hi all here in this uPy Blynk community. I was doing a lot of debugging for one home automation project and finally, the conclusion is I found something estrange in this lib BlinkLib v0.2.1 running in ESP32 board.
I found that if I use a text input widget, (i.e to enter a secret code to open a door in my project) this widget create 3 updates, when all other widget not. even using same virtual port for other widget, text input triplicates whereas let say button not.

running the script with log=print I get this when I just use a button

0 32 | 200
0 33 | 200
0 34 | 200
20 16892 | vw,63,1
Event: V63 -> ['1']
Event: V* -> 63 ['1']
20 16893 | vw,63,0
Event: V63 -> ['0']
Event: V* -> 63 ['0']

that is ok as I press the button (v63 ->1) and then realease it (v63 -> 0)
but entering a value in text input widget same virtual, I got this>

20 16895 | vw,63,1
Event: V63 -> ['1']
Event: V* -> 63 ['1']
20 16896 | vw,63,1
Event: V63 -> ['1']
Event: V* -> 63 ['1']
20 16897 | vw,63,1
Event: V63 -> ['1']
Event: V* -> 63 ['1']

< 6 35 |
0 35 | 200
< 6 36 |
0 36 | 200

in my code understanding this I had to block subsequent updates /messages after first. as a workaround.
any hints to clean up?

thanks, greeting from an in-quarentine home.

<M

Reconnect after loss signal.

Hello

I cannot understand how to use this library working all the time.. When I loss signal its show me the error: BlynkLib.py line 240, in _write. and similar problems.. I do not know how to reconnect blynk correctly after loosing signal.. There is some hidden code which connect into the wifi automaticly, however Im not able to reconnect blynk because I got similar error.

Im using ESP8266 with micropython build.

Library support for ESP32 Micro Python

Hi, Can you please also provide library for ESP32 over Micro python language. I am currently using old Blynk.mpy library for old cloud server. Can that be tweaked in for new cloud connection and accepting template id. I suppose some part of code will change. Please help.

Buttons stop working over time

I'm making a device to automate humidity/temperature in a little tent.
I have 3 virtual buttons. When I run my program, just at the start they work as expected.
If my sensor get a given humidity value, it calls a function to increase it, after this point the buttons stop working

I'm using python 3.7 on a raspberry pi

set_property for color doesn't appear to work

I am using the code from this github repo. I am trying to change the color of a LED attached to V8
I have confirmed the LED is working via

blynk.virtual_write(8,0)

and

blynk.virtual_write(8,255)

I am trying to change the color with this command:

blynk.set_property(8,'color','#D3435C')   # red

Enabling logging shows the Blynk server is responding with '200' (OK) but the LED color never changes.

Do I have the command format correct?

Note that I haven't tried other properties, just the color.

ImportError: No module named 'BlynkTimer'

BlynkTimer seems to be broken somehow, cannot import it.

pi@raspberrypi:~/hytta $ python3 main.py
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ for Python v0.2.0 (Linux)

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from BlynkTimer import BlynkTimer
ImportError: No module named 'BlynkTimer'

RPI disconnects

Raspberry pi (any) with ethernet connection.

The code works fine for few minutes then disconnects with no errors.
Tried to set up line 'blynk = BlynkLib.Blynk(BLYNK_AUTH)' to 'blynk = BlynkLib.Blynk(BLYNK_AUTH, insecure= True)' but I get error: AttributeError: 'socket' object has no attribute 'write'

The option 'insecure=True' works fine on ESP32s however.

Any ideas?
TIA

Provide virtual pin number to callback function

Currently the callbacks for each pin must be declared individually and uniquely:

@blynk.VIRTUAL_READ(2)
def v2_read_handler():
    print "This is V2 handler"
@blynk.VIRTUAL_READ(3)
def v3_read_handler():
    print "This is V3 handler"

But there are cases where I want to call a common function, passing in the pin. Something like this (not real code, but the concept):

@blynk.VIRTUAL_READ(2)
def v2_read_handler():
    common_handler(pin)
@blynk.VIRTUAL_READ(3)
def v3_read_handler():
    common_handler(pin)

def common_handler(pin):
    print "This is V{} handler" % pin

This issue is to provide some mechanism to make the pin number available to the callback function.

'Blynk' object has no attribute 'VIRTUAL_READ'

Hi!
I've installed blynk-library-python 0.2.4 and tried to run example, but I've got error

ImportError: No module named BlynkLib

When I've changed name of module to blynklib I've received this error:

AttributeError: 'Blynk' object has no attribute 'VIRTUAL_READ'

Can you help me?

Invalid auth token with both py libraries for Blynk console 2.0

Hi,

Currently both libraries don't work with the new console 2.0.

https://github.com/blynkkk/blynk-library
https://github.com/vshymanskyy/blynk-library-python

I used the token from:
https://blynk.cloud/dashboard/...

import time
import logging
import BlynkLib

BLYNK_AUTH = 'auth code' #insert your Auth Token here

# initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)

# @blynk.on("connected")
# def connect_handler(ping):
#     print('Blynk connected')

# @blynk.on("disconnected")
# def disconnect_handler():
#     print('Blynk disconnected')

print('starting device...')

# main loop that starts program and handles registered events
try:
    while True:
        blynk.run()
except KeyboardInterrupt:
    blynk.disconnect()
    print("Blynk disconnected!")

Error message

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ for Python v0.2.0 (Darwin)

starting device...
Invalid auth token

struct.error: unpack requires a string argument of length 5

When I run the example app and press run the project on mobile I get:

MacBook-Pro-Max:pysense max$ python blynkapp.py
TCP: Connecting to blynk-cloud.com:8442
Blynk connection successful, authenticating...
Access granted, happy Blynking!
Traceback (most recent call last):
  File "blynkapp.py", line 15, in <module>
    blynk.run()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/BlynkLib.py", line 363, in run
    msg_type, msg_id, msg_len = struct.unpack(HDR_FMT, data)
struct.error: unpack requires a string argument of length 5
MacBook-Pro-Max:pysense max$

Here is the example app - https://gist.github.com/litnimax/16a286b6db725c51c905988396ba647f

Python3.5 and BlynkLib v0.2.0: IndexError: list index out of range

Hey. Until the last moment I used the library version 1.3. I wrote a simple Python 3.5 script to send some data to a local blynk server. Everything worked (and works) super. I decided to try BlynkLib for Python version 2.0 (and the Blynk timer library) and I can’t understand what’s the matter. When a mobile application connects, Python script stopped with an Error:
File "/usr/local/lib/python3.5/dist-packages/BlynkLib.py", line 252, in run self.process(data) File "/usr/local/lib/python3.5/dist-packages/BlynkLib.py", line 213, in process self.emit("int_"+args[1], args[2:]) IndexError: list index out of range

Same error - after mobile application was closed (disconnected from local server).
If the application is active and I run the python script, then the data arrives, the widgets work. I close the application - the python script stops with an error.
My system: Raspberry Pi3, Blynk local Server (0.41.12-java8), Python 3.5

Socket Disconnects - Blynk offline

Hi,

I have been running the latest Blynk Python checkin from his repo and continue to see random disconnects. I have 2 separate apps that are making use of Blynk 2.0 and both show similar behavior. They randomly disconnect from the Blynk servers, they show as offline in the mobile application. The apps are running in Docker containers on RPI 4 devices, the containers are running without issue and the writes to the Blynk library are NOT failing, no exception thrown. I suspect the socket level connection is failing and the library may be in a "disconnected" state and "eating" the write requests. If the code issues a disconnect/connect method call the devices comes back online. I noticed in the Blynk library code there are a few places w/"todo" comments on handling disconnects.... so suspect this is known issue that's still open in the core library design. I'm using the latest code checked into this GIT - anyone have ideas on how to fix?

git+https://github.com/vshymanskyy/blynk-library-python@f84633c#egg=blynk-library-python

Unexpected command: 41 on blynk

I get the error Unexpected command: 41 every time I run the below python script ...
Can anyone help?

import BlynkLib
import network
import machine

WIFI_SSID = 'HamzaJraiwi'
WIFI_PASS = 'pass'

BLYNK_AUTH = 'auth'

print("Connecting to WiFi...")
wifi = network.WLAN(network.STA_IF)
wifi.active(True)
wifi.connect(WIFI_SSID, WIFI_PASS)
while not wifi.isconnected():
pass

print('IP:', wifi.ifconfig()[0])

print("Connecting to Blynk...")
blynk = BlynkLib.Blynk(BLYNK_AUTH)

@blynk.on("connected")
def blynk_connected(ping):
print('Blynk ready. Ping:', ping, 'ms')

def runLoop():
while True:
blynk.run()
machine.idle()

Run blynk in the main thread:

runLoop()

Make it work with local blink servee

Hi,
I edited your source to make it connect to a local server. This works good. I can also set values but I am unable to retrieve values from the app.

Maybe I broke something. But connecting to a local instance should be possible as a standard. Also it would be nice to connect own callbacks. I don't like the decorator approach as this is not working when using blynk-python inside instances of my own classes.

os.uname() not supported on Windows

os.uname() function is not supported on Windows platform (I use it for development).
Since it's used only in banner upon library load, it's not crucial IMO and can be replaced by sys.platform, or omitted altogether.

Jurij

ssl error on connection

hi,
i use the script example 01_virtual_write.py on my local server on a pi zero
with the code
blynk = BlynkLib.Blynk(BLYNK_AUTH, server='x.x.x.x', port=8080)
And i have the error below.. i don't know why because i use the same code on another pizero whitout error..
can you help ?
best regards
Alain

Connecting to x.x.x.x:8080...
Traceback (most recent call last):
File "01_virtual_write.py", line 19, in
blynk = BlynkLib.Blynk(BLYNK_AUTH, server='13.59.253.251', port=8080)
File "build/bdist.linux-armv6l/egg/BlynkLib.py", line 214, in init
File "build/bdist.linux-armv6l/egg/BlynkLib.py", line 81, in init
File "build/bdist.linux-armv6l/egg/BlynkLib.py", line 240, in connect
File "/usr/lib/python2.7/ssl.py", line 369, in wrap_socket
_context=self)
File "/usr/lib/python2.7/ssl.py", line 599, in init
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 828, in do_handshake
self._sslobj.do_handshake()
socket.error: [Errno 0] Error

GPIO on ESP8266

In my blynk app I am only able to get virtual pins working with this library, the actual GPIO - GPIO2 is connected to the onboard LED, for example - do not respond to blynk app buttons. Are the GPIO implemented in this library, or just the virtual pins?

Pycom Lopy4 disconnects

Similar to RPI disconnects #58

I'm able to successfully connect to the Blynk Cloud but quickly crash with OSError: [Errno 104] ECONNRESET.
I believe this might be a SSL socket issue when writing in blynk-library-python. I do not get the error when running insecure=True.

Current firmware and blynk-library as of 10-28-2021:
I'm using a Pycom LoPy 4 (1.20.2.r6) which has MicroPython (v1.11-c5a0a97).

Connecting to Blynk...
Connecting to blynk.cloud:443...
Blynk ready. Ping: 9048 ms
Current slider value: 4
V3 value: ['4']
Traceback (most recent call last):
  File "main.py", line 45, in <module>
  File "main.py", line 42, in runLoop
  File "/flash/lib/BlynkLib.py", line 261, in run
  File "/flash/lib/BlynkLib.py", line 141, in process
  File "/flash/lib/BlynkLib.py", line 117, in _send
  File "/flash/lib/BlynkLib.py", line 249, in _write
OSError: [Errno 104] ECONNRESET

Any ideas how to fix this?

Unexpected command: 41

I'm getting "Unexpected command: 41" error each time I start my program, sometimes the program starts correctly but it stops after a few hours (~2h). After that if I try to start the program again I get the error.
I also get the same error when I try the readme example. I tried on a linux desktop computer and on a raspberry pi.
I can see that command 41 is not implemented yet but I haven't seen anyone with my same issue. Could be a problem with my home network? What does the 41 command do?
Thank you

Add support for merged virtual pins

When using the zeRGBa widget in merge mode, three separate calls to the blynk.VIRTUAL_WRITE function are made. Make the VIRTUAL_WRITE wrapper pass the value as a tuple or list to the handler function.

@blynk.VIRTUAL_WRITE(0)
def zeRGBa(value):
    r = value[0]
    g = value[1]
    b = value[2]

    # Do stuff

ESP8266 halting

My ESP8266 intermittently drops out of the main loop after minutes (20 to 40 usually). I tried heartbeat set to 30 and 10. I am running my own local server. The app still sees the blynk server, so I believe the issue is on the ESP8266.

Also, If I kill the blynk local server (to simulate a server reboot or power failure, which will definitely happen), the ESP8266 halts with an error. Is there a way to keep the ESP8266 code running so things get back to normal when the server restarts?

Getting error "Error: Blynk authentication failed, connection closed"

Anyone have an idea what would cause this?

Blynk connection successful, authenticating...
Error: Blynk authentication failed, connection closed

I tried getting a new token from blynk, but had the same error message with the new token. I thought perhaps they disabled non-SSL access, so I tried using the SSL flag, but then got this error message with Python 3:

SSL: Connecting to blynk-cloud.com:8442
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/BlynkLib.py", line 338, in run
ss = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SEC)
AttributeError: module 'socket' has no attribute 'IPPROTO_SEC'

The original connection attempt didn't work in Python 2 either.

Thanks!

-Dan

Invalid Auth Token

I'm getting an invalid authentication token, but I have correctly copied it from my Blynk Dashboard. I am using Blynk 2.0.

how to change to Blynk local server

I've tried this project on my ESP32, it will work well on ESP32 connect to the blynk-cloud.com
But when cahnge the server address to local server ,my server only have ip, no host name.
I change the Line 216

self.conn.connect(socket.getaddrinfo("blynk-cloud.com", 80)[0][4])

to

self.conn.connect(socket.getaddrinfo("192.168.1.101", 80)[0][4])

or

self.conn.connect(socket.getaddrinfo("192,168,1,101", 80)[0][4])

All of these cant work

App keeps on crashing when mobile app was opened or force closed.

App keeps on crashing when I'm opening or force closing the Blynk mobile app where the sample Blynk python code is pointing to. No issue on running the app when the Blynk mobile app is already open.

Running the code using python2 or python3 is giving the same result.
Same error when running lower version of Blynk server (used v0.41.0 or v0.41.0-1).
No issue with my nodejs code using the same platform(I know python library is beta release).

The blynk app is running on Raspberry Pi with Raspbian Stretch Lite and connected to Blynk server v0.41.0-2 running on Ubuntu Server 18.04.2 LTS. Using Blynk v2.25.0 for IOS for control.


UPDATE:
For now I was able to temporary bypass the error when I modify below lines in the BlynkLib.py.

            elif cmd == MSG_INTERNAL:
                try:
                    self.emit("int_"+args[1], args[2:])
                except:
                    pass

CODE:
import BlynkLib
import time
blynk = BlynkLib.Blynk('568d2xxxxxxxxxxxxxxxxxxaadd', server='192.168.xx.xx', port=8080, heartbeat = 30)
@blynk.VIRTUAL_WRITE(0)
def v0_write_handler(value):
print('Current V0 value: {}'.format(value))
@blynk.VIRTUAL_READ(1)
def v1_read_handler():
blynk.virtual_write(1, int(time.time()))
while True:
blynk.run()


ERROR LOG:
Traceback (most recent call last):
File "testblynk.py", line 18, in
blynk.run()
File "/usr/local/lib/python3.5/dist-packages/BlynkLib.py", line 252, in run
self.process(data)
File "/usr/local/lib/python3.5/dist-packages/BlynkLib.py", line 213, in process
self.emit("int_"+args[1], args[2:])
IndexError: list index out of range

Simultaneous VIRTUAL_READ and VIRTUAL_WRITE?

I am using the library installed by pip on my Raspberry Pi Model 3 B+.
Here is the version information:

Name: blynk-library-python
Version: 0.1.3
Summary: Blynk library
Home-page: http://www.blynk.cc
Author: Volodymyr Shymanskyy
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python2.7/dist-packages
Requires:

Looking at the library code, it appears that when VIRTUAL_READ is used on a virtual pin, it sets the write callback to None. Similarly, when using VIRTUAL_WRITE it sets the read callback to None.

I have a need of both a read and write callback on the same virtual pin.
Is there a way to achieve this?

File "<stdin>", line 35, in <module> AttributeError: 'module' object has no attribute 'Blynk'

Hardware: Xbee3 Celllular LTE CAT1

These devices support some form of micro python but when I go to run the program I am getting an error that is slightly over my head....

`MicroPython v1.9.4-927-g7565eb7 on 2018-11-08; XBC LTE Cat 1 Verizon with EFM32G
Type "help()" for more information.

Loading /flash/main.mpy...
Running bytecode...
Waiting for the module to be connected to the cellular network...
Traceback (most recent call last):
File "", line 35, in
AttributeError: 'module' object has no attribute 'Blynk'`

any idea how to fix this or is it the version of MP on the device?

Gavin

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.