Skip to content

Commit

Permalink
remove unnecessary close and delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Lutz Bender committed Feb 27, 2024
1 parent 3c19385 commit 69ff45c
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions packages/modules/devices/solaredge/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,30 @@ def add_component(self,
self.device_config.id, component_config, self.client))
if component_type == "inverter" or component_type == "external_inverter":
self.inverter_counter += 1
with self.client:
# try:
# # ToDo: convert to String
# manufacturer = self.client.read_holding_registers(40004, [modbus.ModbusDataType.UINT_32]*8,
# unit=component_config.configuration.modbus_id)
# # ToDo: convert to String
# model = self.client.read_holding_registers(40020, [modbus.ModbusDataType.UINT_32]*8,
# unit=component_config.configuration.modbus_id)
# # ToDo: convert to String
# version = self.client.read_holding_registers(40044, [modbus.ModbusDataType.UINT_16]*8,
# unit=component_config.configuration.modbus_id)
# serial_number = self.client.read_holding_registers(40052, [modbus.ModbusDataType.UINT_32]*8,
# unit=component_config.configuration.modbus_id)
# log.debug("Version: " + str(version))
# except Exception as e:
# log.exception("Fehler beim Auslesen der Modbus-Register: " + str(e))
# pass
if self.client.read_holding_registers(40121, modbus.ModbusDataType.UINT_16,
unit=component_config.configuration.modbus_id
) == synergy_unit_identifier:
log.debug("Synergy Units supported")
self.synergy_units = int(self.client.read_holding_registers(
40129, modbus.ModbusDataType.UINT_16,
unit=component_config.configuration.modbus_id)) or 1
log.debug("Synergy Units detected: %s", self.synergy_units)
# try:
# # ToDo: convert to String
# manufacturer = self.client.read_holding_registers(40004, [modbus.ModbusDataType.UINT_32]*8,
# unit=component_config.configuration.modbus_id)
# # ToDo: convert to String
# model = self.client.read_holding_registers(40020, [modbus.ModbusDataType.UINT_32]*8,
# unit=component_config.configuration.modbus_id)
# # ToDo: convert to String
# version = self.client.read_holding_registers(40044, [modbus.ModbusDataType.UINT_16]*8,
# unit=component_config.configuration.modbus_id)
# serial_number = self.client.read_holding_registers(40052, [modbus.ModbusDataType.UINT_32]*8,
# unit=component_config.configuration.modbus_id)
# log.debug("Version: " + str(version))
# except Exception as e:
# log.exception("Fehler beim Auslesen der Modbus-Register: " + str(e))
# pass
if self.client.read_holding_registers(40121, modbus.ModbusDataType.UINT_16,
unit=component_config.configuration.modbus_id

Check failure on line 91 in packages/modules/devices/solaredge/device.py

View workflow job for this annotation

GitHub Actions / build

continuation line over-indented for visual indent
) == synergy_unit_identifier:

Check failure on line 92 in packages/modules/devices/solaredge/device.py

View workflow job for this annotation

GitHub Actions / build

closing bracket does not match visual indentation
log.debug("Synergy Units supported")
self.synergy_units = int(self.client.read_holding_registers(
40129, modbus.ModbusDataType.UINT_16,
unit=component_config.configuration.modbus_id)) or 1
log.debug("Synergy Units detected: %s", self.synergy_units)
if component_type == "external_inverter" or component_type == "counter" or component_type == "inverter":
self.set_component_registers(self.components.values(), self.synergy_units)
else:
Expand Down Expand Up @@ -203,7 +202,6 @@ def create_inverter(modbus_id: int) -> SolaredgeInverter:
if component_type == "counter":
dev.add_component(SolaredgeCounterSetup(
id=num, configuration=SolaredgeCounterConfiguration(modbus_id=int(slave_id0))))
time.sleep(reconnect_delay)
log.debug('Solaredge ModbusID: ' + str(slave_id0))
dev.update()
elif component_type == "inverter":
Expand Down

0 comments on commit 69ff45c

Please sign in to comment.