From b3a074d4c340f6473bfd1db2fcfb8c0c6d3aa23a Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 14 Mar 2025 21:35:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E8=80=97=E7=94=B5?= =?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1=E7=9A=84=E9=94=99=E8=AF=AF=EF=BC=8C?= =?UTF-8?q?mqtt=E4=B8=AD=E5=A2=9E=E5=8A=A0=E4=BA=86TC1=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=EF=BC=8C=E4=BC=A0=E6=84=9F=E5=99=A8=E5=92=8C=E5=BC=80=E5=85=B3?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E5=BD=92=E5=B1=9E=E5=9C=A8=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TC1/http_server/web_data.c | 6 +++--- TC1/main.c | 9 ++++++--- TC1/mqtt_server/user_mqtt_client.c | 24 +++++++++++------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/TC1/http_server/web_data.c b/TC1/http_server/web_data.c index 98910a4..803a530 100644 --- a/TC1/http_server/web_data.c +++ b/TC1/http_server/web_data.c @@ -1,5 +1,5 @@ const unsigned char js_pack[0xd2be] = { -0x1f,0x8b,0x08,0x00,0xa0,0x55,0xd0,0x67,0x02,0xff,0xd4,0xbd,0xfb,0x72,0xdb,0x46, +0x1f,0x8b,0x08,0x00,0xa5,0x26,0xd3,0x67,0x02,0xff,0xd4,0xbd,0xfb,0x72,0xdb,0x46, 0xd2,0x38,0xfa,0xff,0x56,0xed,0x3b,0x88,0x48,0x96,0x01,0xc4,0x21,0x45,0xca,0xb1, 0x13,0x83,0x1e,0xb1,0x1c,0xdb,0x49,0xbc,0x5f,0x9c,0x64,0xe3,0x5c,0x97,0x62,0x52, 0xb8,0x92,0xa0,0x48,0x82,0xe2,0xc5,0x12,0x23,0x72,0xdf,0xe7,0xf7,0x1a,0xe7,0xc9, @@ -3372,7 +3372,7 @@ const unsigned char js_pack[0xd2be] = { 0x02,0x0f,0xb7,0x98,0x0c,0x59,0x7f,0x97,0xf2,0x25,0x55,0x7c,0x45,0xad,0x25,0x8e, 0x0f,0x58,0x4f,0xcc,0x9f,0x00,0x32,0xd2,0xf4,0xa5,0xf0,0xee,0x02,0x00}; const unsigned char css_pack[0x6217] = { -0x1f,0x8b,0x08,0x00,0xa0,0x55,0xd0,0x67,0x02,0xff,0xed,0xbd,0x79,0x73,0xdb,0xc8, +0x1f,0x8b,0x08,0x00,0xa5,0x26,0xd3,0x67,0x02,0xff,0xed,0xbd,0x79,0x73,0xdb,0xc8, 0xf5,0x28,0xfa,0x7f,0xaa,0xf2,0x1d,0x70,0x9d,0x9a,0x1a,0x6b,0x42,0xc8,0xd8,0x49, 0x4a,0x95,0x54,0xbc,0x8f,0x26,0x96,0x9c,0x78,0x19,0x8f,0x9d,0x5f,0x9e,0x0b,0x04, 0x9a,0x24,0x24,0x90,0x60,0x00,0x50,0x1b,0x4b,0xb7,0xee,0x07,0xb9,0xef,0xcb,0xbd, @@ -4943,7 +4943,7 @@ const unsigned char css_pack[0x6217] = { 0xe6,0x54,0x09,0x49,0xbc,0xd0,0xc2,0x1c,0x55,0x23,0x76,0x55,0x21,0xff,0x3f,0x3f, 0xef,0x85,0xce,0x3d,0xbc,0x02,0x00}; const unsigned char web_index_html[0x2c41] = { -0x1f,0x8b,0x08,0x00,0xa0,0x55,0xd0,0x67,0x02,0xff,0xed,0x7d,0x6b,0x73,0xdc,0xc6, +0x1f,0x8b,0x08,0x00,0xa5,0x26,0xd3,0x67,0x02,0xff,0xed,0x7d,0x6b,0x73,0xdc,0xc6, 0x95,0xe8,0xf7,0x5b,0xb5,0xff,0xa1,0x0d,0xa7,0x96,0xc3,0xe5,0x00,0x83,0xc7,0x00, 0x33,0x43,0x91,0xdc,0xd2,0xd2,0x4a,0xe4,0x0d,0x15,0x39,0xa6,0xae,0x7c,0x77,0x1d, 0xd7,0x14,0x38,0x83,0xe1,0xc0,0xc2,0x0c,0xc6,0x00,0x86,0x14,0x95,0xa8,0xca,0xca, diff --git a/TC1/main.c b/TC1/main.c index 6727297..c70449c 100644 --- a/TC1/main.c +++ b/TC1/main.c @@ -55,11 +55,14 @@ void appRestoreDefault_callback(void *const user_config_data, uint32_t size) { } void recordDailyPCount() { - tc1_log("WARNGIN: enter recordDailyPCount! "); + // 获取当前时间 - time_t now; - time(&now); + time_t now = time(NULL) + 28800; //东8区 + struct tm *current_time = localtime(&now); + + tc1_log("WARNGIN: enter recordDailyPCount! now day %d hour %d min %d",current_time->tm_mday,current_time->tm_hour,current_time->tm_min); + // 判断上次检查的时间与当前时间的日期是否不同 if (last_check_day != 0) { tc1_log( "WARNGIN: last_check_time day %d ,current_time day %d", last_check_day, diff --git a/TC1/mqtt_server/user_mqtt_client.c b/TC1/mqtt_server/user_mqtt_client.c index a1f5487..7ec3c1e 100644 --- a/TC1/mqtt_server/user_mqtt_client.c +++ b/TC1/mqtt_server/user_mqtt_client.c @@ -497,7 +497,7 @@ void UserMqttHassAuto(char socket_id) socket_id--; char *send_buf = NULL; char *topic_buf = NULL; - send_buf = (char *) malloc(300); + send_buf = (char *) malloc(1024); topic_buf = (char *) malloc(64); if (send_buf != NULL && topic_buf != NULL) { @@ -514,7 +514,7 @@ void UserMqttHassAuto(char socket_id) "\"name\":\"TC1_%s\"," "\"model\":\"TC1\"," "\"manufacturer\":\"PHICOMM\"}}", - str_mac+8, socket_id+1, str_mac, socket_id, str_mac, socket_id, str_mac, socket_id, str_mac, socket_id, str_mac, str_mac+8, str_mac, str_mac); + str_mac+8, socket_id+1, str_mac, socket_id, str_mac, socket_id, str_mac, socket_id, str_mac, socket_id, str_mac, str_mac); UserMqttSendTopic(topic_buf, send_buf, 1); } if (send_buf) @@ -527,20 +527,18 @@ void UserMqttHassAutoLed(void) { char *send_buf = NULL; char *topic_buf = NULL; - send_buf = (char *) malloc(300); + send_buf = (char *) malloc(1024); topic_buf = (char *) malloc(64); if (send_buf != NULL && topic_buf != NULL) { sprintf(topic_buf, "homeassistant/switch/%s/led/config", str_mac); - sprintf(send_buf, "set led %s %d", str_mac, (int)user_config->power_led_enabled); - - sprintf(send_buf, + sprintf(send_buf, "{\"name\":\"TC1_%s_Led\"," "\"uniq_id\":\"%s_led\"," "\"stat_t\":\"homeassistant/switch/%s/led/state\"," "\"cmd_t\":\"device/ztc1/set\"," "\"pl_on\":\"set led %s 1\"," - "\"pl_off\":\"set led %s 0\", + "\"pl_off\":\"set led %s 0\"," "\"device\":{" "\"identifiers\":[\"tc1_%s\"]," "\"name\":\"TC1_%s\"," @@ -559,7 +557,7 @@ void UserMqttHassAutoPower(void) { char *send_buf = NULL; char *topic_buf = NULL; - send_buf = malloc(512); + send_buf = malloc(1024); topic_buf = malloc(128); if (send_buf != NULL && topic_buf != NULL) { @@ -570,7 +568,7 @@ void UserMqttHassAutoPower(void) "\"state_topic\":\"homeassistant/sensor/%s/power/state\"," "\"unit_of_measurement\":\"W\"," "\"icon\":\"mdi:gauge\"," - "\"value_template\":\"{{ value_json.power }}\","\"device\":{" + "\"value_template\":\"{{ value_json.power }}\",""\"device\":{" "\"identifiers\":[\"tc1_%s\"]," "\"name\":\"TC1_%s\"," "\"model\":\"TC1\"," @@ -584,7 +582,7 @@ void UserMqttHassAutoPower(void) "\"state_topic\":\"homeassistant/sensor/%s/powerConsumption/state\"," "\"unit_of_measurement\":\"kWh\"," "\"icon\":\"mdi:fence-electric\"," - "\"value_template\":\"{{ value_json.powerConsumption }}\","\"device\":{" + "\"value_template\":\"{{ value_json.powerConsumption }}\",""\"device\":{" "\"identifiers\":[\"tc1_%s\"]," "\"name\":\"TC1_%s\"," "\"model\":\"TC1\"," @@ -599,11 +597,11 @@ void UserMqttHassAutoPower(void) "\"state_topic\":\"homeassistant/sensor/%s/powerConsumptionToday/state\"," "\"unit_of_measurement\":\"kWh\"," "\"icon\":\"mdi:fence-electric\"," - "\"value_template\":\"{{ value_json.powerConsumptionToday }}\","\"device\":{" + "\"value_template\":\"{{ value_json.powerConsumptionToday }}\",""\"device\":{" "\"identifiers\":[\"tc1_%s\"]," "\"name\":\"TC1_%s\"," "\"model\":\"TC1\"," - "\"manufacturer\":\"PHICOMM\"}", + "\"manufacturer\":\"PHICOMM\"}}", str_mac+8, str_mac, str_mac, str_mac, str_mac); UserMqttSendTopic(topic_buf, send_buf, 1); @@ -614,7 +612,7 @@ void UserMqttHassAutoPower(void) "\"state_topic\":\"homeassistant/sensor/%s/powerConsumptionYesterday/state\"," "\"unit_of_measurement\":\"kWh\"," "\"icon\":\"mdi:fence-electric\"," - "\"value_template\":\"{{ value_json.powerConsumptionYesterday }}\","\"device\":{" + "\"value_template\":\"{{ value_json.powerConsumptionYesterday }}\",""\"device\":{" "\"identifiers\":[\"tc1_%s\"]," "\"name\":\"TC1_%s\"," "\"model\":\"TC1\","