vintlabs / fauxmoESP

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

Wich Alexa device send fire the onsetstate event #217

Open sergio83100 opened 2 years ago

sergio83100 commented 2 years ago

Hello everybody, The issue I have to fix is not a really bug but just a request for enhancement .. Could it be possible to get the Alexa device IP address when the "onsetstate" is fired? This will be very helpfull to associate Hue emulator and Alexa device Thanks by advance for any help ...

pvint commented 2 years ago

Do you mean, for example, printing out the IP of the device (to serial) that sent the command?

You can get that by enabling debugging in fauxmoESP.h with `#define DEBUG_FAUXMO Serial' (but you get a lot of other "noise" as well). Having ability to print it out without being verbose on everything would be useful. I'll try to have a look at this (when I've had my coffee! ;) )

sergio83100 commented 2 years ago

Hello Paul,

Many thanks to consider my request so quickly.

I've 8 Alexa Dot in my house and 8 ESP boards each assigned to one Alexa device regarding Amazon managing. My purpose is, at ESP level, to accept or denie an Alexa device request depending of my own association rules. This will allow to associate or not logically one Alexa device to selected ESP boards, and to interact depending these associations rules.

May be this could be done by adding a parameter in the callback "onsetstate" like: "String alexa_device_ip".

Many thanks again, and ... enjoy your coffee!

sergio83100 commented 2 years ago

Hello Paul,

Finally I made a fork (for my own usage) of your library to reach my needs.

The modification is very simple, in the _onTCPcontrol() routine I just modified the onSetState call back signature by adding the remote IP new argument:

_setCallback(client->remoteIP().toString().c_str(), id, _devices[id].name, _devices[id].state, _devices[id].value);

instead of:

_setCallback(id, _devices[id].name, _devices[id].state, _devices[id].value);

Then I modified in accordance the call back prototype in fauxmoESP.h, and finally I modified my own code to be in accordance withe the new call back signature.

This seems work perfect, but from your point of view is my modification correct?

But I don't know how to keep both call back signatures to garanty the compatibility with already existing code using your library ...

Regards