Skip to content

Commit

Permalink
Fixed Bugs in Serial Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
veista committed Dec 14, 2022
1 parent fccc213 commit f9f3a8d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
5 changes: 1 addition & 4 deletions custom_components/nilan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
host_port = entry.data["host_port"]
unit_id = entry.data["unit_id"]
com_type = entry.data["com_type"]
if entry.data["host_ip"]:
host_ip = entry.data["host_ip"]
else:
host_ip = None
host_ip = entry.data["host_ip"]

device = Device(hass, name, com_type, host_ip, host_port, unit_id)
await device.setup()
Expand Down
3 changes: 2 additions & 1 deletion custom_components/nilan/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ async def async_step_serial(self, user_input: Optional[dict(str, Any)] = None):
if not errors:
# Input is valid, set data.
self.data = user_input
self.data.update({"com_type": "tcp"})
self.data.update({"com_type": "serial"})
self.data.update({"host_ip": None})
return self.async_create_entry(title=user_input["name"], data=self.data)
return self.async_show_form(
step_id="serial", data_schema=STEP_SERIAL_DATA_SCHEMA, errors=errors
Expand Down
2 changes: 1 addition & 1 deletion custom_components/nilan/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(
"retry_on_empty": "true",
"host": self._host_ip,
"parity": "E",
"baudrate": "19200",
"baudrate": 19200,
"bytesize": 8,
"stopbits": 1,
}
Expand Down

0 comments on commit f9f3a8d

Please sign in to comment.