vintlabs / fauxmoESP

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

Not an Issue, possible enhancement #110

Closed pvint closed 3 years ago

pvint commented 4 years ago

Original report by HiddenVision (Bitbucket: HiddenVision, GitHub: HiddenVision).


Just a quick thought after getting things to work on My Gen 3 Dot.
Many thanks to @Arpad for his thoughts and Json extracts, worked first time.

I edited the Library so that the name I pass is automatically prep-ended with the Device ID.
I found that programming multiple devices with the same code led to confusion (on my part) as all the names were the same. Obviously the usable name can be edited in Alexa app.
Just thinking this is a cute mod for someone to add into the core code.
I admit I am using EspAlexa Library but I think the logic stands for most Alexa libs.

Example line

EspalexaDevice* d = new EspalexaDevice(deviceName+encodeLightId(currentDeviceCount), callback, initialValue);

//The +encodeLightId(currentDeviceCount) is the bit I added

For example I set the name to “Socket_” or “Light_” and end up with a unique name for every device programmed.
I suspect there is a better method but this worked first time round so I left it be.

Sorry if this upsets anyone.
Hv..

pvint commented 3 years ago

@HiddenVision

I normally just handle this in my code, example:

for (int i = 0; i < 8; i++)
        {
                ESP_LOGI(TAG, "Adding fauxmo device %s %c (%d)", deviceBasename, i + 49, i + 49);
                snprintf(d, 15, "%s %c", deviceBasename, i + 49);
                // TODO - get these from flash
                strcpy( deviceName[i], d);
                fauxmo.addDevice(d);
}

It might be worth thinking about adding an option to do this automatically in the future, however.

Hiddenvision commented 3 years ago

So if you program multiple devices with the same binary will they all have unique names? That was the point of the initial post. I am fully sorted by the added code I suggested so no need for me to add anything new.

Tejas-MD commented 3 years ago

I suggest renaming the issue so we can help find a permanent solution for everyone about the same...

pvint commented 3 years ago

So if you program multiple devices with the same binary will they all have unique names?

Yes. As of a6c0300580a6d570c4d677d8252e990338c213b9 the uniqueid is generated based on a hash of the device's MAC and the name you give to the device.