vintlabs / fauxmoESP

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

'class fauxmoESP' has no member named 'onGetState' #236

Closed jsalatiel closed 1 year ago

jsalatiel commented 1 year ago

Hi, to make alexa be able to get the current state for one device, it requires the onGetState callback, but apparently that callback was removed in version 3.0. Any replacement for that ?

jsalatiel commented 1 year ago

https://github.com/vintlabs/fauxmoESP/issues/99

MrGreensWorkshop commented 1 year ago

Hi, please check this commit. It is working for me(gen1 and gen2). If @pvint agrees we can bring to this repo.

jsalatiel commented 1 year ago

I applied your commit, but whats the signature for the onGetState callback? I tried:

  fauxmo.onGetState([](unsigned char device_id, const char * device_name) {

but it does not work:

/home/.../esp32/Arduino/libraries/fauxmoESP-3.4/src/fauxmoESP.h:100:14: note: candidate: void fauxmoESP::onGetState(TGetStateCallback)
         void onGetState(TGetStateCallback fn) { _getCallback = fn; }
/home/.../esp32/Arduino/libraries/fauxmoESP-3.4/src/fauxmoESP.h:100:14: note:   no known conversion for argument 1 from 'setup()::<lambda(unsigned char, const char*)>' to 'TGetStateCallback {aka std::function<void(unsigned char, const char*, bool&, unsigned char&)>}'

exit status 1
MrGreensWorkshop commented 1 year ago

Error explains itself.

This is your definition... fauxmo.onGetState([](unsigned char device_id, const char * device_name) {

This is what error says. no known conversion to -> {aka std::function<void(unsigned char, const char*, bool&, unsigned char&)>}

See the problem? If not, please check how its used here.

jsalatiel commented 1 year ago

Thanks. I am not a programmer per se, so I still have problems to understand those errors. I could not find an example to that onGetState in the link you sent, but i suppose it uses the same args as the onSetState.

MrGreensWorkshop commented 1 year ago

Please check the link again.

jsalatiel commented 1 year ago

I can see the onGetState call back being called and I am returning the correct value afaik. 1 for ON 0 for Off But on alexa I still get "Device doesn't support requested value"

MrGreensWorkshop commented 1 year ago

when you ask "Alexa, is your_device_name is on?" You don't get correct answer. Alexa says "Device doesn't support requested value" Did I understand you right?

what's your Amazon Alexa generation?

Did you try with Alexa app? did you get correct on / off status there?

jsalatiel commented 1 year ago

3rd generation.

The alexa app shows me the message "Device doesn't support requested value". image

"when you ask "Alexa, is your_device_name is on?" Alexa says ( translated from my language ) "Device is not compatible"

I can turn the devices on and off, but since alexa can not detect the current state it makes a two steps thing.

jsalatiel commented 1 year ago

In the onGetState callback I am printing some debug , so I see that alexa is running the getstate.

[ALEXA] 11:16:13 Getting current state for device #0 (buraco 1): ON
[ALEXA] 11:16:18 Getting current state for device #0 (buraco 1): ON
[ALEXA] 11:16:18 Getting current state for device #0 (buraco 1): ON
[ALEXA] 11:16:21 Getting current state for device #0 (buraco 1): ON
[ALEXA] 11:16:21 Getting current state for device #0 (buraco 1): ON
[ALEXA] 11:16:24 Getting current state for device #0 (buraco 1): ON
[ALEXA] 11:16:24 Getting current state for device #0 (buraco 1): ON
[ALEXA] 11:16:27 Getting current state for device #0 (buraco 1): ON
[ALEXA] 11:17:33 Getting current state for device #1 (buraco 2): OFF
MrGreensWorkshop commented 1 year ago

I see, what happens when you tap "buraco 1"? does it shows correct value screen after tapping? as I told you at the beginning

It is working for me(gen1 and gen2)

I don't think I can help more than this. Sorry.

jsalatiel commented 1 year ago

"I see, what happens when you tap "buraco 1"? does it shows correct value screen after tapping" Yes

"I don't think I can help more than this. Sorry." Tks for all your help!

jsalatiel commented 1 year ago

@MrGreensWorkshop I have switched from this repo to FauxmoBelkinPlugfrom your repo and that works great! Well, at least it works for esp32, unfortunatelly on esp8266-esp1 it does not work. ( the devices get not discovered ). Have you ever tested on esp8266 ?

MrGreensWorkshop commented 1 year ago

If you want to discuss about FauxmoBelkinPlug, please open a new discussion with the content you wrote from the link.

jsalatiel commented 1 year ago

I have found the solution in another link for the esp8266. Sharing here: I had to set LwIP variant to "V2 higher bandwidth" I suppose that the "V2 low memory" sending 536 byte packets and "V2 higher bandwidth" sending 1460 byte packets makes the difference here.

Now I have the same code working on both esp32 and esp8266-esp1