vintlabs / fauxmoESP

Add voice control of your ESP32 and ESP8266 devices using Amazon Alexa
MIT License
383 stars 69 forks source link

Duplicate devices entries #67

Closed pvint closed 3 years ago

pvint commented 5 years ago

Original report by Venkatesh E (Bitbucket: [Venkat E](https://bitbucket.org/Venkat E), ).


I add device on ESP8266 code with fauxmo.addDevice("hall light"); But after sometimes or some days I see the "hall light" name is duplicated in my Amazon Alexa device ( I use 2nd gen) and when I open Alexa app on my Android phone, I can see the "hall light" duplicate entries. I need to remove them manually to make "hall light" work.

In some cases I used to restart my esp8266 and amazon alexa device too.

I am using the same code provided in this library example. What could be wrong ? Thanks

pvint commented 5 years ago

Original comment by Xose Pérez (Bitbucket: [Xose Pérez](https://bitbucket.org/Xose Pérez), ).


If the device ID is unique it should not duplicate the names, unless you actually have two different devices reporting the same name... What is your setup? Do you have more than one Alexa device?

pvint commented 5 years ago

Original comment by Venkatesh E (Bitbucket: [Venkat E](https://bitbucket.org/Venkat E), ).


Sorry for getting back on this so late.

Actually I have tested this library on two different ESP8266 boards and each having only "addDevice()" entry with different names. So whenever I tried to scan for new devices, I see duplicate entries of two devices in alexa app and it keeps on adding duplicate entries for the same name. Any idea what I might be doing wrong ? Thanks.

This is the code snippet I used in my code.

#!arduino

// call on  after wifi connected
void registerAlexa() {

    alexa_registered = true; // don't add it again

    fauxmo.enable(true);
    fauxmo.enable(false);
    fauxmo.enable(true);

    fauxmo.addDevice(LIVING_ROOM_LIGHT_TWO);

    // fauxmoESP 2.0.0 has changed the callback signature to add the device_id,
    // this way it's easier to match devices to action without having to compare strings.
    fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
        Serial.printf("[MAIN] Device #%d (%s) state: %s value: %d\n", device_id, device_name, state ? "ON" : "OFF", value);
        // digitalWrite(LED, !state);
        if (strcmp(device_name, LIVING_ROOM_LIGHT_TWO) == 0) {
          state ? switchBoxNode.switchRelay(8, "true") : switchBoxNode.switchRelay(8, "false");
        } 
    });
}
pvint commented 3 years ago

Closing stale issue. Please reopen if this is still an issue.