Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Илья Титов committed Jun 14, 2024
1 parent cb7574c commit 945c1f6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
11 changes: 3 additions & 8 deletions actions/tuya.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,13 @@ QByteArray ActionsTUYA::ChildLock::request(const QString &, const QVariant &data

QByteArray ActionsTUYA::IRCode::request(const QString &, const QVariant &data)
{
QJsonObject json = {{"delay", 300}, {"key1", QJsonObject {{"freq", 38000}, {"key_code", data.toString()}, {"num", 1}, {"type", 1}}}, {"key_num", 1}};
QByteArray message = QJsonDocument(json).toJson(QJsonDocument::Compact);
quint32 length = message.length();

QByteArray message = QJsonDocument(QJsonObject {{"delay", 300}, {"key1", QJsonObject {{"freq", 38000}, {"key_code", data.toString()}, {"num", 1}, {"type", 1}}}, {"key_num", 1}}).toJson(QJsonDocument::Compact);
quint32 length = qToLittleEndian <quint32> (message.length());
meta().insert("message", message);
length = qToLittleEndian(length);

return zclHeader(FC_CLUSTER_SPECIFIC, m_transactionId++, 0x00).append(2, 0x00).append(reinterpret_cast <char*> (&length), sizeof(length)).append(QByteArray::fromHex("0000000004e001020000"));
}

QByteArray ActionsTUYA::IRLearn::request(const QString &, const QVariant &data)
{
QJsonObject json = {{"study", 0}};
return !data.toBool() ? QByteArray() : zclHeader(FC_CLUSTER_SPECIFIC, m_transactionId++, 0x00).append(QJsonDocument(json).toJson(QJsonDocument::Compact));
return zclHeader(FC_CLUSTER_SPECIFIC, m_transactionId++, 0x00).append(QJsonDocument(QJsonObject {{"study", data.toBool() ? 0 : 1}}).toJson(QJsonDocument::Compact));
}
2 changes: 1 addition & 1 deletion actions/tuya.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ namespace ActionsTUYA

public:

IRLearn(void) : ActionObject("irLearn", CLUSTER_TUYA_IR_CONTROL, 0x0000) {}
IRLearn(void) : ActionObject("learn", CLUSTER_TUYA_IR_CONTROL, 0x0000) {}
QByteArray request(const QString &name, const QVariant &data) override;

};
Expand Down
5 changes: 5 additions & 0 deletions controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ void Controller::publishExposes(DeviceObject *device, bool remove)
void Controller::serviceOnline(void)
{
for (auto it = m_zigbee->devices()->begin(); it != m_zigbee->devices()->end(); it++)
{
if (it.value()->removed())
continue;

publishExposes(it.value().data());
}

if (m_haEnabled)
mqttPublishDiscovery("ZigBee", SERVICE_VERSION, m_haPrefix, true);
Expand Down
2 changes: 1 addition & 1 deletion controller.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CONTROLLER_H
#define CONTROLLER_H

#define SERVICE_VERSION "3.7.4-8"
#define SERVICE_VERSION "3.7.5"
#define UPDATE_AVAILABILITY_INTERVAL 5000
#define UPDATE_PROPERTIES_DELAY 1000

Expand Down
14 changes: 12 additions & 2 deletions deploy/data/usr/share/homed-zigbee/tuya.json
Original file line number Diff line number Diff line change
Expand Up @@ -1351,9 +1351,19 @@
},
{
"description": "TUYA TS1201 IR Remote Control",
"modelNames": ["_TZ3290_7v1k4vufotpowp9z", "_TZ3290_rlkmy85q4pzoxobl"],
"modelNames": ["_TZ3290_7v1k4vufotpowp9z", "_TZ3290_acv1iuslxi3shaaj", "_TZ3290_gnl5a6a5xvql7c2a", "_TZ3290_rlkmy85q4pzoxobl"],
"properties": ["tuyaIRCode"],
"actions": ["tuyaIRCode", "tuyaIRLearn"]
"actions": ["tuyaIRCode", "tuyaIRLearn"],
"exposes": ["irCode"]
},
{
"description": "TUYA TS1201 Wireless IR Remote Control",
"modelNames": ["_TZ3290_j37rooaxrcdcqo5n", "_TZ3290_ot6ewjvmejq5ekhl", "_TZ3290_xjpbcxn92aaxvmlz"],
"properties": ["batteryPercentage", "tuyaIRCode"],
"actions": ["tuyaIRCode", "tuyaIRLearn"],
"bindings": ["battery"],
"reportings": ["batteryPercentage"],
"exposes": ["irCode", "battery"]
},
{
"description": "MIBOXER FUT089Z 8-Group Remote Control",
Expand Down
3 changes: 1 addition & 2 deletions properties/tuya.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,7 @@ void PropertiesTUYA::IRCode::parseCommand(quint16, quint8 commandId, const QByte

case 0x05:
{
QJsonObject json = {{"study", 1}};
m_queue.enqueue({CLUSTER_TUYA_IR_CONTROL, zclHeader(FC_CLUSTER_SPECIFIC, m_transactionId, 0x00).append(QJsonDocument(json).toJson(QJsonDocument::Compact))});
m_queue.enqueue({CLUSTER_TUYA_IR_CONTROL, zclHeader(FC_CLUSTER_SPECIFIC, m_transactionId, 0x00).append(QJsonDocument(QJsonObject {{"study", 1}}).toJson(QJsonDocument::Compact))});
m_value = m_buffer.toBase64();
break;
}
Expand Down

0 comments on commit 945c1f6

Please sign in to comment.