Aircoookie / Espalexa

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

Still working a treat on ESP32/8266 ! Thanks. Question : value > 100 ? #191

Closed DadelNet closed 2 years ago

DadelNet commented 2 years ago

Is there any way to get Alexa to accept a value greater than the range 0-100 ?

Anything above and Alexa tells me that "That value is out of range for device blabla!".

I realise that I can upscale from that range but I would really like to have the flexibility to give Alexa larger numbers.

Response would be most appreciated.

Aircoookie commented 2 years ago

Hi! Unfortunately I don't think so, since Espalexa uses the hue protocol, which is only made for lights and thus only offers a brightness range of 0-100% (which is internally mapped to 1-254 by the Echo device already though). Sorry about that.

DadelNet commented 2 years ago

Thanks Aircookie.

DadelNet commented 2 years ago

@Aircookie Ok, I tried this and it looks like there is a double conversion and rounding error going on ! With "Alexa, set Epsilon to 99%", d->getValue() gives 252 (which is 98.8%) and d->getPercent() gives 98, not 99 !
I assume that I need to use d->getValue() and work out the percent by code to avoid this ?

DadelNet commented 2 years ago

Also, I keep getting the [E][WebServer.cpp:633] _handleRequest(): request handler not found every few seconds ...

DadelNet commented 2 years ago

For those who need the exact number given to Alexa, please note that getPercent is incorrect for these values :

Alexa getValue getPercent 91 232 90 93 237 92 95 242 94 97 247 96 99 252 98

As I needed the correct value, I have worked out the correction formula to be : uint8_t Alex = d->getValue() ;
Alex = (Alex == 0 ? 0 : round((float)Alex * 0.396 - 0.842)) ;