blynk-library icon indicating copy to clipboard operation
blynk-library copied to clipboard

Reset all virtual pin values on a device to default

Open nbolton opened this issue 4 years ago • 8 comments

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

nbolton avatar Sep 04 '21 07:09 nbolton

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

doom369 avatar Sep 04 '21 08:09 doom369

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

nbolton avatar Sep 07 '21 22:09 nbolton

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

doom369 avatar Sep 08 '21 06:09 doom369

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.

nbolton avatar Sep 08 '21 08:09 nbolton

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".

doom369 avatar Sep 08 '21 08:09 doom369

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)

nbolton avatar Sep 08 '21 08:09 nbolton

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?

doom369 avatar Sep 08 '21 08:09 doom369

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).

nbolton avatar Sep 08 '21 11:09 nbolton

Closing, as this is not related to the library

vshymanskyy avatar Mar 04 '23 14:03 vshymanskyy