diff --git a/library.properties b/library.properties index 519365b..cf6a0c5 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Espalexa -version=2.4.1 +version=2.4.2 author=Christian Schwinne maintainer=Christian Schwinne sentence=Library to control an ESP module with the Alexa voice assistant diff --git a/src/Espalexa.h b/src/Espalexa.h index a246541..997fada 100644 --- a/src/Espalexa.h +++ b/src/Espalexa.h @@ -10,7 +10,7 @@ */ /* * @title Espalexa library - * @version 2.4.1 + * @version 2.4.2 * @author Christian Schwinne * @license MIT * @contributors d-999 @@ -49,7 +49,7 @@ #include #ifdef ESPALEXA_DEBUG - #pragma message "Espalexa 2.4.1 debug mode" + #pragma message "Espalexa 2.4.2 debug mode" #define EA_DEBUG(x) Serial.print (x) #define EA_DEBUGLN(x) Serial.println (x) #else @@ -118,7 +118,7 @@ class Espalexa { case EspalexaDeviceType::color: return "LST001"; case EspalexaDeviceType::extendedcolor: return "LCT015"; } - return "Plug 01"; + return "Plug"; } //device JSON string: color+temperature device emulates LCT015, dimmable device LWB010, (TODO: on/off Plug 01, color temperature device LWT010, color device LST001) @@ -148,9 +148,9 @@ class Espalexa { json += "\"type\":\"" + typeString(dev->getType()); json += "\",\"name\":\"" + dev->getName(); json += "\",\"modelid\":\"" + modelidString(dev->getType()); - json += "\",\"manufacturername\":\"Espalexa\",\"productname\":\"E" + String(static_cast(dev->getType())); + json += "\",\"manufacturername\":\"Philips\",\"productname\":\"E" + String(static_cast(dev->getType())); json += "\",\"uniqueid\":\""+ WiFi.macAddress() +"-"+ (deviceId+1); - json += "\",\"swversion\":\"2.4.0\"}"; + json += "\",\"swversion\":\"espalexa-2.4.2\"}"; return json; } @@ -174,7 +174,7 @@ class Espalexa { } res += "\r\nFree Heap: " + (String)ESP.getFreeHeap(); res += "\r\nUptime: " + (String)millis(); - res += "\r\n\r\nEspalexa library v2.4.1 by Christian Schwinne 2019"; + res += "\r\n\r\nEspalexa library v2.4.2 by Christian Schwinne 2019"; server->send(200, "text/plain", res); } #endif @@ -557,6 +557,13 @@ class Espalexa { return escapedMac; } + //convert brightness (0-255) to percentage + uint8_t toPercent(uint8_t bri) + { + uint16_t perc = bri * 100; + return perc / 255; + } + ~Espalexa(){delete devices;} //note: Espalexa is NOT meant to be destructed }; diff --git a/src/EspalexaDevice.cpp b/src/EspalexaDevice.cpp index da4aa69..43ad6f0 100644 --- a/src/EspalexaDevice.cpp +++ b/src/EspalexaDevice.cpp @@ -27,6 +27,7 @@ EspalexaDevice::EspalexaDevice(String deviceName, DeviceCallbackFunction gnCallb _deviceName = deviceName; _callbackDev = gnCallback; _type = t; + if (t == EspalexaDeviceType::onoff) _type = EspalexaDeviceType::dimmable; //on/off is broken, so make dimmable device instead _val = initialValue; _val_last = _val; }