update to latest resource api changes
This commit is contained in:
parent
e9c4a74409
commit
20813ef401
@ -163,7 +163,7 @@ void IntegrationPluginZigbeeGenericLights::setupThing(ThingSetupInfo *info)
|
|||||||
// Get the node for this thing
|
// Get the node for this thing
|
||||||
QUuid networkUuid = thing->paramValue(m_networkUuidParamTypeIds.value(thing->thingClassId())).toUuid();
|
QUuid networkUuid = thing->paramValue(m_networkUuidParamTypeIds.value(thing->thingClassId())).toUuid();
|
||||||
ZigbeeAddress zigbeeAddress = ZigbeeAddress(thing->paramValue(m_ieeeAddressParamTypeIds.value(thing->thingClassId())).toString());
|
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) {
|
if (!node) {
|
||||||
qCWarning(dcZigbeeGenericLights()) << "Zigbee node for" << info->thing()->name() << "not found.´";
|
qCWarning(dcZigbeeGenericLights()) << "Zigbee node for" << info->thing()->name() << "not found.´";
|
||||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
|
|||||||
@ -33,6 +33,8 @@
|
|||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "hardware/zigbee/zigbeehardwareresource.h"
|
#include "hardware/zigbee/zigbeehardwareresource.h"
|
||||||
|
|
||||||
|
#include "zcl/hvac/zigbeeclusterthermostat.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
IntegrationPluginZigbeeGeneric::IntegrationPluginZigbeeGeneric()
|
IntegrationPluginZigbeeGeneric::IntegrationPluginZigbeeGeneric()
|
||||||
@ -78,6 +80,19 @@ bool IntegrationPluginZigbeeGeneric::handleNode(ZigbeeNode *node, const QUuid &n
|
|||||||
return handled;
|
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()
|
void IntegrationPluginZigbeeGeneric::init()
|
||||||
{
|
{
|
||||||
hardwareManager()->zigbeeResource()->registerHandler(this, ZigbeeHardwareResource::HandlerTypeCatchAll);
|
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();
|
QUuid networkUuid = thing->paramValue(m_networkUuidParamTypeIds.value(thing->thingClassId())).toUuid();
|
||||||
qCDebug(dcZigbeeGeneric()) << "Nework uuid:" << networkUuid;
|
qCDebug(dcZigbeeGeneric()) << "Nework uuid:" << networkUuid;
|
||||||
ZigbeeAddress zigbeeAddress = ZigbeeAddress(thing->paramValue(m_ieeeAddressParamTypeIds.value(thing->thingClassId())).toString());
|
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) {
|
if (!node) {
|
||||||
qCWarning(dcZigbeeGeneric()) << "Zigbee node for" << info->thing()->name() << "not found.´";
|
qCWarning(dcZigbeeGeneric()) << "Zigbee node for" << info->thing()->name() << "not found.´";
|
||||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_zigbeeNodes.insert(thing, node);
|
||||||
|
|
||||||
ZigbeeNodeEndpoint *endpoint = node->getEndpoint(0x01);
|
ZigbeeNodeEndpoint *endpoint = node->getEndpoint(0x01);
|
||||||
if (!endpoint) {
|
if (!endpoint) {
|
||||||
qCWarning(dcZigbeeGeneric()) << "Zigbee endpoint 1 not found on" << thing->name();
|
qCWarning(dcZigbeeGeneric()) << "Zigbee endpoint 1 not found on" << thing->name();
|
||||||
@ -127,7 +144,8 @@ void IntegrationPluginZigbeeGeneric::setupThing(ThingSetupInfo *info)
|
|||||||
// Type specific setup
|
// Type specific setup
|
||||||
if (thing->thingClassId() == thermostatThingClassId) {
|
if (thing->thingClassId() == thermostatThingClassId) {
|
||||||
// TODO: Thermostat cluster is missing
|
// 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)
|
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;
|
QString name() const override;
|
||||||
bool handleNode(ZigbeeNode *node, const QUuid &networkUuid) override;
|
bool handleNode(ZigbeeNode *node, const QUuid &networkUuid) override;
|
||||||
|
void handleRemoveNode(ZigbeeNode *node, const QUuid &networkUuid) override;
|
||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
void setupThing(ThingSetupInfo *info) override;
|
void setupThing(ThingSetupInfo *info) override;
|
||||||
@ -56,6 +57,7 @@ public:
|
|||||||
void thingRemoved(Thing *thing) override;
|
void thingRemoved(Thing *thing) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QHash<Thing*, ZigbeeNode*> m_zigbeeNodes;
|
||||||
|
|
||||||
QHash<ThingClassId, ParamTypeId> m_ieeeAddressParamTypeIds;
|
QHash<ThingClassId, ParamTypeId> m_ieeeAddressParamTypeIds;
|
||||||
QHash<ThingClassId, ParamTypeId> m_networkUuidParamTypeIds;
|
QHash<ThingClassId, ParamTypeId> m_networkUuidParamTypeIds;
|
||||||
|
|||||||
@ -161,7 +161,7 @@ void IntegrationPluginZigbeeLumi::setupThing(ThingSetupInfo *info)
|
|||||||
// Get the node for this thing
|
// Get the node for this thing
|
||||||
QUuid networkUuid = thing->paramValue(m_networkUuidParamTypeIds.value(thing->thingClassId())).toUuid();
|
QUuid networkUuid = thing->paramValue(m_networkUuidParamTypeIds.value(thing->thingClassId())).toUuid();
|
||||||
ZigbeeAddress zigbeeAddress = ZigbeeAddress(thing->paramValue(m_zigbeeAddressParamTypeIds.value(thing->thingClassId())).toString());
|
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) {
|
if (!node) {
|
||||||
qCWarning(dcZigbeeLumi()) << "Zigbee node for" << info->thing()->name() << "not found.´";
|
qCWarning(dcZigbeeLumi()) << "Zigbee node for" << info->thing()->name() << "not found.´";
|
||||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user