Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ikea switches for new and old firmware #5538

Merged
merged 1 commit into from Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 3 additions & 6 deletions de_web_plugin.cpp
Expand Up @@ -4521,10 +4521,6 @@ void DeRestPluginPrivate::checkSensorButtonEvent(Sensor *sensor, const deCONZ::A
checkSensorGroup(sensor);
}
}
if (ind.dstAddressMode() == deCONZ::ApsNwkAddress)
{
return;
}
}
else if (sensor->modelId().startsWith(QLatin1String("SYMFONISK")))
{
Expand Down Expand Up @@ -4615,14 +4611,15 @@ void DeRestPluginPrivate::checkSensorButtonEvent(Sensor *sensor, const deCONZ::A
if (zclFrame.sequenceNumber() == sensor->previousSequenceNumber)
{
// useful in general but limit scope to known problematic devices
if (isTuyaManufacturerName(sensor->manufacturer()) ||
if ((sensor->node() && sensor->node()->nodeDescriptor().manufacturerCode() == VENDOR_IKEA) ||
isTuyaManufacturerName(sensor->manufacturer()) ||
// TODO "HG06323" can likely be removed after testing,
// since the device only sends group casts and we don't expect this to trigger.
sensor->modelId() == QLatin1String("HG06323"))
{
// deCONZ doesn't always send ZCL Default Response to unicast commands, or they can get lost.
// in this case some devices re-send the command multiple times
DBG_Printf(DBG_INFO, "Discard duplicated zcl.cmd: 0x%02X, cluster: 0x%04X with zcl.seq: %u for %s / %s\n",
DBG_Printf(DBG_INFO_L2, "Discard duplicated zcl.cmd: 0x%02X, cluster: 0x%04X with zcl.seq: %u for %s / %s\n",
zclFrame.commandId(), ind.clusterId(), zclFrame.sequenceNumber(), qPrintable(sensor->manufacturer()), qPrintable(sensor->modelId()));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion de_web_plugin_private.h
Expand Up @@ -1592,7 +1592,7 @@ public Q_SLOTS:
void handleTimeClusterIndication(const deCONZ::ApsDataIndication &ind, deCONZ::ZclFrame &zclFrame);
void handleDiagnosticsClusterIndication(const deCONZ::ApsDataIndication &ind, deCONZ::ZclFrame &zclFrame);
void handleFanControlClusterIndication(const deCONZ::ApsDataIndication &ind, deCONZ::ZclFrame &zclFrame);
void handleIdentifyClusterIndication(const deCONZ::ApsDataIndication &ind, deCONZ::ZclFrame &zclFrame);
void handleIdentifyClusterIndication(const deCONZ::ApsDataIndication &ind, const deCONZ::ZclFrame &zclFrame);
void sendTimeClusterResponse(const deCONZ::ApsDataIndication &ind, deCONZ::ZclFrame &zclFrame);
void handleBasicClusterIndication(const deCONZ::ApsDataIndication &ind, deCONZ::ZclFrame &zclFrame);
void sendBasicClusterResponse(const deCONZ::ApsDataIndication &ind, deCONZ::ZclFrame &zclFrame);
Expand Down
46 changes: 44 additions & 2 deletions identify.cpp
Expand Up @@ -10,9 +10,10 @@

#include "de_web_plugin_private.h"

#define IDENTIFY_COMMAND_IDENTIFY_QUERY quint8(0x01)
#define IDENTIFY_COMMAND_IDENTIFY_QUERY 0x01
#define IDENTIFY_COMMAND_IDENTIFY_QUERY_RESPONSE 0x00

void DeRestPluginPrivate::handleIdentifyClusterIndication(const deCONZ::ApsDataIndication &ind, deCONZ::ZclFrame &zclFrame)
void DeRestPluginPrivate::handleIdentifyClusterIndication(const deCONZ::ApsDataIndication &ind, const deCONZ::ZclFrame &zclFrame)
{

if (zclFrame.commandId() == IDENTIFY_COMMAND_IDENTIFY_QUERY &&
Expand All @@ -36,6 +37,47 @@ void DeRestPluginPrivate::handleIdentifyClusterIndication(const deCONZ::ApsDataI
writeAttribute(sensor, 0x01, 0xFCC0, attr, VENDOR_XIAOMI);
item->setValue(item->toNumber() & ~R_PENDING_MODE);
}
return;
}

if (permitJoinFlag)
{
// send Idendify Query Response if requested during pairing
deCONZ::ApsDataRequest req;
deCONZ::ZclFrame outZclFrame;

req.dstAddress() = ind.srcAddress();
req.setDstAddressMode(deCONZ::ApsExtAddress);
req.setClusterId(ind.clusterId());
req.setProfileId(ind.profileId());
req.setDstEndpoint(ind.srcEndpoint());
req.setSrcEndpoint(endpoint());

outZclFrame.setSequenceNumber(zclFrame.sequenceNumber());
outZclFrame.setCommandId(IDENTIFY_COMMAND_IDENTIFY_QUERY_RESPONSE);


outZclFrame.setFrameControl(deCONZ::ZclFCClusterCommand |
deCONZ::ZclFCDirectionServerToClient |
deCONZ::ZclFCDisableDefaultResponse);

{ // payload
QDataStream stream(&outZclFrame.payload(), QIODevice::WriteOnly);
stream.setByteOrder(QDataStream::LittleEndian);

stream << quint16(60); // our identify time
}

{ // ZCL frame
QDataStream stream(&req.asdu(), QIODevice::WriteOnly);
stream.setByteOrder(QDataStream::LittleEndian);
outZclFrame.writeToStream(stream);
}

if (apsCtrlWrapper.apsdeDataRequest(req) == deCONZ::Success)
{
DBG_Printf(DBG_INFO, "send identify query response to 0x%016llX\n", ind.srcAddress().ext());
}
}
}
}
Expand Down