Skip to content

Commit

Permalink
(2.4.2) Fixed discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
Aircoookie committed Apr 14, 2019
1 parent 1b993b0 commit cae0de6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 13 additions & 6 deletions src/Espalexa.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
/*
* @title Espalexa library
* @version 2.4.1
* @version 2.4.2
* @author Christian Schwinne
* @license MIT
* @contributors d-999
Expand Down Expand Up @@ -49,7 +49,7 @@
#include <WiFiUdp.h>

#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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<uint8_t>(dev->getType()));
json += "\",\"manufacturername\":\"Philips\",\"productname\":\"E" + String(static_cast<uint8_t>(dev->getType()));
json += "\",\"uniqueid\":\""+ WiFi.macAddress() +"-"+ (deviceId+1);
json += "\",\"swversion\":\"2.4.0\"}";
json += "\",\"swversion\":\"espalexa-2.4.2\"}";

return json;
}
Expand All @@ -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
Expand Down Expand Up @@ -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
};

Expand Down
1 change: 1 addition & 0 deletions src/EspalexaDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cae0de6

Please sign in to comment.