blynkkk / blynk-library

Blynk library for IoT boards. Works with Arduino, ESP32, ESP8266, Raspberry Pi, Particle, ARM Mbed, etc.
https://blynk.io
MIT License
3.81k stars 1.38k forks source link

Reset all virtual pin values on a device to default #548

Closed nbolton closed 1 year ago

nbolton commented 2 years ago

There is a way to reset all virtual pin values to 0 (erase data), but I can't see how to reset all of a device's virtual pin values to their default values. This would be useful when, for example, you're working on a testing/staging device in the lab, and you change many of the defaults. Right now, when you go live with a device in the field, you need to manually set all of the virtual pins to the same as the defaults.

It would be helpful if there was a menu option to reset all virtual pin values to default.

Screenshot 2021-09-04 at 08 04 51
doom369 commented 2 years ago

@nbolton hello. Do you mean Wi-Fi settings?

nbolton commented 2 years ago

Oops, I meant virtual pin values (not settings). Edited.

doom369 commented 2 years ago

@nbolton you could try Invalidate feature https://docs.blynk.io/en/blynk.console/templates/datastreams/datastreams-common-settings/invalidate-value

nbolton commented 2 years ago

I have about 50 or so virtual pins on the device, and I need to reset them all to default. Right now, the only workaround is to either use the invalidate feature (as you say), or delete the device and create a new one. Neither of which are particularly ideal.

doom369 commented 2 years ago

It seems like custom logic to me. So what I would do is:

Create new DS, let's say virtual pin 50. Assing button on it. When button is pressed - send the command to the hardware. hardware sets all default values required and sends it back to the server.

Another approach would be to use Scene Automation that will trigger 50 "writes".

nbolton commented 2 years ago

Ok, good idea. I didn't consider that. Is there a way to retrieve the default value for a virtual pin from the Blynk server? Or, would it be better to not use the Blynk default pin value and instead maintain your own set of defaults locally? (e.g. in the code)

doom369 commented 2 years ago

Is there a way to retrieve the default value for a virtual pin from the Blynk server?

You can do it only once on the initial connection with Blynk.sync until you or the user haven't override it. You can store the defaults in persistent memory than on the hardware. But maybe it would make sense to provide an API to fetch the default values. We never had a request like that before.

Or, would it be better to not use the Blynk default pin value and instead maintain your own set of defaults locally? (e.g. in the code)

It's up to you.

Just to clarify - what you need is actually action "Reset virtual pins to default", something like that, right?

nbolton commented 2 years ago

Just to clarify - what you need is actually action "Reset virtual pins to default", something like that, right?

Yes a "Reset virtual pins to default" server-side action would be handy. But, I would say that your custom code solution sounds like it will work for the meantime (I'll give it a try at some point in the future).

vshymanskyy commented 1 year ago

Closing, as this is not related to the library