Fix AsusWRT wrong api call (#47522)

This commit is contained in:
ollo69 2021-03-08 19:34:12 +01:00 committed by GitHub
parent f9e33a4a0d
commit 32476a3fed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 8 deletions

View File

@ -46,7 +46,7 @@ homeassistant/components/arcam_fmj/* @elupus
homeassistant/components/arduino/* @fabaff
homeassistant/components/arest/* @fabaff
homeassistant/components/arris_tg2492lg/* @vanbalken
homeassistant/components/asuswrt/* @kennedyshead
homeassistant/components/asuswrt/* @kennedyshead @ollo69
homeassistant/components/atag/* @MatsNL
homeassistant/components/aten_pe/* @mtdcr
homeassistant/components/atome/* @baqs

View File

@ -127,7 +127,7 @@ class AsusWrtFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
conf_protocol = user_input[CONF_PROTOCOL]
if conf_protocol == PROTOCOL_TELNET:
await api.connection.disconnect()
api.connection.disconnect()
return RESULT_SUCCESS
async def async_step_user(self, user_input=None):

View File

@ -4,5 +4,5 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/asuswrt",
"requirements": ["aioasuswrt==1.3.1"],
"codeowners": ["@kennedyshead"]
"codeowners": ["@kennedyshead", "@ollo69"]
}

View File

@ -341,7 +341,7 @@ class AsusWrtRouter:
"""Close the connection."""
if self._api is not None:
if self._protocol == PROTOCOL_TELNET:
await self._api.connection.disconnect()
self._api.connection.disconnect()
self._api = None
for func in self._on_close:

View File

@ -1,6 +1,6 @@
"""Tests for the AsusWrt config flow."""
from socket import gaierror
from unittest.mock import AsyncMock, patch
from unittest.mock import AsyncMock, Mock, patch
import pytest
@ -46,7 +46,7 @@ def mock_controller_connect():
with patch("homeassistant.components.asuswrt.router.AsusWrt") as service_mock:
service_mock.return_value.connection.async_connect = AsyncMock()
service_mock.return_value.is_connected = True
service_mock.return_value.connection.disconnect = AsyncMock()
service_mock.return_value.connection.disconnect = Mock()
yield service_mock

View File

@ -1,6 +1,6 @@
"""Tests for the AsusWrt sensor."""
from datetime import timedelta
from unittest.mock import AsyncMock, patch
from unittest.mock import AsyncMock, Mock, patch
from aioasuswrt.asuswrt import Device
import pytest
@ -49,7 +49,7 @@ def mock_controller_connect():
with patch("homeassistant.components.asuswrt.router.AsusWrt") as service_mock:
service_mock.return_value.connection.async_connect = AsyncMock()
service_mock.return_value.is_connected = True
service_mock.return_value.connection.disconnect = AsyncMock()
service_mock.return_value.connection.disconnect = Mock()
service_mock.return_value.async_get_connected_devices = AsyncMock(
return_value=MOCK_DEVICES
)