mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Fix MAX17043 invalid JSON (#19495)
This commit is contained in:
parent
728b1b2d36
commit
597c3655b0
@ -249,11 +249,15 @@ void CmndWifiTest(void)
|
|||||||
#endif //USE_WEBSERVER
|
#endif //USE_WEBSERVER
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmndBatteryPercent(void) {
|
void UpdateBatteryPercent(int batt_percentage) {
|
||||||
if (XdrvMailbox.payload > 101) XdrvMailbox.payload = 100;
|
if (batt_percentage > 101) { batt_percentage = 100; }
|
||||||
if (XdrvMailbox.payload >= 0) {
|
if (batt_percentage >= 0) {
|
||||||
Settings->battery_level_percent = XdrvMailbox.payload;
|
Settings->battery_level_percent = batt_percentage;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CmndBatteryPercent(void) {
|
||||||
|
UpdateBatteryPercent(XdrvMailbox.payload);
|
||||||
ResponseCmndNumber(Settings->battery_level_percent);
|
ResponseCmndNumber(Settings->battery_level_percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,9 +108,7 @@ void Max17043Show(bool json) {
|
|||||||
// only update the system percentage if it's changed
|
// only update the system percentage if it's changed
|
||||||
battery_current = int(round(percentage));
|
battery_current = int(round(percentage));
|
||||||
if (battery_latest != battery_current) {
|
if (battery_latest != battery_current) {
|
||||||
char cmnd[30];
|
UpdateBatteryPercent(battery_current);
|
||||||
sprintf(cmnd, "%s %d", D_CMND_ZIGBEE_BATTPERCENT, battery_current);
|
|
||||||
ExecuteCommand(cmnd, SRC_SENSOR);
|
|
||||||
battery_latest = battery_current;
|
battery_latest = battery_current;
|
||||||
}
|
}
|
||||||
if (json) {
|
if (json) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user