This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Michael Zanetti 6afc214202 More work on OnOff, LevelControl and ScenesCluster
This alignes the OnOff cluster with the LevelControl cluster in terms
of signal behavior: Previously, the OnOff cluster would fire a generic
commandSent() signal for some commands and specific signals for others.
Effectively forcing the user to connect multiple signals even if only
the command would be of interest.

The LevelControl cluster instead always fired a generic commandSent()
signal and *additionally* more specific signals for parsed parameters.

This changes the OnOff cluster to be in line with the LevelCluster
as and making the API a bit simpler to use when parameters are not of
interest.

Also it completes the specific parsing for all 3 clusters.
2021-12-07 10:14:02 +01:00

106 lines
3.6 KiB
C++

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* 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 <https://www.gnu.org/licenses/>.
*
* 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 ZIGBEECLUSTERONOFF_H
#define ZIGBEECLUSTERONOFF_H
#include <QObject>
#include "zcl/zigbeecluster.h"
#include "zcl/zigbeeclusterreply.h"
class ZigbeeNode;
class ZigbeeNetwork;
class ZigbeeNodeEndpoint;
class ZigbeeNetworkReply;
class ZigbeeClusterOnOff : public ZigbeeCluster
{
Q_OBJECT
friend class ZigbeeNode;
friend class ZigbeeNetwork;
public:
enum Attribute {
AttributeOnOff = 0x0000,
AttributeGlobalSceneControl = 0x4000,
AttributeOnTime = 0x4001,
AttributeOffTime = 0x4002
};
Q_ENUM(Attribute)
enum Command {
CommandOff = 0x00,
CommandOn = 0x01,
CommandToggle = 0x02,
CommandOffWithEffect = 0x40,
CommandOnWithRecallGlobalScene = 0x41,
CommandOnWithTimedOff = 0x42
};
Q_ENUM(Command)
enum Effect {
EffectDelayedAllOff = 0x00,
EffectDyingLight = 0x01
};
Q_ENUM(Effect)
explicit ZigbeeClusterOnOff(ZigbeeNetwork *network, ZigbeeNode *node, ZigbeeNodeEndpoint *endpoint, Direction direction, QObject *parent = nullptr);
ZigbeeClusterReply *commandOff();
ZigbeeClusterReply *commandOn();
ZigbeeClusterReply *commandToggle();
ZigbeeClusterReply *commandOffWithEffect(Effect effect, quint8 effectVariant = 0x00);
ZigbeeClusterReply *commandOnWithRecallGlobalScene();
ZigbeeClusterReply *commandOnWithTimedOff(bool acceptOnlyWhenOn, quint16 onTime, quint16 offWaitTime);
bool power() const;
private:
bool m_power = false;
void setAttribute(const ZigbeeClusterAttribute &attribute) override;
protected:
void processDataIndication(ZigbeeClusterLibrary::Frame frame) override;
signals:
// Server cluster signals
void powerChanged(bool power);
// Client cluster signals
void commandSent(Command command, const QByteArray &parameters = QByteArray());
// On and off time is in 1/10 seconds
void commandOnWithTimedOffSent(bool acceptOnlyWhenOn, quint16 onTime, quint16 offTime);
// On and off time is in 1/10 seconds
void commandOffWithEffectSent(Effect effect, quint8 effectVariant);
};
#endif // ZIGBEECLUSTERONOFF_H