mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 21:18:13 +08:00
优化HA功率
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "mico.h"
|
||||
#include "MQTTClient.h"
|
||||
#include "user_gpio.h"
|
||||
#include "user_power.h"
|
||||
#include "user_mqtt_client.h"
|
||||
|
||||
typedef struct
|
||||
@@ -507,7 +508,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)(real_time_power/10), (int)(real_time_power%10));
|
||||
sprintf(send_buf, "{\"power\":\"%.3f\"}", real_time_power);
|
||||
UserMqttSendTopic(topic_buf, send_buf, 0);
|
||||
}
|
||||
if (send_buf) free(send_buf);
|
||||
|
||||
Reference in New Issue
Block a user