BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Last state button and blackout

Hello,
I’m using blynk for my home automation. I’m able to turn on and off a lamp but when it is on, a blackout turned it off (and my esp8266). On my phone the button is “ON”.
When the current come on, the phone say “ON” but the lamp is “OFF”. How can I do to syncronize my app?

The code is the siple Blynk button.
Thanks Fabio

Do you want to synchronise the lamp with the app, or the app with the lamp?

To synchronise the lamp with the app then add a BLYNK_CONNECTED() callback and some code to synchronise the pin that your lamp widget is attached to…

BLYNK_CONNECTED()
{
  Blynk.syncAll(); // This synchronises all pins, both digital and virtual - or,
  Blynl.syncVirtial(vPin); // This will just synchronise the specified virtual pin
}

To synchronise the app with the lamp then add a BLYNK_CONNECTED() callback with some different code. This will depend much more on how you’ve written your code, but will look something like this:…

BLYNK_CONNECTED()
{
  Blynk.virtualWrite(vPin, lampsState); // Write the current lampState to the widget
}

If this doesn’t make any sense to you then post your code (correctly formatted with triple backticks - ```) and details of which pin your lamp widget is attached to.

Pete.

Thanks a lot Pete,
it works fine with Blynk.syncAll();
Could I change the message “your device went offline” in another message? For example only “offline”?

Thanks Fabio

No, that are system messages.
Not sure if it’s possible to change if you run a local server.

Pete.

thanks Pete.
Best regards Fabio