update to latest resource api changes
parent
e9c4a74409
commit
20813ef401
|
|
@ -163,7 +163,7 @@ void IntegrationPluginZigbeeGenericLights::setupThing(ThingSetupInfo *info)
|
|||
// Get the node for this thing
|
||||
QUuid networkUuid = thing->paramValue(m_networkUuidParamTypeIds.value(thing->thingClassId())).toUuid();
|
||||
ZigbeeAddress zigbeeAddress = ZigbeeAddress(thing->paramValue(m_ieeeAddressParamTypeIds.value(thing->thingClassId())).toString());
|
||||
ZigbeeNode *node = hardwareManager()->zigbeeResource()->getNode(networkUuid, zigbeeAddress);
|
||||
ZigbeeNode *node = hardwareManager()->zigbeeResource()->claimNode(this, networkUuid, zigbeeAddress);
|
||||
if (!node) {
|
||||
qCWarning(dcZigbeeGenericLights()) << "Zigbee node for" << info->thing()->name() << "not found.´";
|
||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
#include "plugininfo.h"
|
||||
#include "hardware/zigbee/zigbeehardwareresource.h"
|
||||
|
||||
#include "zcl/hvac/zigbeeclusterthermostat.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
IntegrationPluginZigbeeGeneric::IntegrationPluginZigbeeGeneric()
|
||||
|
|
@ -78,6 +80,19 @@ bool IntegrationPluginZigbeeGeneric::handleNode(ZigbeeNode *node, const QUuid &n
|
|||
return handled;
|
||||
}
|
||||
|
||||
void IntegrationPluginZigbeeGeneric::handleRemoveNode(ZigbeeNode *node, const QUuid &networkUuid)
|
||||
{
|
||||
Q_UNUSED(networkUuid)
|
||||
Thing *thing = m_zigbeeNodes.key(node);
|
||||
if (thing) {
|
||||
qCDebug(dcZigbeeGeneric()) << node << "for" << thing << "has left the network.";
|
||||
emit autoThingDisappeared(thing->id());
|
||||
|
||||
// Removing it from our map to prevent a loop that would ask the zigbee network to remove this node (see thingRemoved())
|
||||
m_zigbeeNodes.remove(thing);
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginZigbeeGeneric::init()
|
||||
{
|
||||
hardwareManager()->zigbeeResource()->registerHandler(this, ZigbeeHardwareResource::HandlerTypeCatchAll);
|
||||
|
|
@ -94,13 +109,15 @@ void IntegrationPluginZigbeeGeneric::setupThing(ThingSetupInfo *info)
|
|||
QUuid networkUuid = thing->paramValue(m_networkUuidParamTypeIds.value(thing->thingClassId())).toUuid();
|
||||
qCDebug(dcZigbeeGeneric()) << "Nework uuid:" << networkUuid;
|
||||
ZigbeeAddress zigbeeAddress = ZigbeeAddress(thing->paramValue(m_ieeeAddressParamTypeIds.value(thing->thingClassId())).toString());
|
||||
ZigbeeNode *node = hardwareManager()->zigbeeResource()->getNode(networkUuid, zigbeeAddress);
|
||||
ZigbeeNode *node = hardwareManager()->zigbeeResource()->claimNode(this, networkUuid, zigbeeAddress);
|
||||
if (!node) {
|
||||
qCWarning(dcZigbeeGeneric()) << "Zigbee node for" << info->thing()->name() << "not found.´";
|
||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||
return;
|
||||
}
|
||||
|
||||
m_zigbeeNodes.insert(thing, node);
|
||||
|
||||
ZigbeeNodeEndpoint *endpoint = node->getEndpoint(0x01);
|
||||
if (!endpoint) {
|
||||
qCWarning(dcZigbeeGeneric()) << "Zigbee endpoint 1 not found on" << thing->name();
|
||||
|
|
@ -127,7 +144,8 @@ void IntegrationPluginZigbeeGeneric::setupThing(ThingSetupInfo *info)
|
|||
// Type specific setup
|
||||
if (thing->thingClassId() == thermostatThingClassId) {
|
||||
// TODO: Thermostat cluster is missing
|
||||
// ZigbeeClusterThermostat *thermostatCluster = endpoint->inputCluster<ZigbeeClusterThermostat>(ZigbeeClusterLibrary::ClusterIdThermostat);
|
||||
// ZigbeeClusterThermostat *thermostatCluster = endpoint->outputCluster<ZigbeeClusterThermostat>(ZigbeeClusterLibrary::ClusterIdThermostat);
|
||||
// thermostatCluster->attribute(ZigbeeClusterLibrary::ClusterId);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -142,5 +160,9 @@ void IntegrationPluginZigbeeGeneric::executeAction(ThingActionInfo *info)
|
|||
|
||||
void IntegrationPluginZigbeeGeneric::thingRemoved(Thing *thing)
|
||||
{
|
||||
Q_UNUSED(thing)
|
||||
ZigbeeNode *node = m_zigbeeNodes.take(thing);
|
||||
if (node) {
|
||||
QUuid networkUuid = thing->paramValue(m_networkUuidParamTypeIds.value(thing->thingClassId())).toUuid();
|
||||
hardwareManager()->zigbeeResource()->removeNodeFromNetwork(networkUuid, node);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ public:
|
|||
|
||||
QString name() const override;
|
||||
bool handleNode(ZigbeeNode *node, const QUuid &networkUuid) override;
|
||||
void handleRemoveNode(ZigbeeNode *node, const QUuid &networkUuid) override;
|
||||
|
||||
void init() override;
|
||||
void setupThing(ThingSetupInfo *info) override;
|
||||
|
|
@ -56,6 +57,7 @@ public:
|
|||
void thingRemoved(Thing *thing) override;
|
||||
|
||||
private:
|
||||
QHash<Thing*, ZigbeeNode*> m_zigbeeNodes;
|
||||
|
||||
QHash<ThingClassId, ParamTypeId> m_ieeeAddressParamTypeIds;
|
||||
QHash<ThingClassId, ParamTypeId> m_networkUuidParamTypeIds;
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ void IntegrationPluginZigbeeLumi::setupThing(ThingSetupInfo *info)
|
|||
// Get the node for this thing
|
||||
QUuid networkUuid = thing->paramValue(m_networkUuidParamTypeIds.value(thing->thingClassId())).toUuid();
|
||||
ZigbeeAddress zigbeeAddress = ZigbeeAddress(thing->paramValue(m_zigbeeAddressParamTypeIds.value(thing->thingClassId())).toString());
|
||||
ZigbeeNode *node = hardwareManager()->zigbeeResource()->getNode(networkUuid, zigbeeAddress);
|
||||
ZigbeeNode *node = hardwareManager()->zigbeeResource()->claimNode(this, networkUuid, zigbeeAddress);
|
||||
if (!node) {
|
||||
qCWarning(dcZigbeeLumi()) << "Zigbee node for" << info->thing()->name() << "not found.´";
|
||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||
|
|
|
|||
Loading…
Reference in New Issue