Improve generic power socket device creation and init power state reading
This commit is contained in:
parent
26f2be5029
commit
b97b7c3ee3
@ -91,20 +91,20 @@ bool IntegrationPluginZigbeeGeneric::handleNode(ZigbeeNode *node, const QUuid &n
|
|||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check on/off plug
|
// Check on/off thing
|
||||||
if ((endpoint->profile() == Zigbee::ZigbeeProfile::ZigbeeProfileLightLink &&
|
if ((endpoint->profile() == Zigbee::ZigbeeProfile::ZigbeeProfileLightLink && endpoint->deviceId() == Zigbee::LightLinkDevice::LightLinkDeviceOnOffPlugin) ||
|
||||||
endpoint->deviceId() == Zigbee::LightLinkDevice::LightLinkDeviceOnOffPlugin) ||
|
(endpoint->profile() == Zigbee::ZigbeeProfile::ZigbeeProfileHomeAutomation && endpoint->deviceId() == Zigbee::HomeAutomationDeviceOnOffPlugin) ||
|
||||||
(endpoint->profile() == Zigbee::ZigbeeProfile::ZigbeeProfileHomeAutomation &&
|
(endpoint->profile() == Zigbee::ZigbeeProfile::ZigbeeProfileHomeAutomation && endpoint->deviceId() == Zigbee::HomeAutomationDeviceMainPowerOutlet) ||
|
||||||
endpoint->deviceId() == Zigbee::HomeAutomationDeviceOnOffPlugin) ||
|
(endpoint->profile() == Zigbee::ZigbeeProfile::ZigbeeProfileHomeAutomation && endpoint->deviceId() == Zigbee::HomeAutomationDeviceSmartPlug)) {
|
||||||
(endpoint->profile() == Zigbee::ZigbeeProfile::ZigbeeProfileHomeAutomation &&
|
|
||||||
endpoint->deviceId() == Zigbee::HomeAutomationDeviceMainPowerOutlet) ||
|
|
||||||
(endpoint->profile() == Zigbee::ZigbeeProfile::ZigbeeProfileHomeAutomation &&
|
|
||||||
endpoint->deviceId() == Zigbee::HomeAutomationDeviceSmartPlug)) {
|
|
||||||
|
|
||||||
// FIXME: create powersocket with metering for SmartPlug device ID
|
// Simple on/off device
|
||||||
qCDebug(dcZigbeeGeneric()) << "Handeling power socket endpoint for" << node << endpoint;
|
if (endpoint->hasInputCluster(ZigbeeClusterLibrary::ClusterIdOnOff)) {
|
||||||
createThing(powerSocketThingClassId, networkUuid, node, endpoint);
|
// FIXME: create powersocket with metering for SmartPlug device ID
|
||||||
handled = true;
|
qCDebug(dcZigbeeGeneric()) << "Handeling power socket endpoint for" << node << endpoint;
|
||||||
|
createThing(powerSocketThingClassId, networkUuid, node, endpoint);
|
||||||
|
initSimplePowerSocket(node, endpoint);
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check door lock
|
// Check door lock
|
||||||
@ -455,6 +455,23 @@ void IntegrationPluginZigbeeGeneric::createThing(const ThingClassId &thingClassI
|
|||||||
emit autoThingsAppeared({descriptor});
|
emit autoThingsAppeared({descriptor});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IntegrationPluginZigbeeGeneric::initSimplePowerSocket(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint)
|
||||||
|
{
|
||||||
|
// Get the on/off server cluster from the endpoint
|
||||||
|
ZigbeeClusterOnOff *onOffCluster = endpoint->inputCluster<ZigbeeClusterOnOff>(ZigbeeClusterLibrary::ClusterIdOnOff);
|
||||||
|
if (!onOffCluster)
|
||||||
|
return;
|
||||||
|
|
||||||
|
qCDebug(dcZigbeeGeneric()) << "Reading on/off power value for" << node << endpoint;
|
||||||
|
ZigbeeClusterReply *reply = onOffCluster->readAttributes({ZigbeeClusterOnOff::AttributeOnOff});
|
||||||
|
connect(reply, &ZigbeeClusterReply::finished, node, [=](){
|
||||||
|
if (reply->error() != ZigbeeClusterReply::ErrorNoError) {
|
||||||
|
qCWarning(dcZigbeeGeneric()) << "Failed to read on/off cluster attribute from" << node << endpoint << reply->error();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void IntegrationPluginZigbeeGeneric::initializeDoorLock(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint)
|
void IntegrationPluginZigbeeGeneric::initializeDoorLock(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint)
|
||||||
{
|
{
|
||||||
qCDebug(dcZigbeeGeneric()) << "Read power configuration cluster attributes" << node;
|
qCDebug(dcZigbeeGeneric()) << "Read power configuration cluster attributes" << node;
|
||||||
|
|||||||
@ -73,6 +73,7 @@ private:
|
|||||||
ZigbeeNodeEndpoint *findEndpoint(Thing *thing);
|
ZigbeeNodeEndpoint *findEndpoint(Thing *thing);
|
||||||
void createThing(const ThingClassId &thingClassId, const QUuid &networkUuid, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
void createThing(const ThingClassId &thingClassId, const QUuid &networkUuid, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
||||||
|
|
||||||
|
void initSimplePowerSocket(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
||||||
void initializeDoorLock(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
void initializeDoorLock(ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user