Skip to content

Commit

Permalink
fix: Battery SOH when wrong corrected capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Aug 15, 2024
1 parent c6f2ab1 commit 369e2fb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/solarman/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ def update(self):
match self.sensor_name:
case "Battery SOH":
total_battery_charge = self.get_data("Total Battery Charge", None)
battery_capacity = self.get_data("Battery Corrected Capacity", None)
if battery_capacity <= 0:
battery_capacity = self.get_data("Battery Capacity", None)
battery_capacity = self.get_data("Battery Capacity", None)
battery_capacity_5 = battery_capacity / 100 * 5
battery_corrected_capacity = self.get_data("Battery Corrected Capacity", None)
if battery_capacity - battery_capacity_5 <= battery_corrected_capacity <= battery_capacity + battery_capacity_5:
battery_capacity = battery_corrected_capacity
if total_battery_charge and battery_capacity and self._battery_nominal_voltage and self._battery_life_cycle_rating:
self._attr_state = get_number(100 - total_battery_charge / get_battery_power_capacity(battery_capacity, self._battery_nominal_voltage) / (self._battery_life_cycle_rating * 0.05), self._digits)
case "Battery State":
Expand Down

0 comments on commit 369e2fb

Please sign in to comment.