Refactor add- and store scenes (wip)
@@ -951,6 +951,12 @@ bool DeRestPluginPrivate::addTaskStoreScene(TaskItem &task, uint16_t groupId, ui
*/
bool DeRestPluginPrivate::addTaskAddScene(TaskItem &task, uint16_t groupId, uint8_t sceneId, const QString &lightId)
{
+ DBG_Assert(task.lightNode != 0);
+ if (!task.lightNode)
+ {
+ return false;
+ }
+
Group *group = getGroupForId(groupId);
std::vector<Scene>::iterator i = group->scenes.begin();
@@ -965,8 +971,11 @@ bool DeRestPluginPrivate::addTaskAddScene(TaskItem &task, uint16_t groupId, uint
for ( ;l != lend; ++l)
{
- if (l->lid() == lightId)
+ if (l->lid() != lightId)
{
+ continue;
+ }
+
task.taskType = TaskAddScene;
task.req.setClusterId(SCENE_CLUSTER_ID);
@@ -1009,8 +1018,10 @@ bool DeRestPluginPrivate::addTaskAddScene(TaskItem &task, uint16_t groupId, uint
stream << (uint16_t)0x0008; // level cluster
stream << (uint8_t)0x01;
stream << l->bri();
- if (task.lightNode && task.lightNode->hasColor() &&
- !task.lightNode->modelId().startsWith("FLS-PP3")) // color in add scene not supported well
+
+ ResourceItem *item = task.lightNode->item(RStateColorMode);
+ if (item &&
+ !task.lightNode->modelId().startsWith(QLatin1String("FLS-PP3"))) // color in add scene not supported well
{
stream << (uint16_t)0x0300; // color cluster
stream << (uint8_t)11;
@@ -1018,6 +1029,11 @@ bool DeRestPluginPrivate::addTaskAddScene(TaskItem &task, uint16_t groupId, uint
{
stream << l->x();
stream << l->y();
+ stream << l->enhancedHue();
+ stream << l->saturation();
+#if 0
+ stream << l->x();
+ stream << l->y();
if (task.lightNode->manufacturerCode() == VENDOR_OSRAM ||
task.lightNode->manufacturerCode() == VENDOR_OSRAM_STACK)
@@ -1030,6 +1046,7 @@ bool DeRestPluginPrivate::addTaskAddScene(TaskItem &task, uint16_t groupId, uint
stream << (quint16)0; //enhanced hue
stream << (quint8)0; // saturation
}
+#endif
}
else if (l->colorMode() == QLatin1String("ct"))
{
@@ -1093,7 +1110,6 @@ bool DeRestPluginPrivate::addTaskAddScene(TaskItem &task, uint16_t groupId, uint
return addTask(task);
}
- }
return false;
}
}
