Skip to content

Commit

Permalink
feat: Estimates Battery Capacity over last X states, default: 1000
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Jan 21, 2025
1 parent 78f9b85 commit c1e893c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions custom_components/solarman/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def __init__(self, coordinator, sensor):
super().__init__(coordinator, sensor)
self._digits = sensor.get(DIGITS, DEFAULT_[DIGITS])
self._threshold = sensor.get("threshold", 200)
self._nstates = sensor.get("states", 1000)
self._states = []
self._temp = []

Expand Down Expand Up @@ -148,6 +149,8 @@ def update(self):
l = s
if h[1] > m[1] > l[1] > s[1] and (diff := abs(h[0] - l[0])) > 0 and (state := get_number((h[1] - l[1]) * (100 / diff), self._digits)):
self._states.append(state)
while len(self._states) > self._nstates:
self._states.pop(0)
self._attr_extra_state_attributes["states"] = self._states
self._temp = [(power, soc, tb)]
if (srtd := sorted(self._states)):
Expand Down

0 comments on commit c1e893c

Please sign in to comment.