Skip to content

Commit c159e52

Browse files
committed
Cleanup ResourceItems
Proper split into `attr`, `capabilities`, `config`, and `state` resource items.
1 parent 123e17a commit c159e52

10 files changed

+322
-265
lines changed

bindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,7 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
21832183
rq4.maxInterval = 1800;
21842184

21852185
// TODO re activate. Don't disable for now until more testing is done.
2186-
// const ResourceItem *cap = lightNode ? lightNode->item(RConfigColorCapabilities) : nullptr;
2186+
// const ResourceItem *cap = lightNode ? lightNode->item(RCapolorCapabilities) : nullptr;
21872187

21882188
// if (cap && (cap->toNumber() & 0x0008) == 0) // doesn't support xy --> color temperature light
21892189
// {

de_web_plugin.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ void DeRestPluginPrivate::apsdeDataIndicationDevice(const deCONZ::ApsDataIndicat
10061006
return;
10071007
}
10081008

1009-
if (!device->item(RAttrSleeper)->toBool())
1009+
if (!device->item(RCapSleeper)->toBool())
10101010
{
10111011
auto *item = device->item(RStateReachable);
10121012
if (!item->toBool())
@@ -2991,7 +2991,7 @@ void DeRestPluginPrivate::addLightNode(const deCONZ::Node *node)
29912991

29922992
if (existDevicesWithVendorCodeForMacPrefix(node->address(), VENDOR_DDEL) && i->deviceId() != DEV_ID_CONFIGURATION_TOOL && node->nodeDescriptor().manufacturerCode() == VENDOR_DDEL)
29932993
{
2994-
ResourceItem *item = lightNode.addItem(DataTypeUInt32, RConfigPowerup);
2994+
ResourceItem *item = lightNode.addItem(DataTypeUInt32, RAttrPowerup);
29952995
DBG_Assert(item != 0);
29962996
item->setValue(R_POWERUP_RESTORE | R_POWERUP_RESTORE_AT_DAYLIGHT | R_POWERUP_RESTORE_AT_NO_DAYLIGHT);
29972997
}
@@ -3251,29 +3251,29 @@ void DeRestPluginPrivate::setLightNodeStaticCapabilities(LightNode *lightNode)
32513251
{
32523252
item->setValue(QVariant("Color temperature light"));
32533253
}
3254-
if (lightNode->item(RConfigColorCapabilities) != nullptr)
3254+
if (lightNode->item(RCapColorCapabilities) != nullptr)
32553255
{
32563256
return; // already initialized
32573257
}
32583258
lightNode->addItem(DataTypeUInt16, RStateCt);
3259-
lightNode->addItem(DataTypeUInt16, RConfigCtMin)->setValue(142);
3260-
lightNode->addItem(DataTypeUInt16, RConfigCtMax)->setValue(666);
3261-
lightNode->addItem(DataTypeUInt16, RConfigColorCapabilities)->setValue(0x0001 | 0x0008 | 0x0010);
3259+
lightNode->addItem(DataTypeUInt16, RCapColorCtMin)->setValue(142);
3260+
lightNode->addItem(DataTypeUInt16, RCapColorCtMax)->setValue(666);
3261+
lightNode->addItem(DataTypeUInt16, RCapColorCapabilities)->setValue(0x0001 | 0x0008 | 0x0010);
32623262
lightNode->addItem(DataTypeString, RStateColorMode)->setValue(QVariant("ct"));
32633263
}
32643264
else if (lightNode->modelId() == QLatin1String("LIGHTIFY A19 RGBW"))
32653265
{
3266-
if (lightNode->item(RConfigColorCapabilities) != nullptr)
3266+
if (lightNode->item(RCapColorCapabilities) != nullptr)
32673267
{
32683268
return; // already initialized
32693269
}
32703270
lightNode->addItem(DataTypeUInt16, RStateCt);
32713271
// the light doesn't provide ctmin, ctmax and color capabilities attributes
32723272
// however it supports the 'Move To Color Temperature' command and Color Temperature attribute
3273-
lightNode->addItem(DataTypeUInt16, RConfigCtMin)->setValue(152);
3274-
lightNode->addItem(DataTypeUInt16, RConfigCtMax)->setValue(689);
3273+
lightNode->addItem(DataTypeUInt16, RCapColorCtMin)->setValue(152);
3274+
lightNode->addItem(DataTypeUInt16, RCapColorCtMax)->setValue(689);
32753275
// hue, saturation, color mode, xy, ct
3276-
lightNode->addItem(DataTypeUInt16, RConfigColorCapabilities)->setValue(0x0001 | 0x0008 | 0x0010);
3276+
lightNode->addItem(DataTypeUInt16, RCapColorCapabilities)->setValue(0x0001 | 0x0008 | 0x0010);
32773277
}
32783278
else if (lightNode->modelId() == QLatin1String("LIGHTIFY A19 Tunable White") ||
32793279
lightNode->modelId() == QLatin1String("LIGHTIFY Conv Under Cabinet TW") ||
@@ -3299,17 +3299,17 @@ void DeRestPluginPrivate::setLightNodeStaticCapabilities(LightNode *lightNode)
32993299
item->setValue(QVariant("Color temperature light"));
33003300
}
33013301

3302-
if (lightNode->item(RConfigColorCapabilities) != nullptr)
3302+
if (lightNode->item(RCapColorCapabilities) != nullptr)
33033303
{
33043304
return; // already initialized
33053305
}
33063306
lightNode->addItem(DataTypeUInt16, RStateCt);
33073307
// these lights don't provide ctmin, ctmax and color capabilities attributes
33083308
// however they support the 'Move To Color Temperature' command and Color Temperature attribute
3309-
lightNode->addItem(DataTypeUInt16, RConfigCtMin)->setValue(153); // 6500K
3310-
lightNode->addItem(DataTypeUInt16, RConfigCtMax)->setValue(370); // 2700K
3309+
lightNode->addItem(DataTypeUInt16, RCapColorCtMin)->setValue(153); // 6500K
3310+
lightNode->addItem(DataTypeUInt16, RCapColorCtMax)->setValue(370); // 2700K
33113311
// color mode, xy, ct
3312-
lightNode->addItem(DataTypeUInt16, RConfigColorCapabilities)->setValue(0x0008 | 0x0010);
3312+
lightNode->addItem(DataTypeUInt16, RCapColorCapabilities)->setValue(0x0008 | 0x0010);
33133313
lightNode->addItem(DataTypeString, RStateColorMode)->setValue(QVariant("ct"));
33143314
lightNode->removeItem(RStateHue);
33153315
lightNode->removeItem(RStateSat);
@@ -3326,14 +3326,14 @@ void DeRestPluginPrivate::setLightNodeStaticCapabilities(LightNode *lightNode)
33263326
{
33273327
item->setValue(QVariant("Color temperature light"));
33283328
}
3329-
if (lightNode->item(RConfigColorCapabilities) != nullptr)
3329+
if (lightNode->item(RCapColorCapabilities) != nullptr)
33303330
{
33313331
return; // already initialized
33323332
}
33333333
lightNode->addItem(DataTypeUInt16, RStateCt);
3334-
lightNode->addItem(DataTypeUInt16, RConfigCtMin)->setValue(153);
3335-
lightNode->addItem(DataTypeUInt16, RConfigCtMax)->setValue(370);
3336-
lightNode->addItem(DataTypeUInt16, RConfigColorCapabilities)->setValue(0x0001 | 0x0008 | 0x0010);
3334+
lightNode->addItem(DataTypeUInt16, RCapColorCtMin)->setValue(153);
3335+
lightNode->addItem(DataTypeUInt16, RCapColorCtMax)->setValue(370);
3336+
lightNode->addItem(DataTypeUInt16, RCapColorCapabilities)->setValue(0x0001 | 0x0008 | 0x0010);
33373337
lightNode->addItem(DataTypeString, RStateColorMode)->setValue(QVariant("ct"));
33383338
}
33393339
else if (isXmasLightStrip(lightNode))
@@ -3348,7 +3348,7 @@ void DeRestPluginPrivate::setLightNodeStaticCapabilities(LightNode *lightNode)
33483348
else if (modelId.startsWith(QLatin1String("KADRILJ")) ||
33493349
modelId.startsWith(QLatin1String("FYRTUR")))
33503350
{
3351-
item = lightNode->addItem(DataTypeBool, RAttrSleeper);
3351+
item = lightNode->addItem(DataTypeBool, RCapSleeper);
33523352
if (item)
33533353
{
33543354
item->setValue(false);
@@ -3753,7 +3753,7 @@ LightNode *DeRestPluginPrivate::updateLightNode(const deCONZ::NodeEvent &event)
37533753
}
37543754

37553755
{
3756-
ResourceItem *item = lightNode->item(RConfigColorCapabilities);
3756+
ResourceItem *item = lightNode->item(RCapColorCapabilities);
37573757
if (item && item->toNumber() > 0)
37583758
{
37593759
const auto cap = item->toNumber();
@@ -3790,17 +3790,17 @@ LightNode *DeRestPluginPrivate::updateLightNode(const deCONZ::NodeEvent &event)
37903790
else if (ia->id() == 0x400a) // color capabilities
37913791
{
37923792
quint16 cap = ia->numericValue().u16;
3793-
lightNode->setValue(RConfigColorCapabilities, cap);
3793+
lightNode->setValue(RCapColorCapabilities, cap);
37943794
}
37953795
else if (ia->id() == 0x400b) // color temperature min
37963796
{
37973797
quint16 cap = ia->numericValue().u16;
3798-
lightNode->setValue(RConfigCtMin, cap);
3798+
lightNode->setValue(RCapColorCtMin, cap);
37993799
}
38003800
else if (ia->id() == 0x400c) // color temperature max
38013801
{
38023802
quint16 cap = ia->numericValue().u16;
3803-
lightNode->setValue(RConfigCtMax, cap);
3803+
lightNode->setValue(RCapColorCtMax, cap);
38043804
}
38053805
}
38063806
}
@@ -11841,7 +11841,7 @@ void DeRestPluginPrivate::handleXalClusterIndication(const deCONZ::ApsDataIndica
1184111841
{
1184211842
quint8 id;
1184311843
stream >> id;
11844-
ResourceItem *item = lightNode->addItem(DataTypeUInt32, RConfigId);
11844+
ResourceItem *item = lightNode->addItem(DataTypeUInt32, RAttrConfigId);
1184511845
if (!item->lastSet().isValid() || item->toNumber() != id)
1184611846
{
1184711847
item->setValue(id);
@@ -11853,7 +11853,7 @@ void DeRestPluginPrivate::handleXalClusterIndication(const deCONZ::ApsDataIndica
1185311853
{
1185411854
quint8 minLevel;
1185511855
stream >> minLevel;
11856-
ResourceItem *item = lightNode->addItem(DataTypeUInt8, RConfigLevelMin);
11856+
ResourceItem *item = lightNode->addItem(DataTypeUInt8, RAttrLevelMin);
1185711857
if (!item->lastSet().isValid() || item->toNumber() != minLevel)
1185811858
{
1185911859
item->setValue(minLevel);
@@ -11865,7 +11865,7 @@ void DeRestPluginPrivate::handleXalClusterIndication(const deCONZ::ApsDataIndica
1186511865
{
1186611866
quint8 powerOnLevel;
1186711867
stream >> powerOnLevel;
11868-
ResourceItem *item = lightNode->addItem(DataTypeUInt8, RConfigPowerOnLevel);
11868+
ResourceItem *item = lightNode->addItem(DataTypeUInt8, RAttrPowerOnLevel);
1186911869
if (!item->lastSet().isValid() || item->toNumber() != powerOnLevel)
1187011870
{
1187111871
item->setValue(powerOnLevel);
@@ -11877,7 +11877,7 @@ void DeRestPluginPrivate::handleXalClusterIndication(const deCONZ::ApsDataIndica
1187711877
{
1187811878
quint16 powerOnTemp;
1187911879
stream >> powerOnTemp;
11880-
ResourceItem *item = lightNode->addItem(DataTypeUInt16, RConfigPowerOnCt);
11880+
ResourceItem *item = lightNode->addItem(DataTypeUInt16, RAttrPowerOnCt);
1188111881
if (!item->lastSet().isValid() || item->toNumber() != powerOnTemp)
1188211882
{
1188311883
item->setValue(powerOnTemp);
@@ -12079,7 +12079,7 @@ bool DeRestPluginPrivate::flsNbMaintenance(LightNode *lightNode)
1207912079
return false;
1208012080
}
1208112081

12082-
item = lightNode->item(RConfigPowerup);
12082+
item = lightNode->item(RAttrPowerup);
1208312083
quint32 powerup = item ? item->toNumber() : 0;
1208412084

1208512085
if ((powerup & R_POWERUP_RESTORE) == 0)

device.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Resource *DEV_GetSubDevice(Device *device, const char *prefix, const QString &id
198198
{
199199
return nullptr;
200200
}
201-
201+
202202
for (auto &sub : device->subDevices())
203203
{
204204
if (prefix && sub->prefix() != prefix)
@@ -333,7 +333,7 @@ void DEV_NodeDescriptorStateHandler(Device *device, const Event &event)
333333
DBG_Printf(DBG_DEV, "ZDP node descriptor verified: 0x%016llX\n", device->key());
334334
d->maxResponseTime = d->hasRxOnWhenIdle() ? RxOnWhenIdleResponseTime
335335
: RxOffWhenIdleResponseTime;
336-
device->item(RAttrSleeper)->setValue(!d->hasRxOnWhenIdle()); // can be overwritten by DDF
336+
device->item(RCapSleeper)->setValue(!d->hasRxOnWhenIdle()); // can be overwritten by DDF
337337
d->setState(DEV_ActiveEndpointsStateHandler);
338338
}
339339
else if (!device->reachable()) // can't be queried, go back to #1 init
@@ -870,7 +870,7 @@ void DEV_IdleStateHandler(Device *device, const Event &event)
870870
}
871871
}
872872

873-
if (!device->reachable() && !device->item(RAttrSleeper)->toBool())
873+
if (!device->reachable() && !device->item(RCapSleeper)->toBool())
874874
{
875875
DBG_Printf(DBG_DEV, "DEV (NOT reachable) Idle event %s/0x%016llX/%s\n", event.resource(), event.deviceKey(), event.what());
876876
}
@@ -1994,7 +1994,7 @@ Device::Device(DeviceKey key, deCONZ::ApsController *apsCtrl, QObject *parent) :
19941994
d->flags.initialRun = 1;
19951995

19961996
addItem(DataTypeBool, RStateReachable);
1997-
addItem(DataTypeBool, RAttrSleeper);
1997+
addItem(DataTypeBool, RCapSleeper);
19981998
addItem(DataTypeUInt64, RAttrExtAddress);
19991999
addItem(DataTypeUInt16, RAttrNwkAddress);
20002000
addItem(DataTypeString, RAttrUniqueId)->setValue(generateUniqueId(key, 0, 0));
@@ -2194,7 +2194,7 @@ bool Device::reachable() const
21942194
{
21952195
return item(RStateReachable)->toBool();
21962196
}
2197-
else if (!item(RAttrSleeper)->toBool())
2197+
else if (!item(RCapSleeper)->toBool())
21982198
{
21992199
return item(RStateReachable)->toBool();
22002200
}

device_ddf_init.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ bool DEV_InitDeviceFromDescription(Device *device, const DeviceDescription &ddf)
248248
{
249249
QString writeFunction;
250250
const auto writeParam = ddfItem.writeParameters.toMap();
251-
251+
252252
if (writeParam.contains(QLatin1String("fn")))
253253
{
254254
writeFunction = writeParam.value(QLatin1String("fn")).toString();
@@ -257,7 +257,7 @@ bool DEV_InitDeviceFromDescription(Device *device, const DeviceDescription &ddf)
257257
if (writeFunction.isEmpty() || writeFunction == QLatin1String("zcl"))
258258
{
259259
bool ok;
260-
260+
261261
StateChange stateChange(StateChange::StateWaitSync, SC_WriteZclAttribute, sub.uniqueId.at(1).toUInt());
262262
stateChange.addTargetValue(item->descriptor().suffix, item->toVariant());
263263
stateChange.setChangeTimeoutMs(1000 * 60 * 60);
@@ -312,7 +312,7 @@ bool DEV_InitDeviceFromDescription(Device *device, const DeviceDescription &ddf)
312312

313313
if (ddf.sleeper >= 0)
314314
{
315-
device->item(RAttrSleeper)->setValue(ddf.sleeper == 1);
315+
device->item(RCapSleeper)->setValue(ddf.sleeper == 1);
316316
}
317317

318318
device->clearBindings();

light_node.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ bool LightNode::isColorLoopActive() const
235235

236236
bool LightNode::supportsColorLoop() const
237237
{
238-
const auto *colorCapabilities = item(RConfigColorCapabilities);
238+
const auto *colorCapabilities = item(RCapColorCapabilities);
239239

240240
if (colorCapabilities)
241241
{
@@ -390,9 +390,9 @@ void LightNode::setHaEndpoint(const deCONZ::SimpleDescriptor &endpoint)
390390
case DEV_ID_Z30_COLOR_TEMPERATURE_LIGHT:
391391
case DEV_ID_ZLL_COLOR_TEMPERATURE_LIGHT: // fall through
392392
{
393-
addItem(DataTypeUInt16, RConfigColorCapabilities);
394-
addItem(DataTypeUInt16, RConfigCtMin);
395-
addItem(DataTypeUInt16, RConfigCtMax)->setValue(0xFEFF);
393+
addItem(DataTypeUInt16, RCapColorCapabilities);
394+
addItem(DataTypeUInt16, RCapColorCtMin);
395+
addItem(DataTypeUInt16, RCapColorCtMax)->setValue(0xFEFF);
396396
addItem(DataTypeUInt16, RStateCt);
397397

398398
if (deviceId == DEV_ID_Z30_COLOR_TEMPERATURE_LIGHT ||
@@ -411,7 +411,7 @@ void LightNode::setHaEndpoint(const deCONZ::SimpleDescriptor &endpoint)
411411
{
412412
case DEV_ID_ZLL_COLOR_LIGHT:
413413
{
414-
addItem(DataTypeUInt16, RConfigColorCapabilities);
414+
addItem(DataTypeUInt16, RCapColorCapabilities);
415415
}
416416
// fall through
417417
case DEV_ID_ZLL_EXTENDED_COLOR_LIGHT:
@@ -422,7 +422,7 @@ void LightNode::setHaEndpoint(const deCONZ::SimpleDescriptor &endpoint)
422422
addItem(DataTypeUInt16, RStateY);
423423
if (manufacturer() == QLatin1String("LIDL Livarno Lux"))
424424
{
425-
removeItem(RConfigColorCapabilities);
425+
removeItem(RCapColorCapabilities);
426426
}
427427
else
428428
{

poll_manager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void PollManager::poll(RestNodeBase *restNode, const QDateTime &tStart)
4242

4343
if (!restNode->node()->nodeDescriptor().receiverOnWhenIdle())
4444
{
45-
auto *item = r->item(RAttrSleeper);
45+
auto *item = r->item(RCapSleeper);
4646
if (!item || item->toBool())
4747
{
4848
return;
@@ -300,7 +300,7 @@ void PollManager::pollTimerFired()
300300
else if (suffix == RStateColorMode && lightNode)
301301
{
302302
clusterId = COLOR_CLUSTER_ID;
303-
item = r->item(RConfigColorCapabilities);
303+
item = r->item(RCapColorCapabilities);
304304

305305
if ((!item || item->toNumber() <= 0) && (lightNode->haEndpoint().profileId() == ZLL_PROFILE_ID || lightNode->manufacturerCode() == VENDOR_XIAOMI || lightNode->manufacturerCode() == VENDOR_MUELLER || lightNode->manufacturerCode() == VENDOR_XAL || lightNode->manufacturerCode() == VENDOR_LEDVANCE))
306306
{
@@ -492,7 +492,7 @@ void PollManager::pollTimerFired()
492492
if (cl.id() == clusterId)
493493
{
494494
found = true;
495-
495+
496496
std::vector<quint16> check;
497497

498498
for (const deCONZ::ZclAttribute &attr : cl.attributes()) // Loop through cluster attributes

0 commit comments

Comments
 (0)