Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement zigbee2mqtt protocol #1024

Merged
merged 17 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2024 awawa-dev
Copyright (c) 2020-2025 awawa-dev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions cmake/installers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ macro(DeployUnix TARGET)
"libdl"
"libexpat"
"libfontconfig"
"libgcc_s"
"libgpg-error"
"libgcc_s"
"libm"
"libpthread"
"librt"
Expand Down
2 changes: 1 addition & 1 deletion include/base/AutomaticToneMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/base/RawUdpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/bonjour/DiscoveryRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/bonjour/DiscoveryWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/db/SQLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/effects/EffectManufactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/flatbuffers/parser/FlatBuffersParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/flatbuffers/server/FlatBuffersServerConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/grabber/windows/DX/PixelShaderHyperHDR.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/grabber/windows/DX/VertexShaderHyperHDR.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/image/MemoryBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/led-drivers/LedDeviceManufactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
4 changes: 3 additions & 1 deletion include/led-drivers/net/DriverNetHomeAssistant.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DriverNetHomeAssistant : public LedDevice
QString homeAssistantHost;
QString longLivedAccessToken;
int transition;
int constantBrightness;
int constantBrightness = 255;
bool restoreOriginalState;

std::list<HomeAssistantLamp> lamps;
Expand All @@ -34,6 +34,7 @@ class DriverNetHomeAssistant : public LedDevice

QString name;
Mode colorModel;
int currentBrightness = 255;

struct
{
Expand Down Expand Up @@ -63,6 +64,7 @@ class DriverNetHomeAssistant : public LedDevice
HomeAssistantInstance _haInstance;

std::unique_ptr<ProviderRestApi> _restApi;
long long _lastUpdate;

static bool isRegistered;
};
67 changes: 67 additions & 0 deletions include/led-drivers/net/DriverNetZigbee2mqtt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once

#ifndef PCH_ENABLED
#include <QJsonObject>
#include <QJsonArray>
#include <memory>
#include <list>
#include <atomic>
#include <chrono>
#endif

#include <led-drivers/LedDevice.h>
#include <linalg.h>

class DriverNetZigbee2mqtt : public LedDevice
{
Q_OBJECT

struct Zigbee2mqttLamp;

struct Zigbee2mqttInstance
{
int transition;
int constantBrightness = 255;

std::list<Zigbee2mqttLamp> lamps;
};

struct Zigbee2mqttLamp
{
enum Mode { RGB = 0, HSV };

QString name;
Mode colorModel;
int currentBrightness = 255;
};

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;
int _timeLogger;
QString _discoveryMessage;
int _mqttId;
long long _lastUpdate;

static int mqttId;
static bool isRegistered;
};
2 changes: 1 addition & 1 deletion include/led-drivers/serial/EspTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/led-drivers/spi/DriverSpiHD108.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/led-strip/ChannelCalibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/led-strip/ColorCalibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/led-strip/LedCalibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/lut-calibrator/BestResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/lut-calibrator/BoardUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/lut-calibrator/CalibrationWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/lut-calibrator/CapturedColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/lut-calibrator/ColorSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/lut-calibrator/LutCalibrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/lut-calibrator/YuvConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
9 changes: 9 additions & 0 deletions include/mqtt/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <QSet>
#include <QJsonDocument>
#include <QTimer>
#include <QStringList>
#include <map>
#endif

#include <utils/Logger.h>
Expand All @@ -28,6 +30,10 @@ public slots:

void handleSettingsUpdate(settings::type type, const QJsonDocument& config);

void handleSignalMqttSubscribe(bool subscribe, QString topic);
void handleSignalMqttPublish(QString topic, QString payload);
void handleSignalMqttLastWill(QString id, QStringList pairs);

private slots:
void connected();
void error(const QMQTT::ClientError error);
Expand Down Expand Up @@ -56,6 +62,9 @@ private slots:
QTimer* _retryTimer;
bool _initialized;
QJsonArray _resultArray;
bool _disableApiAccess;

std::map<QString, QStringList> _lastWill;

Logger* _log;
QMQTT::Client* _clientInstance;
Expand Down
2 changes: 1 addition & 1 deletion include/proto-nano-server/ProtoNanoClientConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/suspend-handler/SuspendHandlerDummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/suspend-handler/SuspendHandlerLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
2 changes: 1 addition & 1 deletion include/suspend-handler/SuspendHandlerMacOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* MIT License
*
* Copyright (c) 2020-2024 awawa-dev
* Copyright (c) 2020-2025 awawa-dev
*
* Project homesite: https://github.com/awawa-dev/HyperHDR
*
Expand Down
Loading
Loading