Skip to content

Commit

Permalink
Write IAS CIE address when IAS Zone devices joins
Browse files Browse the repository at this point in the history
Needed for some sensors like OSRAM, SmartThings and NYCE.

Issues #881 #548
  • Loading branch information
manup committed Jan 18, 2019
1 parent 54a2c0a commit 31f745f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
37 changes: 35 additions & 2 deletions de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<quint8>(attr.numericValue().u64);
}
}
}
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 31f745f

Please sign in to comment.