Skip to content

Improve Samjin multi sensor and Samjin battery reporting #4186

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

Merged
merged 7 commits into from
Jan 17, 2021
27 changes: 20 additions & 7 deletions bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,12 +937,12 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
{
// Only configure periodic reports, as events are already sent though zone status change notification commands
rq.minInterval = 300;
rq.maxInterval = 300;
rq.maxInterval = 3600;
}
else
{
rq.minInterval = 1;
rq.maxInterval = 300;
rq.minInterval = 300;
rq.maxInterval = 3600;

const ResourceItem *item = sensor ? sensor->item(RConfigDuration) : nullptr;

Expand Down Expand Up @@ -1617,6 +1617,13 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
rq.maxInterval = 43200; // according to technical manual
rq.reportableChange8bit = 0;
}
else if (sensor && sensor->manufacturer() == QLatin1String("Samjin"))
{
// https://github.com/SmartThingsCommunity/SmartThingsPublic/blob/master/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy
rq.minInterval = 30;
rq.maxInterval = 21600;
rq.reportableChange8bit = 10;
}
else
{
rq.minInterval = 300;
Expand Down Expand Up @@ -1937,30 +1944,30 @@ bool DeRestPluginPrivate::sendConfigureReportingRequest(BindingTask &bt)
rq.attributeId = 0x0010; // active
rq.minInterval = manufacturerCode == VENDOR_SAMJIN ? 0 : 10;
rq.maxInterval = 3600;
rq.reportableChange8bit = 1;
rq.reportableChange8bit = 0xFF;
rq.manufacturerCode = manufacturerCode;

ConfigureReportingRequest rq1;
rq1.dataType = deCONZ::Zcl16BitInt;
rq1.attributeId = 0x0012; // acceleration x
rq1.minInterval = minInterval;
rq1.maxInterval = 300;
rq1.maxInterval = 3600;
rq1.reportableChange16bit = 1;
rq1.manufacturerCode = manufacturerCode;

ConfigureReportingRequest rq2;
rq2.dataType = deCONZ::Zcl16BitInt;
rq2.attributeId = 0x0013; // acceleration y
rq2.minInterval = minInterval;
rq2.maxInterval = 300;
rq2.maxInterval = 3600;
rq2.reportableChange16bit = 1;
rq2.manufacturerCode = manufacturerCode;

ConfigureReportingRequest rq3;
rq3.dataType = deCONZ::Zcl16BitInt;
rq3.attributeId = 0x0014; // acceleration z
rq3.minInterval = minInterval;
rq3.maxInterval = 300;
rq3.maxInterval = 3600;
rq3.reportableChange16bit = 1;
rq3.manufacturerCode = manufacturerCode;

Expand Down Expand Up @@ -2838,6 +2845,12 @@ bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor *senso
{
continue; // process only once
}

if (sensor->manufacturer() == QLatin1String("Samjin") && sensor->modelId() == QLatin1String("multi") && sensor->type() != QLatin1String("ZHAOpenClose"))
{
continue; // process only once
}

if (sensor->modelId() == QLatin1String("Remote switch") ||
sensor->modelId() == QLatin1String("Shutters central remote switch") ||
sensor->modelId() == QLatin1String("Double gangs remote switch") ||
Expand Down
7 changes: 7 additions & 0 deletions de_web_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12451,6 +12451,13 @@ void DeRestPluginPrivate::sendZclDefaultResponse(const deCONZ::ApsDataIndication
deCONZ::ZclFCDirectionClientToServer |
deCONZ::ZclFCDisableDefaultResponse);


if (zclFrame.manufacturerCode_t() != 0x0000_mfcode)
{
outZclFrame.setFrameControl(outZclFrame.frameControl() | deCONZ::ZclFCManufacturerSpecific);
outZclFrame.setManufacturerCode(zclFrame.manufacturerCode_t());
}

{ // ZCL payload
QDataStream stream(&outZclFrame.payload(), QIODevice::WriteOnly);
stream.setByteOrder(QDataStream::LittleEndian);
Expand Down
3 changes: 3 additions & 0 deletions de_web_plugin_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#include "websocket_server.h"
#include "tuya.h"

// enable domain specific string literals
using namespace deCONZ::literals;

#if defined(Q_OS_LINUX) && !defined(Q_PROCESSOR_X86)
// Workaround to detect ARM and AARCH64 in older Qt versions.
#define ARCH_ARM
Expand Down