Alexa app quirky behavior with light switch

Board: NodeMCU 1.0 (ESP-12E Module)
Smartphone: Android
Server: Blynk
Arduino IDE: Mac version
ESP8266 core version: 2.4.2
Blynk Library version: ??
Setup: Wall light switch with a momentary switch, MCU, relay
Contributors: My original idea/code for this project came from @chrome1000; many thanks. Others that I cannot remember contributed to the other functions.
Automation: light can be controlled (1) with the wall switch (2) Blynk app (3) Alexa app or voice commands
Other functions: If I lose my internet connection the code will stop bypass connecting to the Blank server and function as a normal light switch with no automation capability until the internet reconnects.

Issue: When I open the Alex app and I go into the smart home section, all eight of my automated light switches turn on. I go into the Blynk app and it shows all of the lights on. I can then turn them off but if I go back into the Alexa app they turn back on. I can also turn them off in the Alexa app but within 10-20 seconds, they all turn back on.

Research: I found a conversation between @jasperdog and @chrome1000 about this issue but not enough discussion to give me a resolution other than to stay out of the Alexa app unless I need to discover new devices or setup groups and routines.

Thanks in advance for any help on this issue. The code below is from one of my devices. The remaining seven devices you the same code with VPIN and name modifications.

 * Device is controllable with the Blynk app, momentary switch, and Alexa.

//Common libraries
#include <ESP8266WiFi.h>
#include <SimpleTimer.h>

#include "WemoSwitch.h"
#include "WemoManager.h"
#include "CallbackFunction.h"

//WiFiManager specific libraries
#include <DNSServer.h>          //Local DNS server used for redirecting all requests to the configuration portal
#include <ESP8266WebServer.h>   //Local WebServer used to serve as the configuration portal
#include <WiFiManager.h>        //Core library

//ArduinoOTA specific libraries
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

#define VPIN V4  //Use a unique virtual pin for each device using the same token / dashboard
                 //In order to control a multitude of devices with a single Blynk dashboard, each ESP8266
                 //should be programmed with a unique virtual pin assignment, corresponding to a Blynk switch.

char auth[] = “xxxxxxxxxxxxxxxxxxxxxxxxxxx”; //Get token from Blynk
const char* ssid = “xxxxxxxxxxxxxxxxx”; //insert your router SSID
const char* pass = “xxxxxxxxxxxxxxxx”; //insert your router password; set password to "" for open network

//on/off callbacks
void lightOn();
void lightOff();

WemoManager wemoManager;
WemoSwitch *light = NULL;

boolean LampState = 0;
boolean SwitchReset = true;   //Flag indicating that the hardware button has been released

#define TacSwitch D2      //Pin for hardware momentary switch.
#define RelayPin D4      //Relay switching pin.

SimpleTimer timer;

void setup()      
  //WiFi.disconnect(); //Use to erase previous ssid/password then comment out and upload sketch again.
  WiFi.hostname(“xxxxxxxx_xxxxxxx”); //Change the default ESP_#### name of the module
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED)

  // Format: Alexa invocation name, local port no, on callback, off callback
  light = new WemoSwitch("Fireplace Lamp", 80, lightOn, lightOff);

  pinMode(RelayPin, OUTPUT);
  pinMode(TacSwitch, INPUT_PULLUP);
  digitalWrite(RelayPin, LOW);


  timer.setInterval(100, ButtonCheck);

// Handle hardware switch activation
void ButtonCheck()
  // look for new button press
  boolean SwitchState = (digitalRead(TacSwitch));

  // toggle the switch if there's a new button press
  if (!SwitchState && SwitchReset == true)
    //Serial.println("Hardware switch activated");
    if (LampState)

    // Flag that indicates the physical button hasn't been released
    SwitchReset = false;
    delay(50);            //debounce
  else if (SwitchState)
    // reset flag the physical button release
    SwitchReset = true;

// Toggle the relay on
void lightOn() {
    digitalWrite(RelayPin, HIGH);
    LampState = 1;

// Toggle the relay off
void lightOff() {
    digitalWrite(RelayPin, LOW);
    LampState = 0;

void ToggleRelay()
  LampState = !LampState;

  if (LampState)
  else lightOff();

void loop()

@ISheetMaDrawz i had the same issue, i resolved it by downgrading the Blynk library from V0.5.4 TO V0.5.3 and reflashing the board (in your case the NodeMCU). I don’t know what the issue is or why it happens. Good luck. hope this helps.

@Jasperdog So you can go to the “devices” tab of the Alexa app now, and it doesn’t turn on all your Wemo emulation devices? I was pretty certain that this bug had nothing to do with Blynk, but was caused by changes in how the Alexa app communicates with Wemo devices.

That was one of the reasons that I moved from Wemo emulation (WemoManager) to Hue emulation (Espalexa).

@jasperdog, I did as you suggested and downgraded the Blynk library. I’ll have to wait until Christmas to verify as the switches are at a vacation cabin. I may setup a test device before then. I’ll post back with results when able… Thanks.

@chrome1000 do you have some sample code or links for your Hue emulation (Espalexa) implementation. I would like to start implementing dimmers to some of my projects. Thanks.

Yeah, it’s on the same thread as the original Wemo emulation, in my 8 August 2018 post. Here’s the link: