diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index 9fb41fa3e..674440696 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -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); } diff --git a/tasmota/tasmota_xsns_sensor/xsns_110_max17043.ino b/tasmota/tasmota_xsns_sensor/xsns_110_max17043.ino index 3e9a64a74..542f27642 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_110_max17043.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_110_max17043.ino @@ -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) {