Aircoookie/Espalexa

HELP please, ALEXA does not discover devices.

DuncL opened this issue · 1 comments

DuncL commented

I am very new this and am having trouble getting Alexa to discover my devices.

I am a retired gentleman and my expertise and knowledge is fairly basic.

The url for the my espalexa reports;

Hello from Espalexa!

Value of device 1 (White LED): 0 (Dimmable light)
Value of device 2 (Blue LED): 0 (Dimmable light)

Free Heap: 48784
Uptime: 21966

Espalexa library v2.4.7 by Christian Schwinne 2020

However, the Alexa app does not find them. There are 3 Alexa Dots on my network plus a Phillips Hue hub and various other devices.

my code is below and compiles and uploads fine.

/**********************************************************************************
TITLE: Alexa control 5 channel Relay Module using NodeMCU or ESP32
Click on the following links to learn more.
YouTube Video: https://youtu.be/tIFEtHVLexw
Related Blog : https://easyelectronicsproject.com/esp32-projects/
by Subhajit (Tech StudyCell)

Download the libraries:
https://github.com/Aircoookie/Espalexa

Preferences--> Aditional boards Manager URLs :
https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

Download Board:
For ESP8266 NodeMCU (2.5.1): https://github.com/esp8266/Arduino
For ESP32                  : https://github.com/espressif/arduino-esp32

You can go to http://[yourEspIP]/espalexa to see all devices and their current state.

**********************************************************************************/

#define ESPALEXA_DEBUG
#define ESPALEXA_MAXDEVICES 2
#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include <Espalexa.h>
// define the GPIO connected with Relays
#define RelayPin1 5 //D1
#define RelayPin2 4 //D2
//#define RelayPin3 13 //D7
//#define RelayPin4 14 //D5
//#define RelayPin5 12 //D6

// prototypes
boolean connectWifi();

//callback functions
void firstLightChanged(uint8_t brightness);
void secondLightChanged(uint8_t brightness);
//void thirdLightChanged(uint8_t brightness);
//void fourthLightChanged(uint8_t brightness);
//void fifthLightChanged(uint8_t brightness);

// WiFi Credentials
const char* ssid = "My Device";
const char* password = "My Password";

// device names
String Device_1_Name = "White LED";
String Device_2_Name = "Blue LED";
//String Device_3_Name = "Yellow bulb";
//String Device_4_Name = "Red bulb";
//String Device_5_Name = "CFL bulb";

boolean wifiConnected = false;

Espalexa espalexa;

void setup()
{
Serial.begin(115200);

pinMode(RelayPin1, OUTPUT);
pinMode(RelayPin2, OUTPUT);
// pinMode(RelayPin3, OUTPUT);
// pinMode(RelayPin4, OUTPUT);
// pinMode(RelayPin5, OUTPUT);

// Initialise wifi connection
wifiConnected = connectWifi();

if (wifiConnected)
{
// Define your devices here.
espalexa.addDevice(Device_1_Name, firstLightChanged); //simplest definition, default state off
espalexa.addDevice(Device_2_Name, secondLightChanged);
// espalexa.addDevice(Device_3_Name, thirdLightChanged);
// espalexa.addDevice(Device_4_Name, fourthLightChanged);
// espalexa.addDevice(Device_5_Name, fifthLightChanged);

espalexa.begin();

}
else
{
while (1)
{
Serial.println("Cannot connect to WiFi. Please check data and reset the ESP.");
delay(2500);
}
}
}

void loop()
{
espalexa.loop();
delay(1);
}

//our callback functions
void firstLightChanged(uint8_t brightness)
{
//Control the device
if (brightness == 255)
{
digitalWrite(RelayPin1, HIGH);
Serial.println("Device1 ON");
}
else
{
digitalWrite(RelayPin1, LOW);
Serial.println("Device1 OFF");
}
}

void secondLightChanged(uint8_t brightness)
{
//Control the device
if (brightness == 255)
{
digitalWrite(RelayPin2, HIGH);
Serial.println("Device2 ON");
}
else
{
digitalWrite(RelayPin2, LOW);
Serial.println("Device2 OFF");
}
}

/*void thirdLightChanged(uint8_t brightness)
{
//Control the device
if (brightness == 255)
{
digitalWrite(RelayPin3, HIGH);
Serial.println("Device3 ON");
}
else
{
digitalWrite(RelayPin3, LOW);
Serial.println("Device3 OFF");
}
}

void fourthLightChanged(uint8_t brightness)
{
//Control the device
if (brightness == 255)
{
digitalWrite(RelayPin4, HIGH);
Serial.println("Device4 ON");
}
else
{
digitalWrite(RelayPin4, LOW);
Serial.println("Device4 OFF");
}
}

void fifthLightChanged(uint8_t brightness)
{
//Control the device
if (brightness == 255)
{
digitalWrite(RelayPin5, HIGH);
Serial.println("Device5 ON");
}
else
{
digitalWrite(RelayPin5, LOW);
Serial.println("Device5 OFF");
}
}
*/
// connect to wifi – returns true if successful or false if not
boolean connectWifi()
{
boolean state = true;
int i = 0;

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("Connecting to WiFi");

// Wait for connection
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
if (i > 20) {
state = false; break;
}
i++;
}
Serial.println("");
if (state) {
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
else {
Serial.println("Connection failed.");
}
return state;
}

Your Debug information is below. I have deleted hundreds of the same "Got UDP" statements to make the report shorter.

........
Connected to EE-Hub-J3o4-24
IP address: 192.168.1.253
Constructing device 1
Adding device 1
Constructing device 2
Adding device 2
Espalexa Begin...
MAXDEVICES 2
Done
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 1
ST: urn:schemas-upnp-org:device:ZonePlayer:1
USER-AGENT: Linux UPnP/1.0 Sonos/60.3-82090 (ACR_:samsung:dream2ltexx:SM-G955F)
X-SONOS-DEVICEID: 03e74b96a933db07
X-SONOS-MDPMO
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 1
ST: urn:schemas-upnp-org:device:ZonePlayer:1
USER-AGENT: Linux UPnP/1.0 Sonos/60.3-82090 (ACR_:samsung:dream2ltexx:SM-G955F)
X-SONOS-DEVICEID: 03e74b96a933db07
X-SONOS-MDPMO
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: ssdp:all
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: ssdp:all
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: ssdp:all
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: ssdp:all
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: ssdp:all
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: ssdp:all
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: ssdp:all
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: ssdp:all
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: ssdp:all
MAN: "ssdp:discover"
MX: 3

Responding search req...
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 3

Responding search req...

Responding to description.xml ...

Send setup.xml# Responding to description.xml ... #

Send setup.xmlNot-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights
Body:
AlexaApiCall
ok
l0
lAll
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights
Body:
AlexaApiCall
ok
l0
lAll
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/251384049
Body:
AlexaApiCall
ok
l251384049
1
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/251384049
Body:
AlexaApiCall
ok
l251384049
1
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/251384050
Body:
AlexaApiCall
ok
l251384050
2
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/251384050
Body:
AlexaApiCall
ok
l251384050
2
Got UDP!
Got UDP!
Got UDP!
Got UDP!

Responding to description.xml ...

Send setup.xmlNot-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights
Body:
AlexaApiCall
ok
l0
lAll
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/251384049
Body:
AlexaApiCall
ok
l251384049
1
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights/251384050
Body:
AlexaApiCall
ok
l251384050
2
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights
Body:
AlexaApiCall
ok
l0
lAll
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights
Body:
AlexaApiCall
ok
l0
lAll
Not-Found HTTP call:
URI: /api/2WLEDHardQrI3WHYTHoMcXHgEspsM8ZZRpSKtBQr/lights
Body:
AlexaApiCall
ok
l0
lAll
Got UDP!
Got UDP!
Got UDP!
Got UDP!

Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 1
ST: urn:schemas-upnp-org:device:ZonePlayer:1
USER-AGENT: Linux UPnP/1.0 Sonos/60.3-82090 (ACR_:samsung:dream2ltexx:SM-G955F)
X-SONOS-DEVICEID: 03e74b96a933db07
X-SONOS-MDPMO
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 1
ST: urn:schemas-upnp-org:device:ZonePlayer:1
USER-AGENT: Linux UPnP/1.0 Sonos/60.3-82090 (ACR_:samsung:dream2ltexx:SM-G955F)
X-SONOS-DEVICEID: 03e74b96a933db07
X-SONOS-MDPMO
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 1
ST: urn:schemas-upnp-org:device:ZonePlayer:1
USER-AGENT: Linux UPnP/1.0 Sonos/60.3-82090 (ACR_:samsung:dream2ltexx:SM-G955F)
X-SONOS-DEVICEID: 03e74b96a933db07
X-SONOS-MDPMO
Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 1
ST: urn:schemas-upnp-org:device:ZonePlayer:1
USER-AGENT: Linux UPnP/1.0 Sonos/60.3-82090 (ACR_:samsung:dream2ltexx:SM-G955F)
X-SONOS-DEVICEID: 03e74b96a933db07
X-SONOS-MDPMO
Got UDP!
Got UDP!
Got UDP!
Got UDP!

Thank you in advance for your assitance and advice.

Same happed with me, i just discconected my alexa, when it loaded again it worked