Reset widget color to original after calling setProperty("color")

Hi Blynk Team!

I’ve got an idea that haven’t seen on the forum (I’ve searched, honestly)

It would be great to have an ability to reset widget color to default after it was changed with setProperty(“color”, xxx).

Consider scenario: changing a parameter in device takes some time; you’d like to indicate a “pending apply” state for a numeric input widget after user has tapped + or -; for this you set its color to gray; when value has been applied, you’d like to revert the color back to original.

Currently, the only solution is hardcoding colors in a device, which is not good.

1 Like

You can pick almost unlimited colours with the new colour picker in the App… if anything needs to be added it is the resultant #HEX code.

But as far as “default”, that is Blynk Green, and if you are going to change it from code, then resetting it from code is the better solution. If you set a different colour from code, then again, changing it back and forth is best from code.

Under “default color” I mean the one set through widget’s settings in the app.

Probably it would be more clear with pseudo-code:

setProperty(v0, “color”, #555555);

// smth for a long time...

setProperty(v0, “color”, super_constant_that_resets_widget_color_to_original); // I don't know the original color, but I want to set it back!
1 Like

As there is no mechanism for reading the current colours of the widget via code (except through an API call that returns the whole JSON definition for the project) then its not possible to know what colour settings have been set by editing the app.

The question is very similar to this one:

and the answer is also the same…
Give the app user a colour picker to set the widget colours (I guess multiple ones would be needed as there are on and off and background and text colours to set) and update the properties via code when these change.
Some validation would be needed to ensure that the users doesn’t choose the same text and background colours.


Thank for your suggestion with colour picker, Pete. Unfortunately it is not always possible, especially when you have many widgets with different colors.

My idea does not necessarily require reading the current colours of the widget via code (indeed, it would be possible to implement it if we had that function).

The problem is though that unless you want to call the default green for example that Blynk doesn’t know what ‘default’ is.

When setting a ‘default’ colour in the app, all that is actually happening is that the app effectively sets the color property and sends it to the server.
The standard colours that can be picked from the app just make it easier to pick a colour rather than setting them by code.

So for example if you chose the red colour in the app in widget settings, it sets the colour to the server for the ‘color’ property.

1 Like

I think it does. As @JustBertC has pointed-out, the colours chosen by a user when they stop the app and pick a different colour scheme aren’t a ‘default’, they are just a different selection that can’t (currently) be read from code unless you use the /project API. Without knowing what colours the user has picked, it’s not possible to restore them via code.


I think at application startup you could store an array of all the widgets colours. Then user would be able reset to default. The array would only be 255 items long

I also have this exact requirement