vintlabs / fauxmoESP

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

Need to SetState on my fauxmo device #59

Closed pvint closed 5 years ago

pvint commented 5 years ago

Original report by Jason Childress (Bitbucket: Jasonchildress, GitHub: Jasonchildress).


I'm working on a simple project where I want to be able to control the light bulb of a simple dumb-lamp by voice and by button.

I'm using fauxmoESP to turn on a test LED by voice (which is working great). And then I've added a button to my circuit which also controls the test LED.

My problem is when using the button, there is no signal to fauxmo to let it know that light's state know it has changed. This leads to my Alexa app telling me the light is still on when it really isn't. There is no syncing between the two methods.

Is there any way to set the state on my fauxmo object so that pressing the button will go through the same code path as using voice? I don't see any form of setState or setDeviceState in the cpp file.

If this isn't possible now, adding a setState(deviceId, state) function would be useful.

pvint commented 5 years ago

Original comment by Carsten Jungfleisch (Bitbucket: carsten_j, ).


Hello Xose, your library is a perfect piece of software... but I miss the same thing. I'm no programming-professional, but I got a realy cool ESP-program with your library to work.

I want to control a device with a physical button with Alexa and MQTT. If I switch the device over MQTT or physical, I have no idea how to update the state in Alexa-App.

Thank you! Carsten

pvint commented 5 years ago

Original comment by Xose Pérez (Bitbucket: [Xose Pérez](https://bitbucket.org/Xose Pérez), ).


I'm not sure this can be done. Alexa devices issue pull requests, I don't know how to "push" info to them.

pvint commented 5 years ago

Original comment by Carsten Jungfleisch (Bitbucket: carsten_j, ).


Hello Xose, I searched a lot and I found also out, that pushing is not possible. But Alexa is asking very often for the state. And with your old version I was able to aswer with onGetState. I checke your sources, but I did not find any hint for onGetState in the New Version. Do you have perhaps an example?

Thank you! Carsten

pvint commented 5 years ago

Original comment by Xose Pérez (Bitbucket: [Xose Pérez](https://bitbucket.org/Xose Pérez), ).


OK Just added a setState method to dev branch that changes the internal state and value of the devices so they will be correctly reported on next Alexa pull request. You can use device_id or device_name:

fauxmo.setState("kitchen light", true, 128);
pvint commented 5 years ago

Original comment by Carsten Jungfleisch (Bitbucket: carsten_j, ).


Xose, you are the best!