Blynk.syncAll not working for timer widget output

Hi There!

Blynk.syncAll() is not syncing the timer widget output. What I noticed is, for example, if I set the timer widget start at 6pm and stop at 10pm and if there is a power interruption at 7pm, selected output of the widget(virtual/digital) won’t go high(to previous state) after the power restoration. This senario is absolutely working fine for button widget, ONLY issue with timer output.

1 Like

Hello. Issue is already fixed and will be deployed very soon. If you are using local server you may try 0.16.3 version with fix.
Issue - https://github.com/blynkkk/blynk-server/issues/245

1 Like

Thanks for your quick reply! BTW, I am not using local server.

1 Like

Hey @Dmitriy

Do we need to be running under local server in order to benefit from the blynk.syncAll function? I haven’t set up my server yet but am trying to capitalize on the sync all function but am not having enough luck.

Much like @Lavan, I’m trying to avoid any hick ups that can incur if the timer widget’s cycle is unexpectedly hindered, e.g. power going out before or after either high/low data transfers. I followed the link to (https://github.com/blynkkk/blynk-library/blob/master/examples/More/Sync/Sync.ino) and copy/pasted the script into a javascript file through the linux terminal/command. When I attempt to activate/implement the script and function, I get a syntax error message declaring multiple illegal tokens. Is this normal?

Any insight would be much appreciated.

Here’s the response I get after trying to run the script:

pi@raspberrypi:~ $ sudo js syncall.js

/home/pi/syncall.js:1
(function (exports, require, module, __filename, __dirname) { #define BLYNK_PR
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions…js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
pi@raspberrypi:~ $

I’m still relatively noobish to the Pi, as well Blynking :wink:

Hi!
I wonder if syncing timer state was fixed because it still doesn’t work

Timer on V0

V0 doesn’t sync (doesn’t run BLYNK_WRITE(V0) ) neither with Blynk.syncAll()
or Bynk.syncVirtual(vPin)

(Other V pins sync OK)

Hi.

Yes. It was fixed.

Probably your timer wasn’t triggered yet. In that case this is correct.

No, it doesn’t sync even when there is data on server, I’ve checked http://blynk-cloud.com/*****************/get/V0
Neither when is 0 nor 1.

Do you use local server? Latest app version?

No I use your server, latest iOS app (2.08.2017) and latest blynk library

How do you check that?

BLYNK_WRITE(V0)
{
  // You'll get HIGH/1 at startTime and LOW/0 at stopTime.
  // this method will be triggered every day
  // until you remove widget or stop project or
  // clean stop/start fields of widget
  timerState = param.asInt();
  Serial.print("V0 in sync: ");
  Serial.println(timerState);
} 

there is no response on Serial neither after boot, network connection, not even if I call every 1 minute
Blynk.syncVirtual(V0);

if I change V pin number to other than timer widget there is respond on serial like for example

BLYNK_WRITE(V16)  // slider on V16 to set value
{
  moisture_alarm = param.asInt();
  Serial.println(moisture_alarm);
 }

Hm… Interesting. Please try to remove and add widget again. Does that help?

I did that multiple times, that didn’t help.
I’ve also just found out that history graph doesn’t show V0 values when it is send by Timer

I noticed that syncing doesn’t work for Virtual Pins that have no representation in widgets in app:

If I write some data by Blynk.virtualWrite(V2, timerState); I can’t sync V2 (syncing doesn’t run BLYNK_WRITE(V2) with confirmation on serial [as in example 2 posts before]) until I add widget on this pin although data is correctly written to server and I can see it using http://blynk-cloud.com/********/get/V2.

Seems like this might be the problem with Timer widget - maybe it doesn’t represent itself in app continuously, only when it changes state.

I also found weird behaviour

/*************************************************************
This runs on NodeMCU.
LED on V4
Timer on V5
/*************************************************************/

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "******";
char ssid[] = "*****";
char pass[] = "****";

void setup()
{

  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  
}
BLYNK_CONNECTED() {
  Serial.println("connected");
  
  //First try this and read serial
  Blynk.syncAll();
  Serial.println("syncAll");

  //Then comment 2 lines above, and uncommet 2 lines below and read serial
  //Blynk.syncVirtual(V4, V5);
  //Serial.println("syncVirtual V4, V5");

  //Then comment 2 lines above, and uncommet 2 lines below and read serial
  //Blynk.syncVirtual(V5, V4);
  //Serial.println("syncVirtual V5, V4");
  
}

BLYNK_WRITE(V5) //Timer on V5
{
  // You'll get HIGH/1 at startTime and LOW/0 at stopTime.
  Serial.println("V5 Timer in sync ");
  Serial.print("Got a value: ");
  Serial.println(param.asInt());
  if (param.asInt() == 0) 
      {
      Blynk.virtualWrite(V4, 0);
      Serial.println("LED OFF");
      }
    else
      {
      Blynk.virtualWrite(V4, 255);
      Serial.println("LED ON");
      }

}

BLYNK_WRITE(V4)  //LED on V4
{
  Serial.print("V4 LED in sync: ");
  Serial.println(param.asStr());
}

void loop()
{
  Blynk.run();
}

Case 1

[26207] Connecting to blynk-cloud.com:8442
[26569] Ready (ping: 1ms).
connected
s <—— this should be syncAll (???) and then serial doesn’t show anything even when timer changes state

Case 2

[26209] Connecting to blynk-cloud.com:8442
[26437] Ready (ping: 1ms).
connected
syncVirtual V4, V5
V4 LED in sync: 0
<—— no response from BLYNK_WRITE(V5) but serial works

Case 3

[24200] Connecting to blynk-cloud.com:8442
[24480] Ready (ping: 1ms).
connected
syncVirtual V5, V4
V4 LED in sync: 0
<—— no response from BLYNK_WRITE(V5) but serial works

(I don’t know if there is any difference in syncVirtual(V4, V5) and syncVirtual(V5, V4)