Skip to content

Commit

Permalink
f div 1000 type
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Jan 28, 2025
1 parent 0b39365 commit 7495c70
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/httpserver/http_fns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/new_pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -2128,6 +2131,7 @@ const char* g_channelTypeNames[] = {
"Orp",
"Tds",
"Motion_n",
"Frequency_div1000",
"error",
"error",
};
Expand Down
7 changes: 7 additions & 0 deletions src/new_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
8 changes: 6 additions & 2 deletions src/selftest/selftest_tuyaMCU.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 7495c70

Please sign in to comment.