Bump python-broadlink to 0.15.0 (#39228)

* Rename DeviceOfflineError to NetworkTimeoutError

* Bump python-broadlink to 0.15
pull/40634/head
Felipe Martins Diel 2020-09-26 12:46:02 -03:00 committed by GitHub
parent 6977425d04
commit 2f4aa35ca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 26 deletions

View File

@ -7,7 +7,7 @@ import broadlink as blk
from broadlink.exceptions import (
AuthenticationError,
BroadlinkException,
DeviceOfflineError,
NetworkTimeoutError,
)
import voluptuous as vol
@ -139,7 +139,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
await self.async_set_unique_id(device.mac.hex())
return await self.async_step_reset(errors=errors)
except DeviceOfflineError as err:
except NetworkTimeoutError as err:
errors["base"] = "cannot_connect"
err_msg = str(err)
@ -207,7 +207,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
try:
await self.hass.async_add_executor_job(device.set_lock, False)
except DeviceOfflineError as err:
except NetworkTimeoutError as err:
errors["base"] = "cannot_connect"
err_msg = str(err)

View File

@ -9,7 +9,7 @@ from broadlink.exceptions import (
AuthorizationError,
BroadlinkException,
ConnectionClosedError,
DeviceOfflineError,
NetworkTimeoutError,
)
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_TIMEOUT, CONF_TYPE
@ -82,7 +82,7 @@ class BroadlinkDevice:
await self._async_handle_auth_error()
return False
except (DeviceOfflineError, OSError) as err:
except (NetworkTimeoutError, OSError) as err:
raise ConfigEntryNotReady from err
except BroadlinkException as err:

View File

@ -2,7 +2,7 @@
"domain": "broadlink",
"name": "Broadlink",
"documentation": "https://www.home-assistant.io/integrations/broadlink",
"requirements": ["broadlink==0.14.1"],
"requirements": ["broadlink==0.15.0"],
"codeowners": ["@danielhiversen", "@felipediel"],
"config_flow": true
}

View File

@ -9,7 +9,7 @@ import logging
from broadlink.exceptions import (
AuthorizationError,
BroadlinkException,
DeviceOfflineError,
NetworkTimeoutError,
ReadError,
StorageError,
)
@ -262,7 +262,7 @@ class BroadlinkRemote(RemoteEntity, RestoreEntity):
try:
await self._device.async_request(self._device.api.send_data, code)
except (AuthorizationError, DeviceOfflineError, OSError) as err:
except (AuthorizationError, NetworkTimeoutError, OSError) as err:
_LOGGER.error("Failed to send '%s': %s", command, err)
break
@ -295,7 +295,7 @@ class BroadlinkRemote(RemoteEntity, RestoreEntity):
if toggle:
code = [code, await self._async_learn_command(command)]
except (AuthorizationError, DeviceOfflineError, OSError) as err:
except (AuthorizationError, NetworkTimeoutError, OSError) as err:
_LOGGER.error("Failed to learn '%s': %s", command, err)
break

View File

@ -9,7 +9,7 @@ from broadlink.exceptions import (
AuthorizationError,
BroadlinkException,
CommandNotSupportedError,
DeviceOfflineError,
NetworkTimeoutError,
StorageError,
)
@ -113,7 +113,7 @@ class BroadlinkRMMini3UpdateManager(BroadlinkUpdateManager):
)
devices = await self.device.hass.async_add_executor_job(hello)
if not devices:
raise DeviceOfflineError("The device is offline")
raise NetworkTimeoutError("The device is offline")
return {}

View File

@ -383,7 +383,7 @@ boto3==1.9.252
bravia-tv==1.0.6
# homeassistant.components.broadlink
broadlink==0.14.1
broadlink==0.15.0
# homeassistant.components.brother
brother==0.1.17

View File

@ -204,7 +204,7 @@ bond-api==0.1.8
bravia-tv==1.0.6
# homeassistant.components.broadlink
broadlink==0.14.1
broadlink==0.15.0
# homeassistant.components.brother
brother==0.1.17

View File

@ -249,11 +249,11 @@ async def test_flow_auth_authentication_error(hass):
assert result["errors"] == {"base": "invalid_auth"}
async def test_flow_auth_device_offline(hass):
"""Test we handle a device offline in the auth step."""
async def test_flow_auth_network_timeout(hass):
"""Test we handle a network timeout in the auth step."""
device = get_device("Living Room")
mock_api = device.get_mock_api()
mock_api.auth.side_effect = blke.DeviceOfflineError()
mock_api.auth.side_effect = blke.NetworkTimeoutError()
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -403,12 +403,12 @@ async def test_flow_unlock_works(hass):
assert mock_api.set_lock.call_count == 1
async def test_flow_unlock_device_offline(hass):
"""Test we handle a device offline in the unlock step."""
async def test_flow_unlock_network_timeout(hass):
"""Test we handle a network timeout in the unlock step."""
device = get_device("Living Room")
mock_api = device.get_mock_api()
mock_api.is_locked = True
mock_api.set_lock.side_effect = blke.DeviceOfflineError
mock_api.set_lock.side_effect = blke.NetworkTimeoutError()
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}

View File

@ -62,11 +62,11 @@ async def test_device_setup_authentication_error(hass):
}
async def test_device_setup_device_offline(hass):
"""Test we handle a device offline."""
async def test_device_setup_network_timeout(hass):
"""Test we handle a network timeout."""
device = get_device("Office")
mock_api = device.get_mock_api()
mock_api.auth.side_effect = blke.DeviceOfflineError()
mock_api.auth.side_effect = blke.NetworkTimeoutError()
with patch.object(
hass.config_entries, "async_forward_entry_setup"
@ -119,11 +119,11 @@ async def test_device_setup_broadlink_exception(hass):
assert mock_init.call_count == 0
async def test_device_setup_update_device_offline(hass):
"""Test we handle a device offline in the update step."""
async def test_device_setup_update_network_timeout(hass):
"""Test we handle a network timeout in the update step."""
device = get_device("Office")
mock_api = device.get_mock_api()
mock_api.check_sensors.side_effect = blke.DeviceOfflineError()
mock_api.check_sensors.side_effect = blke.NetworkTimeoutError()
with patch.object(
hass.config_entries, "async_forward_entry_setup"
@ -308,7 +308,7 @@ async def test_device_unload_update_failed(hass):
"""Test we unload a device that failed the update step."""
device = get_device("Office")
mock_api = device.get_mock_api()
mock_api.check_sensors.side_effect = blke.DeviceOfflineError()
mock_api.check_sensors.side_effect = blke.NetworkTimeoutError()
with patch.object(hass.config_entries, "async_forward_entry_setup"):
_, mock_entry = await device.setup_entry(hass, mock_api=mock_api)