From 5901dc06b5b041427fd2f96769bc690daf006a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 26 Nov 2020 13:16:53 +0100 Subject: [PATCH] Add multistate value cluster --- libnymea-zigbee/libnymea-zigbee.pro | 2 + .../general/zigbeeclustermultistatevalue.cpp | 41 ++++++++++++ .../general/zigbeeclustermultistatevalue.h | 64 +++++++++++++++++++ libnymea-zigbee/zigbeenodeendpoint.cpp | 2 + libnymea-zigbee/zigbeenodeendpoint.h | 1 + 5 files changed, 110 insertions(+) create mode 100644 libnymea-zigbee/zcl/general/zigbeeclustermultistatevalue.cpp create mode 100644 libnymea-zigbee/zcl/general/zigbeeclustermultistatevalue.h diff --git a/libnymea-zigbee/libnymea-zigbee.pro b/libnymea-zigbee/libnymea-zigbee.pro index 13fa5c7..f5481b5 100644 --- a/libnymea-zigbee/libnymea-zigbee.pro +++ b/libnymea-zigbee/libnymea-zigbee.pro @@ -28,6 +28,7 @@ SOURCES += \ zcl/general/zigbeeclusterlevelcontrol.cpp \ zcl/general/zigbeeclustermultistateinput.cpp \ zcl/general/zigbeeclustermultistateoutput.cpp \ + zcl/general/zigbeeclustermultistatevalue.cpp \ zcl/general/zigbeeclusteronoff.cpp \ zcl/general/zigbeeclusterpowerconfiguration.cpp \ zcl/hvac/zigbeeclusterthermostat.cpp \ @@ -93,6 +94,7 @@ HEADERS += \ zcl/general/zigbeeclusterlevelcontrol.h \ zcl/general/zigbeeclustermultistateinput.h \ zcl/general/zigbeeclustermultistateoutput.h \ + zcl/general/zigbeeclustermultistatevalue.h \ zcl/general/zigbeeclusteronoff.h \ zcl/general/zigbeeclusterpowerconfiguration.h \ zcl/hvac/zigbeeclusterthermostat.h \ diff --git a/libnymea-zigbee/zcl/general/zigbeeclustermultistatevalue.cpp b/libnymea-zigbee/zcl/general/zigbeeclustermultistatevalue.cpp new file mode 100644 index 0000000..24f5ece --- /dev/null +++ b/libnymea-zigbee/zcl/general/zigbeeclustermultistatevalue.cpp @@ -0,0 +1,41 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* +* Copyright 2013 - 2020, nymea GmbH +* Contact: contact@nymea.io +* +* This file is part of nymea-zigbee. +* This project including source code and documentation is protected by copyright law, and +* remains the property of nymea GmbH. All rights, including reproduction, publication, +* editing and translation, are reserved. The use of this project is subject to the terms of a +* license agreement to be concluded with nymea GmbH in accordance with the terms +* of use of nymea GmbH, available under https://nymea.io/license +* +* GNU Lesser General Public License Usage +* Alternatively, this project may be redistributed and/or modified under the terms of the GNU +* Lesser General Public License as published by the Free Software Foundation; version 3. +* this project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* See the GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License along with this project. +* If not, see . +* +* For any further details and any questions please contact us under contact@nymea.io +* or see our FAQ/Licensing Information on https://nymea.io/license/faq +* +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "zigbeeclustermultistatevalue.h" +#include "loggingcategory.h" + +ZigbeeClusterMultistateValue::ZigbeeClusterMultistateValue(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent) : + ZigbeeCluster(network, node, endpoint, ZigbeeClusterLibrary::ClusterIdMultistateValue, direction, parent) +{ + +} + +void ZigbeeClusterMultistateValue::setAttribute(const ZigbeeClusterAttribute &attribute) +{ + qCDebug(dcZigbeeCluster()) << "Update attribute" << m_node << m_endpoint << this << static_cast(attribute.id()) << attribute.dataType(); + updateOrAddAttribute(attribute); +} diff --git a/libnymea-zigbee/zcl/general/zigbeeclustermultistatevalue.h b/libnymea-zigbee/zcl/general/zigbeeclustermultistatevalue.h new file mode 100644 index 0000000..56a465e --- /dev/null +++ b/libnymea-zigbee/zcl/general/zigbeeclustermultistatevalue.h @@ -0,0 +1,64 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* +* Copyright 2013 - 2020, nymea GmbH +* Contact: contact@nymea.io +* +* This file is part of nymea-zigbee. +* This project including source code and documentation is protected by copyright law, and +* remains the property of nymea GmbH. All rights, including reproduction, publication, +* editing and translation, are reserved. The use of this project is subject to the terms of a +* license agreement to be concluded with nymea GmbH in accordance with the terms +* of use of nymea GmbH, available under https://nymea.io/license +* +* GNU Lesser General Public License Usage +* Alternatively, this project may be redistributed and/or modified under the terms of the GNU +* Lesser General Public License as published by the Free Software Foundation; version 3. +* this project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* See the GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License along with this project. +* If not, see . +* +* For any further details and any questions please contact us under contact@nymea.io +* or see our FAQ/Licensing Information on https://nymea.io/license/faq +* +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef ZIGBEECLUSTERMULTISTATEVALUE_H +#define ZIGBEECLUSTERMULTISTATEVALUE_H + +#include + +#include "zcl/zigbeecluster.h" + +class ZigbeeClusterMultistateValue : public ZigbeeCluster +{ + Q_OBJECT + + friend class ZigbeeNode; + friend class ZigbeeNetwork; + +public: + enum Attribute { + AttributeStateText = 0x000E, + AttributeDescription = 0x001C, + AttributeNumberOfStates = 0x004A, + AttributeOutOfService = 0x0051, + AttributePresentValue = 0x0055, + AttributePriorityArray = 0x0057, + AttributeReliability = 0x0067, + AttributeRelinquishDefault = 0x0068, + AttributeStatusFlags = 0x006F, + AttributeApplicationType = 0x0100 + }; + Q_ENUM(Attribute) + + explicit ZigbeeClusterMultistateValue(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr); + +private: + void setAttribute(const ZigbeeClusterAttribute &attribute) override; + +}; + +#endif // ZIGBEECLUSTERMULTISTATEVALUE_H diff --git a/libnymea-zigbee/zigbeenodeendpoint.cpp b/libnymea-zigbee/zigbeenodeendpoint.cpp index 162e3ee..4cd5e3f 100644 --- a/libnymea-zigbee/zigbeenodeendpoint.cpp +++ b/libnymea-zigbee/zigbeenodeendpoint.cpp @@ -193,6 +193,8 @@ ZigbeeCluster *ZigbeeNodeEndpoint::createCluster(ZigbeeClusterLibrary::ClusterId return new ZigbeeClusterMultistateInput(m_network, m_node, this, direction, this); case ZigbeeClusterLibrary::ClusterIdMultistateOutput: return new ZigbeeClusterMultistateOutput(m_network, m_node, this, direction, this); + case ZigbeeClusterLibrary::ClusterIdMultistateValue: + return new ZigbeeClusterMultistateValue(m_network, m_node, this, direction, this); // Measurement case ZigbeeClusterLibrary::ClusterIdIlluminanceMeasurement: diff --git a/libnymea-zigbee/zigbeenodeendpoint.h b/libnymea-zigbee/zigbeenodeendpoint.h index 917ba9f..14de96b 100644 --- a/libnymea-zigbee/zigbeenodeendpoint.h +++ b/libnymea-zigbee/zigbeenodeendpoint.h @@ -51,6 +51,7 @@ #include "zcl/general/zigbeeclusterbinaryvalue.h" #include "zcl/general/zigbeeclustermultistateinput.h" #include "zcl/general/zigbeeclustermultistateoutput.h" +#include "zcl/general/zigbeeclustermultistatevalue.h" #include "zcl/closures/zigbeeclusterdoorlock.h"