Aircoookie/Espalexa

Alexa only identifies 1 of 4 devices, the others are not visible in the app.

Opened this issue · 5 comments

I used the "EspalexaBasic" example with 4 devices (Garage, Hall, Kitchen and Living Room). When I command to locate the devices, only "Hall" was found, in the Alexa app, only Hall was available.
But if I give the command to turn on the Garage, the Kitchen or the Living Room, Alexa accepts the command but activates "Hall" for all of them.

Code below
`#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include <Espalexa.h>

// 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);

// Change this!!
const char* ssid = "xxx";
const char* password = "yyy";

boolean wifiConnected = false;

Espalexa espalexa;

EspalexaDevice* device3; //this is optional

void setup()
{
Serial.begin(115200);
// Initialise wifi connection
wifiConnected = connectWifi();

if(wifiConnected){

// Define your devices here. 
espalexa.addDevice("Device 1", firstLightChanged);
espalexa.addDevice("Device 2", secondLightChanged);
espalexa.addDevice("Device 3", thirdLightChanged);
espalexa.addDevice("Device 4", fourthLightChanged);

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) {
Serial.print("Garage changed -> " + brightness);
}

void secondLightChanged(uint8_t brightness) {
Serial.print("Hall changed -> " + brightness);
}

void thirdLightChanged(uint8_t brightness) {
Serial.print("Kitchen changed -> " + brightness);
}

void fourthLightChanged(uint8_t brightness) {
Serial.print("Living room changed -> " + brightness);
}

// 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;
}`

Pretty sure this is your issue, was with us: https://github.com/Aircoookie/Espalexa/issues/url

Hola @ltavasilva , encontré una solución, estaba leyendo mismo tema en la librería de FAUXMO, entonces la solución es muy similar,
Debes entrar a tus librerias/espalexa/src/espalexa.h
y modificar el identificador dispositivos.

en el método encodeLightId, remplazar la linea que asigna el ID,
Linea anterior: sprintf_P(out, PSTR("%02X:%02X:%02X:%02X:%02X:%02X:00:11-%02X"), mac[0],mac[1],mac[2],mac[3],mac[4],mac[5], idx);
Nueva linea: sprintf_P(out, PSTR("%02X:%02X:%02X:%02X:%02X:%02X-%02X-00:11"), mac[0],mac[1],mac[2],mac[3],mac[4],mac[5], idx);

solo eso, y volver a compilar:
Nota: al inicio tardaba en encender/apagar algún dispositivo (60seg aproximadamente), luego ya se estabilizo y funciona sin problema alguno.

Gracias! Just replaced my router, and suddenly had the same problem. You saved me.

Gracias! I had the same issue, this trick resolved it!

Hello @ltavasilva, I found a solution, I was reading the same topic in the FAUXMO library, so the solution is very similar,
You must enter your libraries/espalexa/src/espalexa.h
and modify the device identifier.

Open espalexa.h in an editor and search for encodeLightId

in the encodeLightId method, replace the line that assigns the ID,

Replace this line : sprintf_P(out, PSTR("%02X:%02X:%02X:%02X:%02X:%02X:00:11-%02X"), mac[0],mac[1],mac[2 ],mac[3],mac[4],mac[5], idx);

With this line: sprintf_P(out, PSTR("%02X:%02X:%02X:%02X:%02X:%02X-%02X-00:11"), mac[0],mac[1],mac[2 ],mac[3],mac[4],mac[5], idx);

save the espalexa.h file and upload your sketch again, the on Alexa app discover the devices again you will see all the devices.
give it a little time and you will see "ON" buttons with the devices