vshymanskyy / blynk-library-python

Blynk library for Python. Works with Python 2, Python 3, MicroPython.
https://blynk.io/
MIT License
287 stars 98 forks source link

Unable to sync manual switch with the blynk app button #78

Open kausarn3 opened 1 year ago

kausarn3 commented 1 year ago

Blynk version = 1.0.0 Code used :

`SWITCH_PIN = Pin(13, Pin.IN, Pin.PULL_UP)
RELAY_PIN = Pin(5, Pin.OUT)

blynk = BlynkLib.Blynk(auth_token) blynk = BlynkLib.Blynk(auth_token)

@blynk.VIRTUAL_WRITE(0) def v0_write_handler(value): global relay_state relay_state = int(value[0]) if relay_state == 1: RELAY_PIN.on() else: RELAY_PIN.off()

def switch_callback(pin): global relay_state relay_state = SWITCH_PIN.value() blynk.virtual_write(0, relay_state) # Update the virtual pin in Blynk if relay_state == 1: RELAY_PIN.on() else: RELAY_PIN.off()

SWITCH_PIN.irq(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=switch_callback)

while True: blynk.run()`

Error: File "boot.py", line 26, in AttributeError: 'Blynk' object has no attribute 'VIRTUAL_WRITE'