Skip to content

Commit 87199f6

Browse files
Clean up manufacturer and model presentation
*LG battery returns control characters in manufacturer *LG battery appends its own serial number to manufacturer and model
1 parent e14e061 commit 87199f6

File tree

1 file changed

+7
-2
lines changed
  • custom_components/solaredge_modbus_multi

1 file changed

+7
-2
lines changed

custom_components/solaredge_modbus_multi/hub.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,14 +719,20 @@ def __init__(self, device_id: int, battery_id: int, hub: SolarEdgeModbusMultiHub
719719

720720
for name, value in iteritems(self.decoded_common):
721721
_LOGGER.debug(f"Inverter {self.inverter_unit_id} battery {self.battery_id}: {name} {hex(value) if isinstance(value, int) else value}")
722+
723+
self.decoded_common['B_Manufacturer'] = self.decoded_common['B_Manufacturer'].removesuffix(self.decoded_common['B_SerialNumber'])
724+
self.decoded_common['B_Model'] = self.decoded_common['B_Model'].removesuffix(self.decoded_common['B_SerialNumber'])
722725

726+
ascii_ctrl_chars = dict.fromkeys(range(32))
727+
self.decoded_common['B_Manufacturer'] = self.decoded_common['B_Manufacturer'].translate(ascii_ctrl_chars)
728+
723729
if (
724730
len(self.decoded_common['B_Manufacturer']) == 0
725731
or len(self.decoded_common['B_Model']) == 0
726732
or len(self.decoded_common['B_SerialNumber']) == 0
727733
):
728734
raise RuntimeError("Battery {self.battery_id} not usable.")
729-
735+
730736
self.manufacturer = self.decoded_common['B_Manufacturer']
731737
self.model = self.decoded_common['B_Model']
732738
self.option = ''
@@ -741,7 +747,6 @@ def __init__(self, device_id: int, battery_id: int, hub: SolarEdgeModbusMultiHub
741747
"manufacturer": self.manufacturer,
742748
"model": self.model,
743749
"sw_version": self.fw_version,
744-
"hw_version": self.option,
745750
}
746751

747752
def register_callback(self, callback: Callable[[], None]) -> None:

0 commit comments

Comments
 (0)