Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions custom_components/solar_manager/plugins/JkBMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,15 @@ async def handle_notify(self, topic: str, payload: bytes) -> None:
if name in self._entities:
changed_entities.add(name)

# Make power negative when current is negative (discharging)
if self._data_dict.get("total_current", 0) < 0:
self._data_dict["total_power"] = -abs(self._data_dict.get("total_power", 0))
# Sign power based on current direction
if "total_power" in self._data_dict:
power = abs(self._data_dict["total_power"])
if self._data_dict.get("total_current", 0) < 0:
power = -power
if self._data_dict["total_power"] != power:
self._data_dict["total_power"] = power
if "total_power" in self._entities:
changed_entities.add("total_power")

for name in changed_entities:
entity = self._entities.get(name)
Expand Down
Loading