From f9f3a8d92371227cbb508e8517578b447fb72283 Mon Sep 17 00:00:00 2001 From: veista Date: Wed, 14 Dec 2022 23:15:52 +0200 Subject: [PATCH] Fixed Bugs in Serial Setup --- custom_components/nilan/__init__.py | 5 +---- custom_components/nilan/config_flow.py | 3 ++- custom_components/nilan/device.py | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/custom_components/nilan/__init__.py b/custom_components/nilan/__init__.py index e117077..f7a660d 100644 --- a/custom_components/nilan/__init__.py +++ b/custom_components/nilan/__init__.py @@ -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() diff --git a/custom_components/nilan/config_flow.py b/custom_components/nilan/config_flow.py index 4bc49a9..e4f258a 100644 --- a/custom_components/nilan/config_flow.py +++ b/custom_components/nilan/config_flow.py @@ -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 diff --git a/custom_components/nilan/device.py b/custom_components/nilan/device.py index 662c042..31ef406 100644 --- a/custom_components/nilan/device.py +++ b/custom_components/nilan/device.py @@ -46,7 +46,7 @@ def __init__( "retry_on_empty": "true", "host": self._host_ip, "parity": "E", - "baudrate": "19200", + "baudrate": 19200, "bytesize": 8, "stopbits": 1, }