handle_event with VirtualPin V0 doesn't work
formatcla opened this issue · 5 comments
starting from example 01_write_virtual_pin.py,
I designed an app with 8 button and i assigned for each
button a virtual pin (starting from V0 to V7)
I set up an handler for each 'write' event, i.e for V0:
@blynk.handle_event('write V0')
def write_virtual_pin_handler(pin, value):
print(WRITE_EVENT_PRINT_MSG.format(pin, value))
the script works for all virtual pin except V0.
Then I tried with wilcard:
@blynk.handle_event('write V*')
def write_virtual_pin_handler(pin, value):
print(WRITE_EVENT_PRINT_MSG.format(pin, value))
and again the script works for all virtual pin except V0.
Hi! I have tried to use V0 pin in write operation by running ./examples/06_terminal_widget.py example and looks everything goes correct. Could you please double check app and script settings. Additionally you can try add logging to script ( see how to do it in ./examples/07_tweet_and_logging.py) if there is some error response from server it will be captured and printed
I made a simple app with one button, virtual pin V0, and ran ./examples/07_tweet_and_logging.py
(I commented out just "tweet code", line 87)
handle_event
metod register write event starting from virtual pin V1 to V32
Registered events: ['write v19', 'write v18', 'write v11', 'write v10', 'write v13', 'write v12',
'write v15', 'write v14', 'write v17', 'write v16', 'write v9', 'write v8', 'write v1', 'write v3',
'write v2', 'write v5', 'write v4', 'write v7', 'write v6', 'write v20', 'write v21', 'write v22',
'write v23', 'write v24', 'write v25', 'write v26', 'write v27', 'write v28', 'write v29',
'write v32', 'write v31', 'write v30']
I think because of code line 311 in blynklib.py v0.2.4
...
for i in range(1, blynk.VPIN_MAX_NUM + 1):
blynk._events['{}{}'.format(event_base_name.lower(), i)] = func
...
If, in example ./examples/07_tweet_and_logging.py, I just define the handler for virtual pin V0, it register write event correctly, and works
Registered events: ['write v0']
...
Event: ['write v0'] -> (0, [u'1'])
[WRITE_VIRTUAL_PIN_EVENT] Pin: V0 Value: '[u'1']'
Event: ['write v0'] -> (0, [u'0'])
[WRITE_VIRTUAL_PIN_EVENT] Pin: V0 Value: '[u'0']'
...
For wildcard events addind I fully agree - there was a bug. Fix was added - you can try it.
Thanks a lot for Your investigation!
For separate even registration as I understand - there is everything fine and you can do it without any issues? Correct?
For separate event registration You are correct, no issue (I don't know why in my first test, event registration for pin V0 didn't work. Now it works also for my first test: maybe there was connection problem with remote server and without logging enabled I didn't have evidence)
Good news! Thanks for your tests and investigations. Will close this issue.