Skip to content

Commit

Permalink
Zigbee2mqtt: fix false 200ms communication timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Dec 30, 2024
1 parent 2ed4cd4 commit 789ace3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 1 addition & 5 deletions sources/hyperhdr/HyperHdrDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ void HyperHdrDaemon::instanceStateChangedHandler(InstanceState state, quint8 ins
_flatProtoBuffersThread->start();
}

if (_mqttThread != nullptr && !_mqttThread->isRunning())
{
_mqttThread->start();
}

if (_networkThread != nullptr && !_networkThread->isRunning())
{
_networkThread->start();
Expand Down Expand Up @@ -401,6 +396,7 @@ void HyperHdrDaemon::startNetworkServices()
[_mqtt](QThread* mqttThread) {
THREAD_REMOVER(QString("MQTT"), mqttThread, _mqtt);
});
_mqttThread->start();
#endif
}

Expand Down
9 changes: 8 additions & 1 deletion sources/led-drivers/net/DriverNetZigbee2mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ bool DriverNetZigbee2mqtt::powerOnOff(bool isOn)

for (const auto& lamp : _zigInstance.lamps)
{
QString topic = QString("zigbee2mqtt/%1/set").arg(lamp.name);
QString topicDevice = QString("zigbee2mqtt/%1").arg(lamp.name);
QString topic = QString("%1/set").arg(topicDevice);
QJsonObject row;

row["state"] = (isOn) ? "ON" : "OFF";
Expand All @@ -75,12 +76,18 @@ bool DriverNetZigbee2mqtt::powerOnOff(bool isOn)

if (isOn)
{
emit GlobalSignals::getInstance()->SignalMqttSubscribe(true, topicDevice);

row["state"] = "OFF";
doc.setObject(row);

lastWill.push_back(topic);
lastWill.push_back(doc.toJson(QJsonDocument::Compact));
}
else
{
emit GlobalSignals::getInstance()->SignalMqttSubscribe(false, topicDevice);
}
}

if (_zigInstance.lamps.size() > 0)
Expand Down

0 comments on commit 789ace3

Please sign in to comment.