mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 21:18:13 +08:00
mqtt real_time_power
This commit is contained in:
@@ -99,11 +99,11 @@ void UserFunctionCmdReceived(int udp_flag, char* pusrdata)
|
||||
char *temp_buf = malloc(16);
|
||||
if (temp_buf != NULL)
|
||||
{
|
||||
sprintf(temp_buf, "%d.%d", (int)(power/10), (int)(power%10));
|
||||
sprintf(temp_buf, "%d.%d", (int)(real_time_power/10), (int)(real_time_power%10));
|
||||
cJSON_AddStringToObject(json_send, "power", temp_buf);
|
||||
free(temp_buf);
|
||||
}
|
||||
os_log("power:%d", (int)power);
|
||||
os_log("power:%d", (int)real_time_power);
|
||||
}
|
||||
//解析主机setting-----------------------------------------------------------------
|
||||
cJSON *p_setting = cJSON_GetObjectItem(pJsonRoot, "setting");
|
||||
|
||||
@@ -621,7 +621,7 @@ void UserMqttHassPower(void)
|
||||
if (send_buf != NULL && topic_buf != NULL)
|
||||
{
|
||||
sprintf(topic_buf, "homeassistant/sensor/%s/power/state", str_mac);
|
||||
sprintf(send_buf, "{\"power\":\"%d.%d\"}", (int)(power/10), (int)(power%10));
|
||||
sprintf(send_buf, "{\"power\":\"%d.%d\"}", (int)(real_time_power/10), (int)(real_time_power%10));
|
||||
UserMqttSendTopic(topic_buf, send_buf, 0);
|
||||
}
|
||||
if (send_buf) free(send_buf);
|
||||
|
||||
Reference in New Issue
Block a user