ExtendedColor device showing as "Color" device in Alexa app
KtotheF opened this issue · 0 comments
Thanks so much for this library! I was able to get a simple, dimmable light setup last night (via Adafruit HUZZAH Esp32 and a strip of RGBWW LEDs) but am today trying to get it recognized as an ExtendedColor device without any luck. Here's my code:
`#define ESPALEXA_ASYNC
#include <Espalexa.h>
#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
#include <AsyncTCP.h>
#include <Adafruit_NeoPixel.h>
#define WIFI_SSID ""
#define WIFI_PASS ""
#define SERIAL_BAUDRATE 115200
#define PIN 26 // 2 for bar lights
#define NUMPIXELS 169 // 286 bar lights
#define DEFAULT_BRIGHTNESS 255
boolean connectWifi();
//callback functions
void firstLightChanged(EspalexaDevice* dev);
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRBW + NEO_KHZ800);
boolean wifiConnected = false;
EspalexaDevice* tv;
Espalexa espalexa;
void setup()
{
Serial.begin(115200);
pixels.begin();
pixels.setBrightness(127);
pixels.show();
// Initialize wifi connection
wifiConnected = connectWifi();
if(wifiConnected){
// Define your devices here.
tv = new EspalexaDevice("TV Room Lights", firstLightChanged, EspalexaDeviceType::extendedcolor); //color + color temperature
espalexa.addDevice(tv);
tv->setValue(DEFAULT_BRIGHTNESS); //creating the device yourself allows you to e.g. update their state value at any time!
flashPixels(0, NUMPIXELS-1, 0, 0, 0, DEFAULT_BRIGHTNESS);
espalexa.begin();
} else {
while (1) {
Serial.println("Cannot connect to WiFi. Please check data and reset the ESP.");
delay(2500);
}
}
}
void loop()
{
espalexa.loop();
delay(1);
}
void firstLightChanged(EspalexaDevice* d) {
if (d == nullptr) return;
Serial.println("");
Serial.print("TV ROOM LIGHTS changed to ");
Serial.print(d->getValue());
Serial.print(" ");
Serial.print(d->getPercent());
Serial.println("%");
Serial.print("colortemp ");
Serial.print(d->getCt());
Serial.print(" (");
Serial.print(d->getKelvin()); //this is more common than the hue mired values
Serial.println("K)");
Serial.print("color R ");
Serial.print(d->getR());
Serial.print(", G ");
Serial.print(d->getG());
Serial.print(", B ");
Serial.print(d->getB());
Serial.print(", colormode ");
switch(d->getColorMode())
{
case EspalexaColorMode::hs:
Serial.print("hs, "); Serial.print("hue "); Serial.print(d->getHue()); Serial.print(", sat "); Serial.println(d->getSat()); break;
case EspalexaColorMode::xy:
Serial.print("xy, "); Serial.print("x "); Serial.print(d->getX()); Serial.print(", y "); Serial.println(d->getY()); break;
case EspalexaColorMode::ct:
Serial.print("ct, "); Serial.print("ct "); Serial.println(d->getCt()); break;
case EspalexaColorMode::none:
Serial.println("none"); break;
}
}
// connect to wifi – returns true if successful or false if not
boolean connectWifi(){
boolean state = true;
int i = 0;
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
Serial.println("");
Serial.println("Connecting to WiFi");
// Wait for connection
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
if (i > 20){
state = false; break;
}
i++;
}
Serial.println("");
if (state){
Serial.print("Connected to ");
Serial.println(WIFI_SSID);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
else {
Serial.println("Connection failed.");
}
return state;
}
void flashPixels( int from_pixel, int to_pixel, uint8_t to_r, uint8_t to_g, uint8_t to_b, uint8_t to_w ) {
for( int i = from_pixel; i <= to_pixel; i++ ) {
pixels.setPixelColor( i, to_r, to_g, to_b, to_w );
}
pixels.show();
}`
I've tried deleting and re-discovering my device numerous times via the app and a newer Echo Dot w/Clock but in the Alexa app this device shows just as "Color" under "Color Capabilities" while some actual retail Kasa bulbs I have show as "Color, Color Temperature". I even tried updating Espalexa.h to change the ExtendedColor modelidString to "LCT016" but that had no effect.
I wonder if there's been an update on the Alexa discovery JSON for this device that needs to be changed for this type of device to be properly recognized? I'll keep poking at things as well. Thanks! :)