Tonight some of my lights stopped responding to commands from Alexa. I connected to Phoscon and saw that 3 lights and 1 room disappeared from the configuration. Before re-adding them I updated the firmware to 26660700 and the version to
2.05.86 / 15.10.2020.
I added one light and had Alexa search for devices. The light is detected and I can turn it on/off and set the brightness. However it is not possible to set the color using Alexs, this only works from Phoscon itself.
Seems like you have the same as this:
https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3387
Also, i recommend using a extension cable.
Does not seem be the same as the lights are responsive in the UI (Brightness/Color/Saturation), but with Alexa only the Brightness seems to work. Any additional data I can provide?
//Edit 1: Installed an extension cable, but the issue remains the same.
//Edit 2: If I change the color using the Alexa App, I see that the color in the UI is changing to the color set by Alexa, but the bulb does not react.
I have tried different older version (2.05.69/02.05.75/02.05.77) and I am currently on 02.05.84 (=latest stable). No version was working as expected.
The bulb affected is of type LED1624G9:
{
"colorcapabilities": 8,
"etag": "50577f8922c7b521c3171a4b515f4da5",
"hascolor": true,
"lastannounced": null,
"lastseen": "2020-11-10T14:24Z",
"manufacturername": "IKEA of Sweden",
"modelid": "TRADFRI bulb E27 CWS opal 600lm",
"name": "Stehlampe",
"state": {
"alert": "none",
"bri": 252,
"colormode": "xy",
"effect": "none",
"hue": 0,
"on": true,
"reachable": true,
"sat": 254,
"xy": [
0.1648,
0.5558
]
},
"swversion": "1.3.013",
"type": "Color light",
"uniqueid": ""
}
I have another bulb that LED1732G11 (TRADFRI bulb E27 WS opal 1000lm) that does not have color, but different whites - changing here is fine:
{
"colorcapabilities": 0,
"ctmax": 65279,
"ctmin": 0,
"etag": "783760b99ace6b271cc65edfe1b6d763",
"hascolor": true,
"lastannounced": "2020-11-10T14:21:34Z",
"lastseen": "2020-11-10T14:26Z",
"manufacturername": "IKEA of Sweden",
"modelid": "TRADFRI bulb E27 WS opal 1000lm",
"name": "Schlafzimmer",
"state": {
"alert": "none",
"bri": 145,
"colormode": "ct",
"ct": 250,
"on": false,
"reachable": true
},
"swversion": "2.0.023",
"type": "Color temperature light",
"uniqueid": ""
}
I have solved this issue 9 months ago by fix the code in rest-lights.cpp. Now i have updated to the newest version, and noone fixed this issue.... Ok.
I tried to merge my changes from februray into the current rest-lights. But no chance. Someone changed the code so, i have to analyse it where the issue is. The part where the hue value is calculated wrong is commented out....dont know how to fix it at the moment :/ i also have a tradfri color bulb 600lm
@acid115 You might want to post here if you want. Maybe @SwoopX Can help you out on integrating?
When I got to know what the change should be, I can have a look.
What is the difference between the command that is send from Alexa (not working) and from the UI (working)?
Are the signals send in one command by Alexa or is it the transition time?
9 month ago the issue was that the hue value for color change was completly wrong calculated.
We have to debug it.
I think the gateway and rest api receives the command from alexa. And the command is ok, i think. We have to find out how the json from alexa looks like and debug what way the values go through the code of rest-lights
Ok, now it works for me.
I found the code we have to change.
Maybe we have to do this only for ikea bulbs controlled by echo.
Short: echo sends hue and sat, but ikea bulb only unterstands x and y .
So it is necessary to calculate x and y from given hue and sat. And then set x and y like the echo should sent x and y.
More details tomorrow
Sounds like the change from here: https://github.com/dresden-elektronik/deconz-rest-plugin/commit/a4c712bf6d4cc60b376968b9f6d292b2b916755f
maybe, i dont unterstand a4c712b :)
So here is my change:
Line 1208 - 1249 (was commented out, but was nearly correct :)
addTaskSetXyColor(task, x, y); was not in.
additionally i fixed the yellow value.
can someone merge it?
diff --git a/rest_lights.cpp b/rest_lights.cpp
index 1a855d2..64314a9 100644
--- a/rest_lights.cpp
+++ b/rest_lights.cpp
@@ -1202,47 +1209,67 @@ int DeRestPluginPrivate::setLightState(const ApiRequest &req, ApiResponse &rsp)
ok = addTaskSetHueAndSaturation(task, hue, targetSat); // FIXME
// ok = addTaskSetEnhancedHueAndSaturation(task, targetHue, targetSat);
}
if (ok)
{
+ if (taskRef.lightNode->manufacturerCode() == VENDOR_IKEA
+ && hasHue && hasSat && !hasXy && !hasCt)
+ {
// FIXME: do we need this?
- // quint16 hue = hasHue ? targetHue : taskRef.lightNode->item(RStateHue)->toNumber();
- // quint8 sat = hasSat ? targetSat : taskRef.lightNode->item(RStateSat)->toNumber();
- //
- // double r, g, b;
- // double x, y;
- // double h = (hue * 360.0) / 65535.0;
- // double s = sat / 254.0;
- // double v = 1.0;
- //
- // Hsv2Rgb(&r, &g, &b, h, s, v);
- // Rgb2xy(&x, &y, r, g, b);
- //
- // if (x < 0) { x = 0; }
- // else if (x > 1) { x = 1; }
- // if (y < 0) { y = 0; }
- // else if (y > 1) { y = 1; }
- //
- // x *= 65535.0;
- // y *= 65535.0;
- // if (x > 65279) { x = 65279; }
- // else if (x < 1) { x = 1; }
- // if (y > 65279) { y = 65279; }
- // else if (y < 1) { y = 1; }
- //
- // item = task.lightNode->item(RStateX);
- // if (item && item->toNumber() != static_cast<quint16>(x))
- // {
- // item->setValue(static_cast<quint16>(x));
- // Event e(RLights, RStateX, task.lightNode->id(), item);
- // enqueueEvent(e);
- // }
- // item = task.lightNode->item(RStateY);
- // if (item && item->toNumber() != static_cast<quint16>(y))
- // {
- // item->setValue(static_cast<quint16>(y));
- // Event e(RLights, RStateY, task.lightNode->id(), item);
- // enqueueEvent(e);
- // }
+ quint16 hue = hasHue ? targetHue : taskRef.lightNode->item(RStateHue)->toNumber();
+ quint8 sat = hasSat ? targetSat : taskRef.lightNode->item(RStateSat)->toNumber();
+ double r, g, b;
+ double x, y;
+ double h = (hue * 360.0) / 65535.0;
+ double s = sat / 254.0;
+ double v = 1.0;
+
+ Hsv2Rgb(&r, &g, &b, h, s, v);
+ Rgb2xy(&x, &y, r, g, b);
+
+ if (x < 0) { x = 0; }
+ else if (x > 1) { x = 1; }
+ if (y < 0) { y = 0; }
+ else if (y > 1) { y = 1; }
+
+ //correction for color yellow and Ikea ColorBulb
+ if (req.mode == ApiModeEcho &&
+ hue == 10923)
+ {
+ //real yellow
+ x = 0.5068;
+ y = 0.4715;
+ }
+
+ addTaskSetXyColor(task, x, y);
+
+ x *= 65535.0;
+ y *= 65535.0;
+ if (x > 65279) { x = 65279; }
+ else if (x < 1) { x = 1; }
+ if (y > 65279) { y = 65279; }
+ else if (y < 1) { y = 1; }
+
+ ResourceItem *item = taskRef.lightNode->item(RStateX);
+ if (item && item->toNumber() != static_cast<quint16>(x))
+ {
+ item->setValue(static_cast<quint16>(x));
+ Event e(RLights, RStateX, task.lightNode->id(), item);
+ enqueueEvent(e);
+ }
+ item = taskRef.lightNode->item(RStateY);
+ if (item && item->toNumber() != static_cast<quint16>(y))
+ {
+ item->setValue(static_cast<quint16>(y));
+ Event e(RLights, RStateY, task.lightNode->id(), item);
+ enqueueEvent(e);
+ }
+ }
// End FIXME
if (hasHue)
And if someone has an CT-Bulb from Ikea and uses alexa to control it, knows that the temperature of the bulb is set to low by alexa. You can fix it with the following and everythingbis nice. Not everyone uses Philips or whatever. But you are right, most of the people uses ikea bulbs, does not control it by a conbee, they uses the ikea gateway
else if (hasCt)
{
TaskItem task;
copyTaskReq(taskRef, task);
quint16 targetCtForChange = targetCt;
//correct ikea ct
if (task.lightNode->manufacturerCode() == VENDOR_IKEA &&
req.mode == ApiModeEcho )
{
targetCtForChange += 65;
}
if (!isOn)
{
rsp.list.append(errorToMap(ERR_DEVICE_OFF, QString("/lights/%1/state").arg(id), QString("parameter, ct, is not modifiable. Device is set to off.")));
}
else if (taskRef.lightNode->isColorLoopActive())
{
rsp.list.append(errorToMap(ERR_PARAMETER_NOT_MODIFIEABLE, QString("/lights/%1/state").arg(id), QString("parameter, ct, is not modifiable. Colorloop is active.")));
}
else if (addTaskSetColorTemperature(task, targetCtForChange))
{
Most helpful comment
Ok, now it works for me.
I found the code we have to change.
Maybe we have to do this only for ikea bulbs controlled by echo.
Short: echo sends hue and sat, but ikea bulb only unterstands x and y .
So it is necessary to calculate x and y from given hue and sat. And then set x and y like the echo should sent x and y.
More details tomorrow