vintlabs / fauxmoESP

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

Bug in removeDevice method #175

Open yanivps opened 3 years ago

yanivps commented 3 years ago

Hello If I'm not wrong, there is a bug in the removeDevice method.

The way device IDs work is that they are merely indices in the vector The problem with this is that if I have 4 devices and I remove device num #2, device #3 then becomes the original device #4 Example:

byte devId1 = fauxmo.addDevice("Device 1");
byte devId2 = fauxmo.addDevice("Device 2");
byte devId3 = fauxmo.addDevice("Device 3");
byte devId4 = fauxmo.addDevice("Device 4");
char buff[50];
fauxmo.getDeviceName(devId3, buff, sizeof(buff));
Serial.println(buff); // prints "Device 3"
fauxmo.removeDevice(devId2);
fauxmo.getDeviceName(devId3, buff, sizeof(buff));
Serial.println(buff); // prints "Device 4"