Open PakoCosmos opened 3 weeks ago
Create a PR. Let's incorporate it. :)
Create a PR. Let's incorporate it. :)
Can't PR this because it is only tested on the echo spot 2024, it requires testing in other models as well. I always give away my old models so I can't test any other at this time. And by the way nobody is going to test this if their software is working :) So, this is just an issue with an ice cream at the end ;)
Good morning. This is exactly the problem I have right now, and I am glad that I found someone working on this. I really dont know what gen is my alexa, but it discover all devices and just assume one. You only see that the others are there when you delete. After the first deleted, the second appear, and so on..... I tried the fix you wrote, but the line on the file fauxmoESP.cpp is different. This is what I have there: snprintf(device.uniqueid, FAUXMO_DEVICE_UNIQUE_ID_LENGTH, "%s:%s-%02X", mac.c_str(), "00:00", device_id); I tried change only "%s:%s-%02X" by "%02X:%s:AB-%02X", but doesn't work. I tried also your line, but no success. Any thoughts what I have to change/do to solve? Thanks,
My mistake. In order to not mess with the original file, I just made a copy maintaining the same extension, so arduino IDE tried to compile both files..... Now it is working. Thanks very much for the solution. I am really glad with this library.
you're my hero bro!!
Thank you to PakoCosmos!!! The ESPalexa Library driven solutions have the same issue. https://github.com/Aircoookie/Espalexa/issues/228
But thanks to your proposed solution I could fix it in my environment. Many thanks!!
Mine was slightly different for some reason? but You definitely helped me once I worked it out!! original is snprintf(device.uniqueid, FAUXMO_DEVICE_UNIQUE_ID_LENGTH, "%s:%s-%02X", mac.c_str(), "00:00", device_id);
I changed it to snprintf(device.uniqueid, FAUXMO_DEVICE_UNIQUE_ID_LENGTH, "%02X:%s:%s", device_id, mac.c_str(), "00:00");
Seems like it looks at the first couple bytes only for ID, I saw it mentioned 12 bytes somewhere I think? In any case with one device and the same mac ID it was only finding one device instead of the 3 I wanted, deleting one would make the next show up and control was random, sometimes if I turned the one device it saw the 2nd or 3rd would change state instead.. Putting the device_id in the front made all 3 devices be discovered and all 3 work prefectly.. One ESP32 for ceiling fan. 1)fan light 2)dual fans and 3)fan rotation motor.. Now I get to wire it up and pat myself on the back and thank you for finding out why it wasn't working!!!
Just to let you know - I am looking at this. I feel I need to do a lot of testing with this to ensure we aren't introducing a new bug.
For those who have tried the above fix(es), please let me know whether it works or not.
Paul
This absolutely has to do with the UniqueID of multiple devices hosted in the same network adapter. Using the adapter's MAC address to calculate the UniqueID of the device and appending a numeric suffix at the end leads to this: AA:BB:CC:DD:EE:FF:00:00:NN (First the MAC, then 00:00:, then the device counter). We end with a 17+8=25 bytes.
What I did, (because I was suspicious of the ID), as the devices seemed to overlap on each other was to assume that the detection algorithm of the alexas only count on the first N-digits (N<=17) of the UniqueID to distinguish between devices. So, at this point I had no other choice than break the rule of the composition of the UniqueID on the code because it would never work with multiple devices.
As I saw other libraries composing the UniqueID in different ways, I thought that I can keep a pseudo-MAC format in it but allowing the ID to be different for each device hosted. So I started ID with the device counter and then appended the MAC, resulting in forcebly different UniqueIDs but still maintaining the 25 byte format that I don't know if it is required for some hardware. Resulting in the UniqueID calculation like this: NN:AA:BB:CC:DD:EE:FF:00:00 (As you see I only move the NN to the beginning from the original code, absolutely no other change). Everything started working since then and I was happy as this kept me mad many hours. Then I posted here my fix hoping to save someone's time.
As this only affects multi-device implementation in my Echo spot (the lib was working without the fix on my old alexa 2ºGen) I would keep the library code as is, but will add a comment or a conditional #define along with a couple lines in the docs just to avoid someone going mad again like me ;-) I have no chance of testing this on older devices at this time.
Happy coding ;-)
Thanks PakoCosmos! This fixed my problem too. I have an ESP8266 which had been working without any problems with Alexa for years, then a few days ago Alexa lost all the devices and no matter how I tried, I couldn't get Alexa to find them again. It may be co-incidence but this happened just after I added an Amazon (Alexa) smart plug. As you say, it may only affect multiple 'devices' on the same mac address - my ESP8266 had 10 pseudo-devices. I spent sometime looking into this until I came across your comment. I updated the library along the lines of your earlier comment and Alexa immediately found all 10 devices. Thanks again. :-)
BTW - I have Echo Gen 1 and Echo Dots 2nd Gen
I updated my old echo dot 2nd Gen for a brand new echo spot 2024 only to find that my multiple 4 relay box stopped working. Deleted all devices and when I tried to add again I could only find one, and operating a random relay each time. This drove me nuts, until I digg into the code, repositories, issues, etc. Finally found that reformating the uniqueid did the trick. Here is what I did on fauxmoESP.cpp:
Changed this line (inside fauxmoESP::addDevice(...)): snprintf(device.uniqueid, 27, "%s:00:00-%02X", mac.c_str(), device_id);
Into this: snprintf(device.uniqueid, 27, "%02X:%s:AB-%02X", device_id, mac.c_str(), device_id);
Now it works flawlessly on my echo spot. Why? I guess that the spot is using only the first N digits of the uniqueid to separate devices, hence a counter in the first digits does the job. I didn't test the echo dot, so, I can only confirm this works on my echo spot with firmware updated at 10-10-2024.
Hope this helps someone.
PD. All devices where detected as philips hue lights.