f div 1000 type

This commit is contained in:
Tester23
2025-01-28 04:56:25 +01:00
parent 0b39365b54
commit 7495c70322
4 changed files with 22 additions and 2 deletions

View File

@ -2034,6 +2034,11 @@ void doHomeAssistantDiscovery(const char* topic, http_request_t* request) {
dev_info = hass_init_sensor_device_info(FREQUENCY_SENSOR, i, 3, 2, 1);
}
break;
case ChType_Frequency_div1000:
{
dev_info = hass_init_sensor_device_info(FREQUENCY_SENSOR, i, 4, 3, 1);
}
break;
case ChType_Frequency_div10:
{
dev_info = hass_init_sensor_device_info(FREQUENCY_SENSOR, i, 3, 1, 1);

View File

@ -1171,6 +1171,7 @@ int ChannelType_GetDivider(int type) {
case ChType_Current_div1000:
case ChType_LeakageCurrent_div1000:
case ChType_ReadOnly_div1000:
case ChType_Frequency_div1000:
return 1000;
case ChType_Temperature_div2:
return 2;
@ -1198,6 +1199,7 @@ const char *ChannelType_GetUnit(int type) {
return "W";
case ChType_Frequency_div10:
case ChType_Frequency_div100:
case ChType_Frequency_div1000:
return "Hz";
case ChType_LeakageCurrent_div1000:
case ChType_Current_div1000:
@ -1248,6 +1250,7 @@ const char *ChannelType_GetTitle(int type) {
return "Power";
case ChType_Frequency_div10:
case ChType_Frequency_div100:
case ChType_Frequency_div1000:
return "Frequency";
case ChType_Current_div1000:
case ChType_Current_div100:
@ -2128,6 +2131,7 @@ const char* g_channelTypeNames[] = {
"Orp",
"Tds",
"Motion_n",
"Frequency_div1000",
"error",
"error",
};

View File

@ -980,6 +980,13 @@ typedef enum channelType_e {
//chandetail:"file":"new_pins.h",
//chandetail:"driver":""}
ChType_Motion_n,
//chandetail:{"name":"Frequency_div1000",
//chandetail:"title":"TODO",
//chandetail:"descr":"For TuyaMCU power metering. Not used for BL09** and CSE** sensors. Divider is used by TuyaMCU, because TuyaMCU sends always values as integers so we have to divide them before displaying on UI",
//chandetail:"enum":"ChType_Frequency_div1000",
//chandetail:"file":"new_pins.h",
//chandetail:"driver":""}
ChType_Frequency_div1000,
//chandetail:{"name":"Max",
//chandetail:"title":"TODO",
//chandetail:"descr":"This is the current total number of available channel types.",

View File

@ -625,13 +625,17 @@ void Test_TuyaMCU_Basic() {
SELFTEST_ASSERT_CHANNEL(7, 302);// current
SELFTEST_ASSERT_CHANNEL(9, 67); // power
CMD_ExecuteCommand("linkTuyaMCUOutputToChannel 115 RAW_VCPPfF", 0);
CMD_ExecuteCommand("uartFakeHex 55 AA 03 07 00 13 73 00 00 0F 09 0F 00 00 BF 00 00 78 00 00 25 01 10 C3 32 18 ", 0);
// above command will just put into buffer - need at least a frame to parse it
Sim_RunFrames(100, false);
CMD_ExecuteCommand("linkTuyaMCUOutputToChannel 113 RAW_VCPPfF", 0);
CMD_ExecuteCommand("uartFakeHex 55 AA 03 07 00 13 71 00 00 0F 09 29 00 01 B7 00 03 FC 00 00 00 03 E8 C3 32 65", 0);
// above command will just put into buffer - need at least a frame to parse it
Sim_RunFrames(100, false);
SIM_ClearUART();
}