The new official Blynk library v0.2.0 for Python is released and available via github and pip.
It contains better support for ESP32 boards and Raspberry Pi, API improvements.
In fact, the library was completely rewritten, as previous version had too many problems.
Everything im testing works great. I found once i got into it, it was hard to stop playing
notes: the timer lib wasnt included with the main lib when i ran the pip install. no big deal, just copied them over.
table.widget support and email would be my only requests from this library.
I agree⊠something about Python, itâs syntax, and the speed/simplicity of âedit, save, run/test, edit, save, run/testâŠâ (well, at least on a RPi) is a refreshing change from the Arduino IDE method.
I am finally even able to use Python 3.x
I looks like it is on its way⊠at least this small part of it is referenced in the library
Like with BlynkTimer, clearly a work in progress, so keep updating as and when it looks like updates are released.
In the tweet_notify.py library example (or when checking a response from a button), if value[0]: # is the the button is pressed?
checks for a string â0â or â1â for being a âlistâ so, the correct syntax should be if (value[0] == '1'): # the button is pressed?
@vshymanskyy what do you mean with the note on line 70 of the BlynkLib These are mainly for backward-compatibility you can use âblynk.ON()â instead because blynk.ON doesnât substitute âVIRTUAL_WRITE/READâ, right?
Also, virtual pins (blynk, pin) are always treated as strings, right?
Hi @vshymanskyy, With the following test code I converted the old â@blynk.VIRTUAL_WRITEâ function to the new one â@blynk.ONâ as per the libraryâs note
These are mainly for backward-compatibility you can use âblynk.ON()â instead
However, I noticed an inconsistency with the type of variable it can be used. At times an array is admitted and at time itâs not.
#!/usr/bin/python3
#import libraries
from __future__ import print_function
import BlynkLib
from BlynkTimer import BlynkTimer
from subprocess import check_output
import logging, time, gc
from datetime import datetime as dt
logging.basicConfig(filename='/home/pi/blynk.log',level=logging.DEBUG)
BLYNK_AUTH = '****'
# Initialize Blynkxy
blynk = BlynkLib.Blynk(BLYNK_AUTH)
#virtual pins array
v_arry = ['0','1','V2','V3'] #<--- 'V2' works but not 'V3'
#*** old format ***
@blynk.VIRTUAL_WRITE(v_arry[0])
def btn0_handler(value):
btn0status = value[0]
if btn0status == '1':
print('btn v0 pressed')
time.sleep(.1)
else:
print('btn v0 released')
@blynk.VIRTUAL_WRITE(v_arry[1])
def btn1_handler(value):
#security check
#btn1 is activated only when btn0 is being pressed
if value[0] == '1':
print('btn v1 pressed')
#*** new format ***
@blynk.ON("connected")
def blynk_connected(ping):
print('Blynk ready. Ping:', ping, 'ms')
@blynk.ON(v_arry[2])
def btn2_handler(value):
if(value[0] == '1'):
print('btn v2 pressed')
@blynk.ON('readV*') #is this correct?
def uptime_handle(V3): #won't accept an array
gc.collect()
#get board total uptime
cmd = 'uptime -p'
t = check_output(cmd, shell = True).decode("utf-8")
t = t.rstrip('\n\r')
t = t.replace('up','')
blynk.virtual_write(V3, t)
if __name__ == "__main__":
while True:
try:
blynk.run()
except IOError as e:
if(e.errno == errno.EPIPE):
logging.exception("msg from blynkmain @ " + str(dt.now()))
I think they are bothe âofficialâ in the sense that they are mostly written by Blynkâs own @vshymanskyy⊠but the newest copy/version (0.2.4) is now under the Blynkkk GitHub banner as of a couple of months ago, probably making it the new, new official version
I see⊠well, I donât want to mess up my installation with any potentially conflicting code, so I will stick with just your official 0.2.0 Hope you do keep it updated as needed.
@Emilio during the test phase we run local Python to cloud based Blynk server but we also have remote Python server to a separate cloud based Blynker server. The second scenario is basically our production model after testing.
Problem: blynk.set_user_task(my_user_task, 3000)
AttributeError: âBlynkâ object has no attribute âset_user_taskâ
Question: what to do so with the attribute error,can someone answer me??