mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 11:16: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
|
||||
}
|
||||
|
||||
void CmndBatteryPercent(void) {
|
||||
if (XdrvMailbox.payload > 101) XdrvMailbox.payload = 100;
|
||||
if (XdrvMailbox.payload >= 0) {
|
||||
Settings->battery_level_percent = XdrvMailbox.payload;
|
||||
void UpdateBatteryPercent(int batt_percentage) {
|
||||
if (batt_percentage > 101) { batt_percentage = 100; }
|
||||
if (batt_percentage >= 0) {
|
||||
Settings->battery_level_percent = batt_percentage;
|
||||
}
|
||||
}
|
||||
|
||||
void CmndBatteryPercent(void) {
|
||||
UpdateBatteryPercent(XdrvMailbox.payload);
|
||||
ResponseCmndNumber(Settings->battery_level_percent);
|
||||
}
|
||||
|
||||
|
@ -108,9 +108,7 @@ void Max17043Show(bool json) {
|
||||
// only update the system percentage if it's changed
|
||||
battery_current = int(round(percentage));
|
||||
if (battery_latest != battery_current) {
|
||||
char cmnd[30];
|
||||
sprintf(cmnd, "%s %d", D_CMND_ZIGBEE_BATTPERCENT, battery_current);
|
||||
ExecuteCommand(cmnd, SRC_SENSOR);
|
||||
UpdateBatteryPercent(battery_current);
|
||||
battery_latest = battery_current;
|
||||
}
|
||||
if (json) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user