优化HA功率

This commit is contained in:
zogodo
2020-02-18 09:51:04 +08:00
parent 22dc3bc1df
commit 73a60d3e04
9 changed files with 18 additions and 35 deletions

View File

@@ -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);