Run KNX protocol logic in a separate thread (#68807)

This commit is contained in:
Matthias Alphart 2022-03-28 23:56:29 +02:00 committed by GitHub
parent 9881538c27
commit f2aee38841
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -394,6 +394,7 @@ class KNXModule:
connection_type=ConnectionType.ROUTING,
local_ip=self.config.get(ConnectionSchema.CONF_KNX_LOCAL_IP),
auto_reconnect=True,
threaded=True,
)
if _conn_type == CONF_KNX_TUNNELING:
return ConnectionConfig(
@ -403,6 +404,7 @@ class KNXModule:
local_ip=self.config.get(ConnectionSchema.CONF_KNX_LOCAL_IP),
route_back=self.config.get(ConnectionSchema.CONF_KNX_ROUTE_BACK, False),
auto_reconnect=True,
threaded=True,
)
if _conn_type == CONF_KNX_TUNNELING_TCP:
return ConnectionConfig(
@ -410,8 +412,12 @@ class KNXModule:
gateway_ip=self.config[CONF_HOST],
gateway_port=self.config[CONF_PORT],
auto_reconnect=True,
threaded=True,
)
return ConnectionConfig(auto_reconnect=True)
return ConnectionConfig(
auto_reconnect=True,
threaded=True,
)
async def connection_state_changed_cb(self, state: XknxConnectionState) -> None:
"""Call invoked after a KNX connection state change was received."""

View file

@ -28,7 +28,7 @@ from tests.common import MockConfigEntry
CONF_KNX_INDIVIDUAL_ADDRESS: XKNX.DEFAULT_ADDRESS,
CONF_KNX_CONNECTION_TYPE: CONF_KNX_AUTOMATIC,
},
ConnectionConfig(),
ConnectionConfig(threaded=True),
),
(
{
@ -36,7 +36,9 @@ from tests.common import MockConfigEntry
ConnectionSchema.CONF_KNX_LOCAL_IP: "192.168.1.1",
},
ConnectionConfig(
connection_type=ConnectionType.ROUTING, local_ip="192.168.1.1"
connection_type=ConnectionType.ROUTING,
local_ip="192.168.1.1",
threaded=True,
),
),
(
@ -54,6 +56,7 @@ from tests.common import MockConfigEntry
gateway_port=3675,
local_ip="192.168.1.112",
auto_reconnect=True,
threaded=True,
),
),
],