Skip to content

Commit

Permalink
Fix inverter auto-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
canton7 committed Apr 19, 2023
1 parent 8c3ec6c commit bad9280
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion custom_components/foxess_modbus/modbus_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
from .common.entity_controller import EntityController
from .common.entity_controller import ModbusControllerEntity
from .common.exceptions import UnsupportedInverterException
from .common.register_type import RegisterType
from .common.unload_controller import UnloadController
from .const import AUX
from .inverter_connection_types import CONNECTION_TYPES
from .inverter_profiles import INVERTER_PROFILES
from .inverter_profiles import InverterModelConnectionTypeProfile
Expand Down Expand Up @@ -293,10 +295,17 @@ async def autodetect(client: ModbusClient, slave: int) -> tuple[str, str, str]:
"""
for conn_type_name, conn_type in CONNECTION_TYPES.items():
try:
# TODO: The H3 uses holding registers for everything, so this will always mis-identify the H3 as LAN
# We can fix this as part of the updated config flow, where the user explicitly selects between LAN and AUX
register_type = (
RegisterType.INPUT
if conn_type_name == AUX
else RegisterType.HOLDING
)
result = await client.read_registers(
conn_type.serial_start_address,
10,
conn_type.read_holding_registers,
register_type,
slave,
)
inverter_str = "".join([chr(i) for i in result])
Expand Down

0 comments on commit bad9280

Please sign in to comment.