[SOLVED] Tracking button states when using software (blynk app) and hardware buttons at the same time

Hello everyone, I would like to implement a project in which I control an actuator, say a lamp, with both a hardware button (linked to a digital pin of an Arduino) and a software button in the Blynk app (used on more than one device). Ideally, the state of the actuator (e.g. lamp on or off) should be trackable also in the app when I change the state (switch on or off) through the hardware button. In other words, if ,for example, I switch on the lamp by the software switch on the Blynk app (linked to a virtual pin) I have a representation of the actuator state from the switch state. Now I want to track also the actual state in the Blynk app in the case when the actuator state is changed by the hardware button/switch (e.g. the lamp that has been switched on through Blynk gets switched off by the hardware button, or vice versa), if I re-open the Blynk app, I would like the software switch to reflect the actual lamp state, also if this has been changed with the hardware button.

What would be the most elegant way of implementing that?

I could think of a solution using two virtual pins for this, one tracking the state (e.g. on/off and displaying that via an LED widget in the app) and the second one for the actual button (in this case a push button in the Blynk app) and the Arduino code then toggles the actuator based on the actual state (i.e switches the lamp of when it is on and vice versa). However, it would be more elegant to use just one widget with just one Virtual pin on which the Blink switch (instead of a push button) is hooked. Can I set/update from the Arduinio side the state of the virtual pin in such a way that when I open the Blynk app, the switch shows me whether the lamp is on or off regardless how this state was set?

Hi,
It was discussed many times on the forum. Unfortunately, this functionality is not yet implemented. We will inform about it soon.

You can use an alternative. just use virtual pin for toggle and send the state of virtual pin back as led .

BLYNK_WRITE(V0)
{
  y = param.asInt();
  Serial.print(y);
  if ( y == 1)
  {
   digitalWrite(6, HIGH);
  }
  else if ( y == 0)
  {
    digitalWrite(6, LOW);
   }
}


void loop()
{
  buttonack ();
}
void buttonack()
{
  if ( y == 1 && z == 0)
  {
    Blynk.virtualWrite(V12, 255);
    BLYNK_LOG("LED12: on"); 
    z = 1;
  }
  if ( z == 1 && currenttime - buttonled > 30000)
  {
    Blynk.virtualWrite(V12, 255);
    buttonled = currenttime;
  }
  if ( y == 0 && z ==  1 )
  {
    Blynk.virtualWrite(V12, 0);
    BLYNK_LOG("LED12: off");
    z = 0;
  }
    if ( z == 0 && currenttime - buttonled > 30000)
  {
    Blynk.virtualWrite(V12, 0);
    buttonled = currenttime;
  }
}

currenttime loop is for repeated ack

Is this functionality still under construction or available in the mean time (before searching further)?

Any support for this yet?

The support for this feature lays in your code.
Use a physical/virtual button… as long as both buttons change the same var.

@Zach_Bellay we also have a bunch of examples demonstrating how you can do this - https://github.com/blynkkk/blynk-library/tree/master/examples/More

Closing topic as it is outdated and not valid anymore.