diff --git a/src/driver/drv_tuyaMCU.c b/src/driver/drv_tuyaMCU.c index 47c61bbf0..999831b0d 100644 --- a/src/driver/drv_tuyaMCU.c +++ b/src/driver/drv_tuyaMCU.c @@ -323,7 +323,7 @@ tuyaMCUMapping_t* TuyaMCU_FindDefForChannel(int channel) { return 0; } -void TuyaMCU_MapIDToChannel(int dpId, int dpType, int channel, int bDPCache, float mul) { +tuyaMCUMapping_t* TuyaMCU_MapIDToChannel(int dpId, int dpType, int channel, int bDPCache, float mul) { tuyaMCUMapping_t* cur; cur = TuyaMCU_FindDefForID(dpId); @@ -343,6 +343,7 @@ void TuyaMCU_MapIDToChannel(int dpId, int dpType, int channel, int bDPCache, flo } cur->channel = channel; + return cur; } @@ -1091,6 +1092,9 @@ void TuyaMCU_ApplyMapping(tuyaMCUMapping_t* mapping, int fnID, int value) { addLogAdv(LOG_DEBUG, LOG_FEATURE_TUYAMCU, "ApplyMapping: id %i (val %i) not mapped\n", fnID, value); return; } + if (mapping->channel == -1) { + return; + } // map value depending on channel type switch (CHANNEL_GetType(mapping->channel)) @@ -1505,6 +1509,11 @@ void TuyaMCU_ParseStateMessage(const byte* data, int len) { } if (CFG_HasFlag(OBK_FLAG_TUYAMCU_STORE_RAW_DATA)) { + if (CFG_HasFlag(OBK_FLAG_TUYAMCU_STORE_ALL_DATA)) { + if (mapping == 0) { + mapping = TuyaMCU_MapIDToChannel(dpId, dataType, -1, 0, 1.0f); + } + } if (mapping) { // add space for NULL terminating character int useLen = sectorLen + 1; diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 2fbcbdef6..f09bcbd69 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -2608,6 +2608,7 @@ const char* g_obk_flagNames[] = { "[HTTP] Disable authentication in safe mode (not recommended)", "[MQTT Discovery] Don't merge toggles and dimmers into lights", "[TuyaMCU] Store raw data", + "[TuyaMCU] Store ALL data", "error", "error", }; diff --git a/src/new_pins.h b/src/new_pins.h index 7bc1827ed..3c608ff2d 100644 --- a/src/new_pins.h +++ b/src/new_pins.h @@ -1046,8 +1046,9 @@ typedef struct pinsState_s { #define OBK_FLAG_HTTP_DISABLE_AUTH_IN_SAFE_MODE 44 #define OBK_FLAG_DISCOVERY_DONT_MERGE_LIGHTS 45 #define OBK_FLAG_TUYAMCU_STORE_RAW_DATA 46 +#define OBK_FLAG_TUYAMCU_STORE_ALL_DATA 47 -#define OBK_TOTAL_FLAGS 47 +#define OBK_TOTAL_FLAGS 48 #define LOGGER_FLAG_MQTT_DEDUPER 1 #define LOGGER_FLAG_POWER_SAVE 2