diff --git a/de_web_plugin.cpp b/de_web_plugin.cpp index 4868068cff..7aa15efe6f 100644 --- a/de_web_plugin.cpp +++ b/de_web_plugin.cpp @@ -4390,7 +4390,8 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const SensorFi return; // required } - if (clusterId == IAS_ZONE_CLUSTER_ID) { + if (clusterId == IAS_ZONE_CLUSTER_ID) + { item = sensorNode.addItem(DataTypeBool, RStateLowBattery); item->setValue(false); item = sensorNode.addItem(DataTypeBool, RStateTampered); @@ -4457,6 +4458,11 @@ void DeRestPluginPrivate::addSensorNode(const deCONZ::Node *node, const SensorFi queryTime = queryTime.addSecs(1); } } + else if (*ci == IAS_ZONE_CLUSTER_ID) + { + item = sensorNode.addItem(DataTypeUInt8, RConfigPending); + item->setValue(R_PENDING_WRITE_CIE_ADDRESS); + } } } @@ -11949,6 +11955,11 @@ void DeRestPluginPrivate::taskToLocalData(const TaskItem &task) */ void DeRestPluginPrivate::delayedFastEnddeviceProbe(const deCONZ::NodeEvent *event) { + if (!apsCtrl) + { + return; + } + if (/*getUptime() < WARMUP_TIME &&*/ searchSensorsState != SearchSensorsActive) { return; @@ -12218,7 +12229,8 @@ void DeRestPluginPrivate::delayedFastEnddeviceProbe(const deCONZ::NodeEvent *eve { if (attr.id() == 0x0001 && attr.numericValue().u64 != 0) // Zone type { - iasZoneType = attr.numericValue().u64; + DBG_Assert(attr.numericValue().u64 <= UINT8_MAX); + iasZoneType = static_cast(attr.numericValue().u64); } } } @@ -12389,6 +12401,27 @@ void DeRestPluginPrivate::delayedFastEnddeviceProbe(const deCONZ::NodeEvent *eve { // do nothing } + else if (iasZoneType != 0) + { + ResourceItem *item = sensor->item(RConfigPending); + if (item && (item->toNumber() & R_PENDING_WRITE_CIE_ADDRESS)) + { + // write CIE address needed for some IAS Zone devices + const quint64 iasCieAddress = apsCtrl->getParameter(deCONZ::ParamMacAddress); + deCONZ::ZclAttribute attr(0x0010, deCONZ::ZclIeeeAddress, QLatin1String("CIE address"), deCONZ::ZclReadWrite, false); + attr.setValue(iasCieAddress); + + DBG_Printf(DBG_INFO, "[5] write IAS CIE address for 0x%016llx\n", sc->address.ext()); + + if (writeAttribute(sensor, sensor->fingerPrint().endpoint, IAS_ZONE_CLUSTER_ID, attr, 0)) + { + // mark done + item->setValue(item->toNumber() & ~R_PENDING_WRITE_CIE_ADDRESS); + return; + } + } + + } else if (sensor->modelId().startsWith(QLatin1String("RWL02"))) // Hue dimmer switch { NodeValue val = sensor->getZclValue(VENDOR_CLUSTER_ID, 0x0000); diff --git a/resource.h b/resource.h index 4d56c30565..ec6a5c5211 100644 --- a/resource.h +++ b/resource.h @@ -149,6 +149,7 @@ extern const char *RConfigUbisysJ1StartupSteps; #define R_PENDING_LEDINDICATION (1 << 1) #define R_PENDING_SENSITIVITY (1 << 2) #define R_PENDING_USERTEST (1 << 3) +#define R_PENDING_WRITE_CIE_ADDRESS (1 << 4) // after device announce is received lights can be brought into a defined state // this might be useful for powerloss and OTA updates or simply providing a default power on configuration