Add SetOption137 to avoid mqtt-publish of Tuya MCU heartbeat responses.

This commit is contained in:
Benny Nestler 2022-03-30 11:21:20 +02:00
parent 685642eff4
commit 6ac7c46b41
2 changed files with 14 additions and 2 deletions

View File

@ -166,7 +166,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t pwm_force_same_phase : 1; // bit 20 (v10.1.0.6) - SetOption134 - (PWM) force PWM lights to start at same phase, default is to spread phases to minimze overlap (also needed for H-bridge)
uint32_t display_no_splash : 1; // bit 21 (v11.0.0.2) - SetOption135 - (Display & LVGL) forece disbabling default splash screen
uint32_t tuyasns_no_immediate : 1; // bit 22 (v11.0.0.4) - SetOption136 - (TuyaSNS) When ON disable publish single SNS value on Tuya Receive (keep Teleperiod)
uint32_t spare23 : 1; // bit 23
uint32_t tuya_exclude_heartbeat : 1; // bit 23 (v11.0.0.5) - SetOption137 - (Tuya) When Set, avoid the (mqtt-) publish of Tuya MCU Heartbeat response if SetOption66 is active
uint32_t spare24 : 1; // bit 24
uint32_t spare25 : 1; // bit 25
uint32_t spare26 : 1; // bit 26

View File

@ -1203,6 +1203,7 @@ void TuyaSerialInput(void)
uint8_t dpId = 0;
uint8_t dpDataType = 0;
char DataStr[15];
bool isHeartbeat = false;
if (len > 0) {
ResponseAppend_P(PSTR(",\"CmndData\":\"%s\""), ToHex_P((unsigned char*)&Tuya.buffer[6], len, hex_char, sizeof(hex_char)));
@ -1246,11 +1247,22 @@ void TuyaSerialInput(void)
dpidStart += dpDataLen + 4;
}
}
else if (TUYA_CMD_HEARTBEAT == Tuya.buffer[3]) {
isHeartbeat = true;
}
}
ResponseAppend_P(PSTR("}}"));
if (Settings->flag3.tuya_serial_mqtt_publish) { // SetOption66 - Enable TuyaMcuReceived messages over Mqtt
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED));
if (Settings->flag5.tuya_exclude_heartbeat) { // SetOption137 - (Tuya) When Set, avoid the (mqtt-) publish of Tuya MCU Heartbeat response if SetOption66 is active
if (false == isHeartbeat) {
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED));
}
}
else {
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED));
}
} else {
AddLog(LOG_LEVEL_DEBUG, ResponseData());
}