Prevent blynk.virtual_write triggering write_handler event when manually syncing switch state

Hi

Is it possible to prevent a blynk.virtual_write command (say to a switch) from triggering a write_handler event?

My use case:
After start up, I read a heater state in my app, and want to update the blynk virtual switch to be in the same state - so I blynk.virtual_write

But doing that triggers a write_handler event - which if the heater is on and the virtual switch was off the virtual switch now changing to on causes my code to re-start the heater. This is the behavior I normally want *even if the heater was already on) - however not when trying to sync the virtual switch to the heater current state.

Is there any way to prevent this? I guess I could use a flag within the write_handler so if I have asked for the virtual switch to change state I ignore the subsequent write_handler event. Is there a better method?

Thank you!

It shouldn’t do. Blynk is specifically designed not to do this, to avoid endless loop situations.

Maybe sharing more details would help?

Pete.

Hi Pete

Thanks - and I looked more closely at my code and found I was doing this myself :frowning: