Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Solis inverter #1795

Merged
merged 3 commits into from
Sep 12, 2024
Merged

add Solis inverter #1795

merged 3 commits into from
Sep 12, 2024

Conversation

ndrsnhs
Copy link
Contributor

@ndrsnhs ndrsnhs commented Jul 31, 2024

Comment on lines 22 to 34
if self.version == SolisVersion.inverter:
# register offset -1
power = client.read_holding_registers(3262, ModbusDataType.INT_32, unit=unit)
powers = client.read_holding_registers(3256, [ModbusDataType.INT_32]*3, unit=unit)
frequency = client.read_holding_registers(3281, ModbusDataType.UINT_16, unit=unit) / 100
imported = client.read_holding_registers(3282, ModbusDataType.UINT_32, unit=unit) * 10
exported = client.read_holding_registers(3284, ModbusDataType.UINT_32, unit=unit) * 10
elif self.version == SolisVersion.hybrid:
power = client.read_holding_registers(33263, ModbusDataType.INT_32, unit=unit)
powers = client.read_holding_registers(33257, [ModbusDataType.INT_32]*3, unit=unit)
frequency = client.read_holding_registers(33282, ModbusDataType.UINT_16, unit=unit) / 100
imported = client.read_holding_registers(33283, ModbusDataType.UINT_32, unit=unit) * 10
exported = client.read_holding_registers(33285, ModbusDataType.UINT_32, unit=unit) * 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wenn Du das offset in eine Variable packst, wird es übersichtlicher:

Suggested change
if self.version == SolisVersion.inverter:
# register offset -1
power = client.read_holding_registers(3262, ModbusDataType.INT_32, unit=unit)
powers = client.read_holding_registers(3256, [ModbusDataType.INT_32]*3, unit=unit)
frequency = client.read_holding_registers(3281, ModbusDataType.UINT_16, unit=unit) / 100
imported = client.read_holding_registers(3282, ModbusDataType.UINT_32, unit=unit) * 10
exported = client.read_holding_registers(3284, ModbusDataType.UINT_32, unit=unit) * 10
elif self.version == SolisVersion.hybrid:
power = client.read_holding_registers(33263, ModbusDataType.INT_32, unit=unit)
powers = client.read_holding_registers(33257, [ModbusDataType.INT_32]*3, unit=unit)
frequency = client.read_holding_registers(33282, ModbusDataType.UINT_16, unit=unit) / 100
imported = client.read_holding_registers(33283, ModbusDataType.UINT_32, unit=unit) * 10
exported = client.read_holding_registers(33285, ModbusDataType.UINT_32, unit=unit) * 10
if self.version == SolisVersion.inverter:
register_offset = 0
elif self.version == SolisVersion.hybrid:
register_offset = 1
power = client.read_holding_registers(3262 + register_offset, ModbusDataType.INT_32, unit=unit)
powers = client.read_holding_registers(3256 + register_offset, [ModbusDataType.INT_32]*3, unit=unit)
frequency = client.read_holding_registers(3281 + register_offset, ModbusDataType.UINT_16, unit=unit) / 100
imported = client.read_holding_registers(3282 + register_offset, ModbusDataType.UINT_32, unit=unit) * 10
exported = client.read_holding_registers(3284 + register_offset, ModbusDataType.UINT_32, unit=unit) * 10

@ndrsnhs ndrsnhs requested a review from LKuemmel August 14, 2024 07:03
@LKuemmel LKuemmel added this to the 2.1.6 milestone Aug 14, 2024
@LKuemmel LKuemmel modified the milestones: 2.1.6, 2.1.6 Step 2 Aug 28, 2024
@benderl benderl merged commit 6379e8f into openWB:master Sep 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants