Skip to content

Commit

Permalink
Fix old group0 delete
Browse files Browse the repository at this point in the history
  • Loading branch information
KodeCR authored and manup committed Jun 22, 2019
1 parent 1bacf46 commit 96b1c96
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,31 +336,38 @@ DeRestPluginPrivate::DeRestPluginPrivate(QObject *parent) :
}

// create default group
// get new id
if (gwGroup0 == 0)
{
// get new id and replace old group0 and get new id
for (uint16_t i = 0xFFF0; i > 0; i--) // 0 and larger than 0xfff7 is not valid for Osram Lightify
{
Group* group = getGroupForId(i);
if (!group)
{
gwGroup0 = i;
// delete old group 0
Group* group = getGroupForId(0);
if (group)
{
group->setState(Group::StateDeleted);
}
break;
}
}
}

// delete old group 0
if (gwGroup0 != 0)
{
for (Group& group : groups)
{
if (group.address() == 0 && !(group.state() == Group::StateDeleted || group.state() == Group::StateDeleteFromDB))
{
group.setState(Group::StateDeleted);
queSaveDb(DB_CONFIG | DB_GROUPS, DB_LONG_SAVE_DELAY);
break;
}
}
}

// create new group 0
Group* group = getGroupForId(gwGroup0);
if (!group)
{
// new default group
Group group;
group.setAddress(gwGroup0);
group.setName("All");
Expand Down

0 comments on commit 96b1c96

Please sign in to comment.