diff --git a/zigbeedevelco/integrationpluginzigbeedevelco.cpp b/zigbeedevelco/integrationpluginzigbeedevelco.cpp index c0c256c5..2e91b338 100644 --- a/zigbeedevelco/integrationpluginzigbeedevelco.cpp +++ b/zigbeedevelco/integrationpluginzigbeedevelco.cpp @@ -137,9 +137,9 @@ void IntegrationPluginZigbeeDevelco::setupThing(ThingSetupInfo *info) } connect(basicCluster, &ZigbeeCluster::attributeChanged, this, [=](const ZigbeeClusterAttribute &attribute){ - if (attribute.id() == DEVELCO_ATTRIBUTE_SW_VERSION) { - thing->setStateValue(ioModuleVersionStateTypeId, parseDevelcoVersionString(primaryEndpoint)); - } + if (attribute.id() == DEVELCO_ATTRIBUTE_SW_VERSION) { + thing->setStateValue(ioModuleVersionStateTypeId, parseDevelcoVersionString(primaryEndpoint)); + } }); } @@ -338,28 +338,28 @@ void IntegrationPluginZigbeeDevelco::executeAction(ThingActionInfo *info) qCWarning(dcZigbeeDevelco()) << "Could not find endpoint for output 1 on" << thing << node; info->finish(Thing::ThingErrorHardwareFailure); return; - } else { - ZigbeeClusterOnOff *onOffCluster = output1Endpoint->inputCluster(ZigbeeClusterLibrary::ClusterIdOnOff); - if (!onOffCluster) { - qCWarning(dcZigbeeDevelco()) << "Could not find On/Off cluster on" << thing << node << output1Endpoint; - info->finish(Thing::ThingErrorHardwareFailure); - return; - } else { - ZigbeeClusterReply *reply = (power ? onOffCluster->commandOn() : onOffCluster->commandOff()); - connect(reply, &ZigbeeClusterReply::finished, info, [=](){ - // Note: reply will be deleted automatically - if (reply->error() != ZigbeeClusterReply::ErrorNoError) { - qCWarning(dcZigbeeDevelco()) << "Failed to set power for output 1 on" << thing << reply->error(); - info->finish(Thing::ThingErrorHardwareFailure); - } else { - info->finish(Thing::ThingErrorNoError); - qCDebug(dcZigbeeDevelco()) << "Set power on output 1 finished successfully for" << thing; - thing->setStateValue(ioModuleOutput1StateTypeId, power); - } - }); - return; - } } + + ZigbeeClusterOnOff *onOffCluster = output1Endpoint->inputCluster(ZigbeeClusterLibrary::ClusterIdOnOff); + if (!onOffCluster) { + qCWarning(dcZigbeeDevelco()) << "Could not find On/Off cluster on" << thing << node << output1Endpoint; + info->finish(Thing::ThingErrorHardwareFailure); + return; + } + + ZigbeeClusterReply *reply = (power ? onOffCluster->commandOn() : onOffCluster->commandOff()); + connect(reply, &ZigbeeClusterReply::finished, info, [=](){ + // Note: reply will be deleted automatically + if (reply->error() != ZigbeeClusterReply::ErrorNoError) { + qCWarning(dcZigbeeDevelco()) << "Failed to set power for output 1 on" << thing << reply->error(); + info->finish(Thing::ThingErrorHardwareFailure); + } else { + info->finish(Thing::ThingErrorNoError); + qCDebug(dcZigbeeDevelco()) << "Set power on output 1 finished successfully for" << thing; + thing->setStateValue(ioModuleOutput1StateTypeId, power); + } + }); + return; } // Output 2 @@ -372,28 +372,70 @@ void IntegrationPluginZigbeeDevelco::executeAction(ThingActionInfo *info) qCWarning(dcZigbeeDevelco()) << "Could not find endpoint for output 2 on" << thing << node; info->finish(Thing::ThingErrorHardwareFailure); return; - } else { - ZigbeeClusterOnOff *onOffCluster = output2Endpoint->inputCluster(ZigbeeClusterLibrary::ClusterIdOnOff); - if (!onOffCluster) { - qCWarning(dcZigbeeDevelco()) << "Could not find On/Off cluster on" << thing << node << output2Endpoint; - info->finish(Thing::ThingErrorHardwareFailure); - return; - } else { - ZigbeeClusterReply *reply = (power ? onOffCluster->commandOn() : onOffCluster->commandOff()); - connect(reply, &ZigbeeClusterReply::finished, info, [=](){ - // Note: reply will be deleted automatically - if (reply->error() != ZigbeeClusterReply::ErrorNoError) { - qCWarning(dcZigbeeDevelco()) << "Failed to set power for output 2 on" << thing << reply->error(); - info->finish(Thing::ThingErrorHardwareFailure); - } else { - info->finish(Thing::ThingErrorNoError); - qCDebug(dcZigbeeDevelco()) << "Set power on output 2 finished successfully for" << thing; - thing->setStateValue(ioModuleOutput2StateTypeId, power); - } - }); - return; - } } + + ZigbeeClusterOnOff *onOffCluster = output2Endpoint->inputCluster(ZigbeeClusterLibrary::ClusterIdOnOff); + if (!onOffCluster) { + qCWarning(dcZigbeeDevelco()) << "Could not find On/Off cluster on" << thing << node << output2Endpoint; + info->finish(Thing::ThingErrorHardwareFailure); + return; + } + + ZigbeeClusterReply *reply = (power ? onOffCluster->commandOn() : onOffCluster->commandOff()); + connect(reply, &ZigbeeClusterReply::finished, info, [=](){ + // Note: reply will be deleted automatically + if (reply->error() != ZigbeeClusterReply::ErrorNoError) { + qCWarning(dcZigbeeDevelco()) << "Failed to set power for output 2 on" << thing << reply->error(); + info->finish(Thing::ThingErrorHardwareFailure); + } else { + info->finish(Thing::ThingErrorNoError); + qCDebug(dcZigbeeDevelco()) << "Set power on output 2 finished successfully for" << thing; + thing->setStateValue(ioModuleOutput2StateTypeId, power); + } + }); + return; + } + + // Impulse action + if (info->action().actionTypeId() == ioModuleImpulseOutput1ActionTypeId || info->action().actionTypeId() == ioModuleImpulseOutput2ActionTypeId) { + // Uint for time is 1/10 s + uint impulseDuration = thing->settings().paramValue(ioModuleSettingsImpulseDurationParamTypeId).toUInt(); + quint16 impulseDurationScaled = static_cast(qRound(impulseDuration / 100.0)); + + ZigbeeNodeEndpoint *endpoint = nullptr; + if (info->action().actionTypeId() == ioModuleImpulseOutput1ActionTypeId) { + endpoint = node->getEndpoint(IO_MODULE_EP_OUTPUT1); + qCDebug(dcZigbeeDevelco()) << "Execute output 1 impulse with" << impulseDurationScaled * 100 << "ms"; + } else if (info->action().actionTypeId() == ioModuleImpulseOutput2ActionTypeId) { + endpoint = node->getEndpoint(IO_MODULE_EP_OUTPUT2); + qCDebug(dcZigbeeDevelco()) << "Execute output 2 impulse with" << impulseDurationScaled * 100 << "ms"; + } + + if (!endpoint) { + qCWarning(dcZigbeeDevelco()) << "Could not find endpoint for impulse action on" << thing << node; + info->finish(Thing::ThingErrorHardwareFailure); + return; + } + + ZigbeeClusterOnOff *onOffCluster = endpoint->inputCluster(ZigbeeClusterLibrary::ClusterIdOnOff); + if (!onOffCluster) { + qCWarning(dcZigbeeDevelco()) << "Could not find On/Off cluster on" << thing << node << endpoint; + info->finish(Thing::ThingErrorHardwareFailure); + return; + } + + ZigbeeClusterReply *reply = onOffCluster->commandOnWithTimedOff(false, impulseDurationScaled, 0); + connect(reply, &ZigbeeClusterReply::finished, info, [=](){ + // Note: reply will be deleted automatically + if (reply->error() != ZigbeeClusterReply::ErrorNoError) { + qCWarning(dcZigbeeDevelco()) << "Failed to set on with timed off on" << thing << endpoint << reply->error(); + info->finish(Thing::ThingErrorHardwareFailure); + } else { + info->finish(Thing::ThingErrorNoError); + qCDebug(dcZigbeeDevelco()) << "Set on with timed off on finished successfully for" << thing << endpoint; + } + }); + return; } } @@ -456,8 +498,16 @@ void IntegrationPluginZigbeeDevelco::initIoModule(ZigbeeNode *node) { qCDebug(dcZigbeeDevelco()) << "Start initializing IO Module" << node; readDevelcoFirmwareVersion(node, node->getEndpoint(IO_MODULE_EP_INPUT1)); + + // Binding and reporting outputs configureOnOffPowerReporting(node, node->getEndpoint(IO_MODULE_EP_OUTPUT1)); - configureOnOffPowerReporting(node, node->getEndpoint(IO_MODULE_EP_OUTPUT1)); + configureOnOffPowerReporting(node, node->getEndpoint(IO_MODULE_EP_OUTPUT2)); + + // Binding and reporting inputs + configureBinaryInputReporting(node, node->getEndpoint(IO_MODULE_EP_INPUT1)); + configureBinaryInputReporting(node, node->getEndpoint(IO_MODULE_EP_INPUT2)); + configureBinaryInputReporting(node, node->getEndpoint(IO_MODULE_EP_INPUT3)); + configureBinaryInputReporting(node, node->getEndpoint(IO_MODULE_EP_INPUT4)); } void IntegrationPluginZigbeeDevelco::configureOnOffPowerReporting(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint) @@ -474,8 +524,9 @@ void IntegrationPluginZigbeeDevelco::configureOnOffPowerReporting(ZigbeeNode *no // Configure attribute reporting for lock state ZigbeeClusterLibrary::AttributeReportingConfiguration reportingConfig; reportingConfig.attributeId = ZigbeeClusterOnOff::AttributeOnOff; + reportingConfig.minReportingInterval = 0; + reportingConfig.maxReportingInterval = 600; reportingConfig.dataType = Zigbee::Bool; - reportingConfig.reportableChange = ZigbeeDataType(static_cast(1)).data(); qCDebug(dcZigbeeDevelco()) << "Configure attribute reporting for on/off cluster" << node << endpoint; ZigbeeClusterReply *reportingReply = endpoint->getInputCluster(ZigbeeClusterLibrary::ClusterIdOnOff)->configureReporting({reportingConfig}); @@ -503,8 +554,9 @@ void IntegrationPluginZigbeeDevelco::configureBinaryInputReporting(ZigbeeNode *n // Configure attribute reporting for lock state ZigbeeClusterLibrary::AttributeReportingConfiguration reportingConfig; reportingConfig.attributeId = ZigbeeClusterBinaryInput::AttributePresentValue; + reportingConfig.minReportingInterval = 0; + reportingConfig.maxReportingInterval = 600; reportingConfig.dataType = Zigbee::Bool; - reportingConfig.reportableChange = ZigbeeDataType(static_cast(1)).data(); qCDebug(dcZigbeeDevelco()) << "Configure attribute reporting for binary input cluster" << node << endpoint; ZigbeeClusterReply *reportingReply = endpoint->getInputCluster(ZigbeeClusterLibrary::ClusterIdBinaryInput)->configureReporting({reportingConfig}); diff --git a/zigbeedevelco/integrationpluginzigbeedevelco.json b/zigbeedevelco/integrationpluginzigbeedevelco.json index 5517d3b8..bbf58f73 100644 --- a/zigbeedevelco/integrationpluginzigbeedevelco.json +++ b/zigbeedevelco/integrationpluginzigbeedevelco.json @@ -38,7 +38,7 @@ "type": "uint", "unit": "MilliSeconds", "defaultValue": 100, - "minValue": 10 + "minValue": 100 } ], "stateTypes": [ @@ -135,6 +135,16 @@ "id": "62c5562a-8bdf-49b4-8e1d-f27442b2b360", "name": "alert", "displayName": "Identify" + }, + { + "id": "45ec5c65-0719-4148-82ea-3e69b34be939", + "name": "impulseOutput1", + "displayName": "Impulse output 1" + }, + { + "id": "d780946c-4ddf-4b59-a669-dbf6ecfda5d6", + "name": "impulseOutput2", + "displayName": "Impulse output 2" } ] } diff --git a/zigbeedevelco/translations/1b9e976d-e842-40e1-9fad-87d71a69c721-en_US.ts b/zigbeedevelco/translations/1b9e976d-e842-40e1-9fad-87d71a69c721-en_US.ts index a0b47a28..e5e1e220 100644 --- a/zigbeedevelco/translations/1b9e976d-e842-40e1-9fad-87d71a69c721-en_US.ts +++ b/zigbeedevelco/translations/1b9e976d-e842-40e1-9fad-87d71a69c721-en_US.ts @@ -4,8 +4,8 @@ ZigbeeDevelco - - + + Connected The name of the ParamType (ThingClass: ioModule, EventType: connected, ID: {16d5ebb7-21d1-4294-98a6-ca06eea8e3a3}) ---------- @@ -13,44 +13,56 @@ The name of the StateType ({16d5ebb7-21d1-4294-98a6-ca06eea8e3a3}) of ThingClass - + Connected changed The name of the EventType ({16d5ebb7-21d1-4294-98a6-ca06eea8e3a3}) of ThingClass ioModule - + Develco The name of the vendor ({e4b36f3e-ccdc-4a88-8968-39025c3ec742}) - + IEEE adress The name of the ParamType (ThingClass: ioModule, Type: thing, ID: {d9a3afa7-c460-43e7-bc84-c8b5ff1adf44}) - + IO Module The name of the ThingClass ({3fb419ef-795d-4f4d-b801-e7eaff16cdb0}) - + Identify The name of the ActionType ({62c5562a-8bdf-49b4-8e1d-f27442b2b360}) of ThingClass ioModule - + Impulse duration The name of the ParamType (ThingClass: ioModule, Type: settings, ID: {c2806b97-bf94-4ad2-ae22-5b5d7d1eaf5a}) - - + + Impulse output 1 + The name of the ActionType ({45ec5c65-0719-4148-82ea-3e69b34be939}) of ThingClass ioModule + + + + + Impulse output 2 + The name of the ActionType ({d780946c-4ddf-4b59-a669-dbf6ecfda5d6}) of ThingClass ioModule + + + + + Input 1 The name of the ParamType (ThingClass: ioModule, EventType: input1, ID: {bc23c7e8-f4ad-47c4-b938-f9af2dbd3393}) ---------- @@ -58,14 +70,14 @@ The name of the StateType ({bc23c7e8-f4ad-47c4-b938-f9af2dbd3393}) of ThingClass - + Input 1 changed The name of the EventType ({bc23c7e8-f4ad-47c4-b938-f9af2dbd3393}) of ThingClass ioModule - - + + Input 2 The name of the ParamType (ThingClass: ioModule, EventType: input2, ID: {065b0dc0-6d31-40ec-b356-02fea57e2fe1}) ---------- @@ -73,14 +85,14 @@ The name of the StateType ({065b0dc0-6d31-40ec-b356-02fea57e2fe1}) of ThingClass - + Input 2 changed The name of the EventType ({065b0dc0-6d31-40ec-b356-02fea57e2fe1}) of ThingClass ioModule - - + + Input 3 The name of the ParamType (ThingClass: ioModule, EventType: input3, ID: {8f2b052a-30b7-49aa-a8d4-503cb0b9b66b}) ---------- @@ -88,14 +100,14 @@ The name of the StateType ({8f2b052a-30b7-49aa-a8d4-503cb0b9b66b}) of ThingClass - + Input 3 changed The name of the EventType ({8f2b052a-30b7-49aa-a8d4-503cb0b9b66b}) of ThingClass ioModule - - + + Input 4 The name of the ParamType (ThingClass: ioModule, EventType: input4, ID: {caef986c-da13-4ef3-ab81-316244c7be1e}) ---------- @@ -103,15 +115,15 @@ The name of the StateType ({caef986c-da13-4ef3-ab81-316244c7be1e}) of ThingClass - + Input 4 changed The name of the EventType ({caef986c-da13-4ef3-ab81-316244c7be1e}) of ThingClass ioModule - - - + + + Output 1 The name of the ParamType (ThingClass: ioModule, ActionType: output1, ID: {aaeda2c6-439a-452a-b829-45d6249bdee6}) ---------- @@ -121,15 +133,15 @@ The name of the StateType ({aaeda2c6-439a-452a-b829-45d6249bdee6}) of ThingClass - + Output 1 changed The name of the EventType ({aaeda2c6-439a-452a-b829-45d6249bdee6}) of ThingClass ioModule - - - + + + Output 2 The name of the ParamType (ThingClass: ioModule, ActionType: output2, ID: {105cf314-35b5-4a8b-8e6d-d011009f97ff}) ---------- @@ -139,26 +151,26 @@ The name of the StateType ({105cf314-35b5-4a8b-8e6d-d011009f97ff}) of ThingClass - + Output 2 changed The name of the EventType ({105cf314-35b5-4a8b-8e6d-d011009f97ff}) of ThingClass ioModule - + Set output 1 The name of the ActionType ({aaeda2c6-439a-452a-b829-45d6249bdee6}) of ThingClass ioModule - + Set output 2 The name of the ActionType ({105cf314-35b5-4a8b-8e6d-d011009f97ff}) of ThingClass ioModule - - + + Signal strength The name of the ParamType (ThingClass: ioModule, EventType: signalStrength, ID: {0e09e6a6-8b3f-4b63-acb1-ac04ab31957a}) ---------- @@ -166,14 +178,14 @@ The name of the StateType ({0e09e6a6-8b3f-4b63-acb1-ac04ab31957a}) of ThingClass - + Signal strength changed The name of the EventType ({0e09e6a6-8b3f-4b63-acb1-ac04ab31957a}) of ThingClass ioModule - - + + Version The name of the ParamType (ThingClass: ioModule, EventType: version, ID: {f28c9a61-b8ab-419c-bd85-58692df26ac7}) ---------- @@ -181,19 +193,19 @@ The name of the StateType ({f28c9a61-b8ab-419c-bd85-58692df26ac7}) of ThingClass - + Version changed The name of the EventType ({f28c9a61-b8ab-419c-bd85-58692df26ac7}) of ThingClass ioModule - + Zigbee Develco The name of the plugin ZigbeeDevelco ({1b9e976d-e842-40e1-9fad-87d71a69c721}) - + Zigbee network UUID The name of the ParamType (ThingClass: ioModule, Type: thing, ID: {f4c83d2b-06e1-4206-98b7-e3ace79ff447})