Skip to content

Commit cae0de6

Browse files
committed
(2.4.2) Fixed discovery
1 parent 1b993b0 commit cae0de6

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Espalexa
2-
version=2.4.1
2+
version=2.4.2
33
author=Christian Schwinne
44
maintainer=Christian Schwinne
55
sentence=Library to control an ESP module with the Alexa voice assistant

src/Espalexa.h

+13-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
/*
1212
* @title Espalexa library
13-
* @version 2.4.1
13+
* @version 2.4.2
1414
* @author Christian Schwinne
1515
* @license MIT
1616
* @contributors d-999
@@ -49,7 +49,7 @@
4949
#include <WiFiUdp.h>
5050

5151
#ifdef ESPALEXA_DEBUG
52-
#pragma message "Espalexa 2.4.1 debug mode"
52+
#pragma message "Espalexa 2.4.2 debug mode"
5353
#define EA_DEBUG(x) Serial.print (x)
5454
#define EA_DEBUGLN(x) Serial.println (x)
5555
#else
@@ -118,7 +118,7 @@ class Espalexa {
118118
case EspalexaDeviceType::color: return "LST001";
119119
case EspalexaDeviceType::extendedcolor: return "LCT015";
120120
}
121-
return "Plug 01";
121+
return "Plug";
122122
}
123123

124124
//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 {
148148
json += "\"type\":\"" + typeString(dev->getType());
149149
json += "\",\"name\":\"" + dev->getName();
150150
json += "\",\"modelid\":\"" + modelidString(dev->getType());
151-
json += "\",\"manufacturername\":\"Espalexa\",\"productname\":\"E" + String(static_cast<uint8_t>(dev->getType()));
151+
json += "\",\"manufacturername\":\"Philips\",\"productname\":\"E" + String(static_cast<uint8_t>(dev->getType()));
152152
json += "\",\"uniqueid\":\""+ WiFi.macAddress() +"-"+ (deviceId+1);
153-
json += "\",\"swversion\":\"2.4.0\"}";
153+
json += "\",\"swversion\":\"espalexa-2.4.2\"}";
154154

155155
return json;
156156
}
@@ -174,7 +174,7 @@ class Espalexa {
174174
}
175175
res += "\r\nFree Heap: " + (String)ESP.getFreeHeap();
176176
res += "\r\nUptime: " + (String)millis();
177-
res += "\r\n\r\nEspalexa library v2.4.1 by Christian Schwinne 2019";
177+
res += "\r\n\r\nEspalexa library v2.4.2 by Christian Schwinne 2019";
178178
server->send(200, "text/plain", res);
179179
}
180180
#endif
@@ -557,6 +557,13 @@ class Espalexa {
557557
return escapedMac;
558558
}
559559

560+
//convert brightness (0-255) to percentage
561+
uint8_t toPercent(uint8_t bri)
562+
{
563+
uint16_t perc = bri * 100;
564+
return perc / 255;
565+
}
566+
560567
~Espalexa(){delete devices;} //note: Espalexa is NOT meant to be destructed
561568
};
562569

src/EspalexaDevice.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ EspalexaDevice::EspalexaDevice(String deviceName, DeviceCallbackFunction gnCallb
2727
_deviceName = deviceName;
2828
_callbackDev = gnCallback;
2929
_type = t;
30+
if (t == EspalexaDeviceType::onoff) _type = EspalexaDeviceType::dimmable; //on/off is broken, so make dimmable device instead
3031
_val = initialValue;
3132
_val_last = _val;
3233
}

0 commit comments

Comments
 (0)