From 56d7d05a033e037453a11fc3787bf0784a4df205 Mon Sep 17 00:00:00 2001 From: WillCodeForCats <48533968+WillCodeForCats@users.noreply.github.com> Date: Tue, 1 Aug 2023 06:51:54 -0700 Subject: [PATCH 1/5] Missing f string --- custom_components/solaredge_modbus_multi/hub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/solaredge_modbus_multi/hub.py b/custom_components/solaredge_modbus_multi/hub.py index b11a60ec..82a66838 100644 --- a/custom_components/solaredge_modbus_multi/hub.py +++ b/custom_components/solaredge_modbus_multi/hub.py @@ -1525,7 +1525,7 @@ async def init_device(self) -> None: or len(self.decoded_common["B_Model"]) == 0 or len(self.decoded_common["B_SerialNumber"]) == 0 ): - raise DeviceInvalid("Battery {self.battery_id} not usable.") + raise DeviceInvalid(f"Battery {self.battery_id} not usable.") self.manufacturer = self.decoded_common["B_Manufacturer"] self.model = self.decoded_common["B_Model"] From 73dda3286d1a2f4c9d5a816024d6c2b85d712fa0 Mon Sep 17 00:00:00 2001 From: WillCodeForCats <48533968+WillCodeForCats@users.noreply.github.com> Date: Tue, 1 Aug 2023 07:00:01 -0700 Subject: [PATCH 2/5] Change device check to 'and' --- custom_components/solaredge_modbus_multi/hub.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/solaredge_modbus_multi/hub.py b/custom_components/solaredge_modbus_multi/hub.py index b11a60ec..30882f4a 100644 --- a/custom_components/solaredge_modbus_multi/hub.py +++ b/custom_components/solaredge_modbus_multi/hub.py @@ -1522,8 +1522,8 @@ async def init_device(self) -> None: if ( len(self.decoded_common["B_Manufacturer"]) == 0 - or len(self.decoded_common["B_Model"]) == 0 - or len(self.decoded_common["B_SerialNumber"]) == 0 + and len(self.decoded_common["B_Model"]) == 0 + and len(self.decoded_common["B_SerialNumber"]) == 0 ): raise DeviceInvalid("Battery {self.battery_id} not usable.") From 70ce9bd15d13e0eed83bcbee06911555b81fbe0b Mon Sep 17 00:00:00 2001 From: WillCodeForCats <48533968+WillCodeForCats@users.noreply.github.com> Date: Tue, 1 Aug 2023 07:14:10 -0700 Subject: [PATCH 3/5] Bump version for pre-release --- custom_components/solaredge_modbus_multi/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/solaredge_modbus_multi/manifest.json b/custom_components/solaredge_modbus_multi/manifest.json index 101a16f3..3a5d3bc3 100644 --- a/custom_components/solaredge_modbus_multi/manifest.json +++ b/custom_components/solaredge_modbus_multi/manifest.json @@ -10,5 +10,5 @@ "issue_tracker": "https://github.com/WillCodeForCats/solaredge-modbus-multi/issues", "loggers": ["custom_components.solaredge_modbus_multi"], "requirements": ["pymodbus>=3.3.1"], - "version": "2.4.0-pre.7" + "version": "2.4.0-pre.8" } From 28a614f3bba2a7da3f64540e65e9d2db8f3549a8 Mon Sep 17 00:00:00 2001 From: WillCodeForCats <48533968+WillCodeForCats@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:53:58 -0700 Subject: [PATCH 4/5] Device topology for meters and batteries --- .../solaredge_modbus_multi/hub.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/custom_components/solaredge_modbus_multi/hub.py b/custom_components/solaredge_modbus_multi/hub.py index 0948e8f5..fac8a298 100644 --- a/custom_components/solaredge_modbus_multi/hub.py +++ b/custom_components/solaredge_modbus_multi/hub.py @@ -224,6 +224,7 @@ async def _async_init_solaredge(self) -> None: f"Duplicate m1 serial {new_meter_1.serial}" ) + new_meter_1.via_device = new_inverter.uid_base self.meters.append(new_meter_1) _LOGGER.debug(f"Found meter 1 on inverter ID {inverter_unit_id}") @@ -251,6 +252,7 @@ async def _async_init_solaredge(self) -> None: f"Duplicate m2 serial {new_meter_2.serial}" ) + new_meter_2.via_device = new_inverter.uid_base self.meters.append(new_meter_2) _LOGGER.debug(f"Found meter 2 on inverter ID {inverter_unit_id}") @@ -278,6 +280,7 @@ async def _async_init_solaredge(self) -> None: f"Duplicate m3 serial {new_meter_3.serial}" ) + new_meter_3.via_device = new_inverter.uid_base self.meters.append(new_meter_3) _LOGGER.debug(f"Found meter 3 on inverter ID {inverter_unit_id}") @@ -306,6 +309,7 @@ async def _async_init_solaredge(self) -> None: f"Duplicate b1 serial {new_battery_1.serial}" ) + new_battery_1.via_device = new_inverter.uid_base self.batteries.append(new_battery_1) _LOGGER.debug(f"Found battery 1 inverter {inverter_unit_id}") @@ -333,6 +337,7 @@ async def _async_init_solaredge(self) -> None: f"Duplicate b2 serial {new_battery_2.serial}" ) + new_battery_2.via_device = new_inverter.uid_base self.batteries.append(new_battery_2) _LOGGER.debug(f"Found battery 2 inverter {inverter_unit_id}") @@ -1187,7 +1192,7 @@ def online(self) -> bool: def device_info(self) -> DeviceInfo: """Return the device info.""" return DeviceInfo( - identifiers={(DOMAIN, f"{self.model}_{self.serial}")}, + identifiers={(DOMAIN, self.uid_base)}, name=self.name, manufacturer=self.manufacturer, model=self.model, @@ -1216,6 +1221,7 @@ def __init__( self.has_parent = True self.inverter_common = self.hub.inverter_common[self.inverter_unit_id] self.mmppt_common = self.hub.mmppt_common[self.inverter_unit_id] + self._via_device = None if self.meter_id == 1: self.start_address = self.start_address + 121 @@ -1434,8 +1440,17 @@ def device_info(self) -> DeviceInfo: model=self.model, sw_version=self.fw_version, hw_version=self.option, + via_device=self.via_device, ) + @property + def via_device(self) -> tuple[str, str]: + return self._via_device + + @via_device.setter + def via_device(self, device: str) -> None: + self._via_device = (DOMAIN, device) + class SolarEdgeBattery: def __init__( @@ -1449,6 +1464,7 @@ def __init__( self.battery_id = battery_id self.has_parent = True self.inverter_common = self.hub.inverter_common[self.inverter_unit_id] + self._via_device = None if self.battery_id == 1: self.start_address = 57600 @@ -1623,8 +1639,17 @@ def device_info(self) -> DeviceInfo: manufacturer=self.manufacturer, model=self.model, sw_version=self.fw_version, + via_device=self.via_device, ) + @property + def via_device(self) -> tuple[str, str]: + return self._via_device + + @via_device.setter + def via_device(self, device: str) -> None: + self._via_device = (DOMAIN, device) + @property def allow_battery_energy_reset(self) -> bool: return self.hub.allow_battery_energy_reset From 3fe9b58794c101f72346c0cddcde67cef38a3472 Mon Sep 17 00:00:00 2001 From: WillCodeForCats <48533968+WillCodeForCats@users.noreply.github.com> Date: Wed, 2 Aug 2023 07:04:45 -0700 Subject: [PATCH 5/5] Bump version for release. --- custom_components/solaredge_modbus_multi/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/solaredge_modbus_multi/manifest.json b/custom_components/solaredge_modbus_multi/manifest.json index 3a5d3bc3..d8b4256b 100644 --- a/custom_components/solaredge_modbus_multi/manifest.json +++ b/custom_components/solaredge_modbus_multi/manifest.json @@ -10,5 +10,5 @@ "issue_tracker": "https://github.com/WillCodeForCats/solaredge-modbus-multi/issues", "loggers": ["custom_components.solaredge_modbus_multi"], "requirements": ["pymodbus>=3.3.1"], - "version": "2.4.0-pre.8" + "version": "2.4.0" }