Aircoookie / Espalexa

Alexa voice control for ESP8266/ESP32 (including brightness and color!)
MIT License
548 stars 137 forks source link

More than one esp8266 led controller is not working #153

Open Edding300 opened 3 years ago

Edding300 commented 3 years ago

Hello everyone, i have built two led strip controllers, each with an es8266 and with almost the identical code as the EspalexaColor example (identical code on both devices). My problem is, that i can always only use one device. I can have both active at the same time, but alexa only controlls one. I need to delete the functioning device and search for new devices to have the 2. one functioning. I am using an Alexa echo dot 3.gen.

Imma get a beer. Cheers.

barneyz commented 3 years ago

You cannot use the identical code. You must rename one device-name ("roomleftlight" in controller 1 and "roomrightlight" in controller 2 for example) and group them together in the alexa-app("roomlight"). Then you can switch the two devices the same time with "alexa switch roomlight on".

mrhill commented 3 years ago

I discovered a similar problem when connecting multiple ESP boards to Alexa Echo Gen3 -- I can control the individual devices, but I cannot simultaneously add them into Alexa groups. Alexa remembers only one device in a group.

The issue seems that Echo identifies Hue devices by their dictionary index returned from the /api/api/lights endpoint, at least for the purpose of grouping. Currently Espalexa simply enumerates devices starting at 1, and returns that as the device key. So if you have multiple ESPs running Espalexa, the devices clash on their index key. Effectively Alexa supports only 1 Philips device Hub, which makes sense as nobody would own multiple hubs.

It also seems that Echo Gen3 ignores the device uniqueId as well as the UDN -- I found out by re-flashing my ESP with a different uniqueId + UDN hashing algorithms, and I could still control the devices which were registered previously with the older build image. Maybe uniqueId is used during discovery, but for operation Echo Gen3 appears to index devices only with their IP + dict key.

fauxmoESP suffers from the same problem.

I attempted a fix here, which works for me: https://github.com/Aircoookie/Espalexa/pull/156

mrhill commented 3 years ago

Any chance to get the fix merged? This will allow multiple ESP boards to connect to Alexa.

pcb1962 commented 3 years ago

I've tested @mrhill's fix, works for me.