Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Lars Kusch <[email protected]>
  • Loading branch information
LarsK1 committed Dec 29, 2024
1 parent c02981f commit d25153e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions custom_components/solvis_control/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async def async_step_user(self, user_input: ConfigType | None = None) -> FlowRes
self._abort_if_unique_id_configured()
modbussocket = ModbusClient.AsyncModbusTcpClient(host=user_input[CONF_HOST], port=user_input[CONF_PORT])
try:
await self.modbus.connect()
await modbussocket.connect()
_LOGGER.debug("Connected to Modbus for Solvis")
except ConnectionException as exc:
errors["base"] = "cannot_connect"
Expand All @@ -145,11 +145,12 @@ async def async_step_user(self, user_input: ConfigType | None = None) -> FlowRes
return self.async_show_form(step_id="user", data_schema=get_host_schema_config(self.data), errors=errors)
else:
versionsc = await modbussocket.read_input_registers(32770, 1, 1)
versionsc = str(BinaryPayloadDecoder.fromRegisters(versionsc, byteorder=Endian.BIG).decode_16bit_int())
versionsc = str(BinaryPayloadDecoder.fromRegisters(versionsc.registers, byteorder=Endian.BIG).decode_16bit_int())
versionnbg = await modbussocket.read_input_registers(32771, 1, 1)
versionnbg = str(BinaryPayloadDecoder.fromRegisters(versionnbg, byteorder=Endian.BIG).decode_16bit_int())
versionnbg = str(BinaryPayloadDecoder.fromRegisters(versionnbg.registers, byteorder=Endian.BIG).decode_16bit_int())
user_input["VERSIONSC"] = f"{versionsc[0]}.{versionnbg[1:3]}.{versionsc[3:5]}"
user_input["VERSIONNBG"] = f"{versionnbg[0]}.{versionnbg[1:3]}.{versionnbg[3:5]}"
modbussocket.close()
return await self.async_step_device()

return self.async_show_form(step_id="user", data_schema=get_host_schema_config(self.data), errors=errors)
Expand Down Expand Up @@ -205,7 +206,7 @@ async def async_step_init(self, user_input: ConfigType | None = None) -> FlowRes
self.data.update(user_input)
modbussocket: ModbusClient.AsyncModbusTcpClient = ModbusClient.AsyncModbusTcpClient(host=user_input[CONF_HOST], port=user_input[CONF_PORT])
try:
await self.modbus.connect()
await modbussocket.connect()
_LOGGER.debug("Connected to Modbus for Solvis")
except ConnectionException as exc:
errors["base"] = "cannot_connect"
Expand All @@ -217,11 +218,12 @@ async def async_step_init(self, user_input: ConfigType | None = None) -> FlowRes
return self.async_show_form(step_id="user", data_schema=get_host_schema_config(self.data), errors=errors)
else:
versionsc = await modbussocket.read_input_registers(32770, 1, 1)
versionsc = str(BinaryPayloadDecoder.fromRegisters(versionsc, byteorder=Endian.BIG).decode_16bit_int())
versionsc = str(BinaryPayloadDecoder.fromRegisters(versionsc.registers, byteorder=Endian.BIG).decode_16bit_int())
versionnbg = await modbussocket.read_input_registers(32771, 1, 1)
versionnbg = str(BinaryPayloadDecoder.fromRegisters(versionnbg, byteorder=Endian.BIG).decode_16bit_int())
versionnbg = str(BinaryPayloadDecoder.fromRegisters(versionnbg.registers, byteorder=Endian.BIG).decode_16bit_int())
user_input["VERSIONSC"] = f"{versionsc[0]}.{versionnbg[1:3]}.{versionsc[3:5]}"
user_input["VERSIONNBG"] = f"{versionnbg[0]}.{versionnbg[1:3]}.{versionnbg[3:5]}"
modbussocket.close()
return await self.async_step_device()

return self.async_show_form(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/solvis_control/diagonstics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async def async_get_config_entry_diagnostics(hass: HomeAssistant, entry: ConfigE

return {
"entry_data": entry.data,
"data": entry.runtime_data.data,
"data": "",
}


Expand Down

0 comments on commit d25153e

Please sign in to comment.