-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
555 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
|
||
#ifndef PCH_ENABLED | ||
#include <QJsonObject> | ||
#include <QJsonArray> | ||
#include <memory> | ||
#include <list> | ||
#include <atomic> | ||
#endif | ||
|
||
#include <led-drivers/LedDevice.h> | ||
#include <linalg.h> | ||
|
||
class DriverNetZigbee2mqtt : public LedDevice | ||
{ | ||
Q_OBJECT | ||
|
||
struct Zigbee2mqttLamp; | ||
|
||
struct Zigbee2mqttInstance | ||
{ | ||
int transition; | ||
int constantBrightness; | ||
|
||
std::list<Zigbee2mqttLamp> lamps; | ||
}; | ||
|
||
struct Zigbee2mqttLamp | ||
{ | ||
enum Mode { RGB = 0, HSV }; | ||
|
||
QString name; | ||
Mode colorModel; | ||
}; | ||
|
||
public: | ||
explicit DriverNetZigbee2mqtt(const QJsonObject& deviceConfig); | ||
static LedDevice* construct(const QJsonObject& deviceConfig); | ||
|
||
QJsonObject discover(const QJsonObject& params) override; | ||
|
||
void identify(const QJsonObject& params) override; | ||
|
||
public slots: | ||
void handlerSignalMqttReceived(QString topic, QString payload); | ||
|
||
protected: | ||
bool powerOn() override; | ||
bool powerOff() override; | ||
|
||
private: | ||
bool init(const QJsonObject& deviceConfig) override; | ||
int write(const std::vector<ColorRgb>& ledValues) override; | ||
bool powerOnOff(bool isOn); | ||
|
||
Zigbee2mqttInstance _zigInstance; | ||
std::atomic<bool> _discoveryFinished, _colorsFinished; | ||
int _timeLogger; | ||
QString _discoveryMessage; | ||
|
||
static bool isRegistered; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.