[SOLVED] Level Settings Widget and Blynk.setProperty(V0, "color", "HEX value");

Hello Folks,

I have seen the new Level Settings widget does not update its color if sent from the hardware. I have verified I have the right virtual pin and HEX value selected.

Can someone confirm, they have the same issue?



This one works as it is supposed to for me (edit - on Android)… can you show a screenshot and code that you are using?

Hello. We’ll check. Thanks for reporting. Do you mean iOS by the way?

Yes using iOS.

Here is part of my code that is doing a virtual write to V0 and then assigning a color based on the value of the variable.

    // Function to check battery charge
    void battery_level() {
    // read the battery level from the ESP8266 analog in pin.
    // analog read level is 10 bit 0-1023 (0V-1V).
    // our 1M & 220K voltage divider takes the max
    // lipo value of 4.2V and drops it to 0.758V max.
    // this means our min analog read value should be 580 (3.14V)
    // and the max analog read value should be 774 (4.2V).
    int level = analogRead(A0);
    // convert battery level to percent also check if unit is connected to battery or external power
    if (level<=740){
      level = map(level, 550, 740, 0, 100);
      Serial.print("Battery level: "); Serial.print(level); Serial.println("%");
      Blynk.virtualWrite(V0, level);
      if (level >= 50){Blynk.setProperty(V0, "color", "#0C990C");}  // Setting color of bar to Green
      if (level > 20 && level < 50){Blynk.setProperty(V0, "color", "#d69e04");}  // Setting color of bar to Orange
      if (level == 20){Blynk.notify("Battery 20%, pls recharge");Blynk.setProperty(V0, "color", "#e80606");} // Setting color of bar to Red
      if (level == 10){Blynk.notify("Battery 10%, pls recharge");Blynk.setProperty(V0, "color", "#e80606");}// Setting color of bar to Red
      if (level == 2){Blynk.notify("Battery 2%, pls recharge");Blynk.setProperty(V0, "color", "#e80606");}// Setting color of bar to Red
        level = 100; // This assumes unit is connected to external power
        Blynk.virtualWrite(V0, level);
        Blynk.setProperty(V0, "color", "#0c990c");// Setting color of bar to Green

Here are two images from the app. The first shows the widget. The second show the same widget in design mode.

1 Like

Thanks for the report. The bug is that widget won’t change its color if it has a default theme color. We’ll fix that.

As a temporary workaround, just change the widget color from the app before running the project.

Eugene…Thanks for checking into this and for your prompt response. If I do what you told, me the color does change.

Not sure if my issue is related but I’ll start here. After updating app to 2.13.4 (Android) my widget colors are all blue and green. I can change them but when I leave the app and come back they reset to blue/green. I am running local server. The problem happens even if I create a fresh project.

You need to update to the latest server’s version, we had changed color’s parameters work.

Thank you, that worked.

2 posts were split to a new topic: iPhone LCD Widget color set with Blynk.setProperty will reset at App restart