mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Bump python-broadlink to 0.15.0 (#39228)
* Rename DeviceOfflineError to NetworkTimeoutError * Bump python-broadlink to 0.15
This commit is contained in:
parent
6977425d04
commit
2f4aa35ca6
@ -7,7 +7,7 @@ import broadlink as blk
|
|||||||
from broadlink.exceptions import (
|
from broadlink.exceptions import (
|
||||||
AuthenticationError,
|
AuthenticationError,
|
||||||
BroadlinkException,
|
BroadlinkException,
|
||||||
DeviceOfflineError,
|
NetworkTimeoutError,
|
||||||
)
|
)
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
await self.async_set_unique_id(device.mac.hex())
|
await self.async_set_unique_id(device.mac.hex())
|
||||||
return await self.async_step_reset(errors=errors)
|
return await self.async_step_reset(errors=errors)
|
||||||
|
|
||||||
except DeviceOfflineError as err:
|
except NetworkTimeoutError as err:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
err_msg = str(err)
|
err_msg = str(err)
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ class BroadlinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
try:
|
try:
|
||||||
await self.hass.async_add_executor_job(device.set_lock, False)
|
await self.hass.async_add_executor_job(device.set_lock, False)
|
||||||
|
|
||||||
except DeviceOfflineError as err:
|
except NetworkTimeoutError as err:
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
err_msg = str(err)
|
err_msg = str(err)
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from broadlink.exceptions import (
|
|||||||
AuthorizationError,
|
AuthorizationError,
|
||||||
BroadlinkException,
|
BroadlinkException,
|
||||||
ConnectionClosedError,
|
ConnectionClosedError,
|
||||||
DeviceOfflineError,
|
NetworkTimeoutError,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_TIMEOUT, CONF_TYPE
|
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()
|
await self._async_handle_auth_error()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except (DeviceOfflineError, OSError) as err:
|
except (NetworkTimeoutError, OSError) as err:
|
||||||
raise ConfigEntryNotReady from err
|
raise ConfigEntryNotReady from err
|
||||||
|
|
||||||
except BroadlinkException as err:
|
except BroadlinkException as err:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"domain": "broadlink",
|
"domain": "broadlink",
|
||||||
"name": "Broadlink",
|
"name": "Broadlink",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/broadlink",
|
"documentation": "https://www.home-assistant.io/integrations/broadlink",
|
||||||
"requirements": ["broadlink==0.14.1"],
|
"requirements": ["broadlink==0.15.0"],
|
||||||
"codeowners": ["@danielhiversen", "@felipediel"],
|
"codeowners": ["@danielhiversen", "@felipediel"],
|
||||||
"config_flow": true
|
"config_flow": true
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import logging
|
|||||||
from broadlink.exceptions import (
|
from broadlink.exceptions import (
|
||||||
AuthorizationError,
|
AuthorizationError,
|
||||||
BroadlinkException,
|
BroadlinkException,
|
||||||
DeviceOfflineError,
|
NetworkTimeoutError,
|
||||||
ReadError,
|
ReadError,
|
||||||
StorageError,
|
StorageError,
|
||||||
)
|
)
|
||||||
@ -262,7 +262,7 @@ class BroadlinkRemote(RemoteEntity, RestoreEntity):
|
|||||||
try:
|
try:
|
||||||
await self._device.async_request(self._device.api.send_data, code)
|
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)
|
_LOGGER.error("Failed to send '%s': %s", command, err)
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ class BroadlinkRemote(RemoteEntity, RestoreEntity):
|
|||||||
if toggle:
|
if toggle:
|
||||||
code = [code, await self._async_learn_command(command)]
|
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)
|
_LOGGER.error("Failed to learn '%s': %s", command, err)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from broadlink.exceptions import (
|
|||||||
AuthorizationError,
|
AuthorizationError,
|
||||||
BroadlinkException,
|
BroadlinkException,
|
||||||
CommandNotSupportedError,
|
CommandNotSupportedError,
|
||||||
DeviceOfflineError,
|
NetworkTimeoutError,
|
||||||
StorageError,
|
StorageError,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ class BroadlinkRMMini3UpdateManager(BroadlinkUpdateManager):
|
|||||||
)
|
)
|
||||||
devices = await self.device.hass.async_add_executor_job(hello)
|
devices = await self.device.hass.async_add_executor_job(hello)
|
||||||
if not devices:
|
if not devices:
|
||||||
raise DeviceOfflineError("The device is offline")
|
raise NetworkTimeoutError("The device is offline")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ boto3==1.9.252
|
|||||||
bravia-tv==1.0.6
|
bravia-tv==1.0.6
|
||||||
|
|
||||||
# homeassistant.components.broadlink
|
# homeassistant.components.broadlink
|
||||||
broadlink==0.14.1
|
broadlink==0.15.0
|
||||||
|
|
||||||
# homeassistant.components.brother
|
# homeassistant.components.brother
|
||||||
brother==0.1.17
|
brother==0.1.17
|
||||||
|
@ -204,7 +204,7 @@ bond-api==0.1.8
|
|||||||
bravia-tv==1.0.6
|
bravia-tv==1.0.6
|
||||||
|
|
||||||
# homeassistant.components.broadlink
|
# homeassistant.components.broadlink
|
||||||
broadlink==0.14.1
|
broadlink==0.15.0
|
||||||
|
|
||||||
# homeassistant.components.brother
|
# homeassistant.components.brother
|
||||||
brother==0.1.17
|
brother==0.1.17
|
||||||
|
@ -249,11 +249,11 @@ async def test_flow_auth_authentication_error(hass):
|
|||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_auth_device_offline(hass):
|
async def test_flow_auth_network_timeout(hass):
|
||||||
"""Test we handle a device offline in the auth step."""
|
"""Test we handle a network timeout in the auth step."""
|
||||||
device = get_device("Living Room")
|
device = get_device("Living Room")
|
||||||
mock_api = device.get_mock_api()
|
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(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
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
|
assert mock_api.set_lock.call_count == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_unlock_device_offline(hass):
|
async def test_flow_unlock_network_timeout(hass):
|
||||||
"""Test we handle a device offline in the unlock step."""
|
"""Test we handle a network timeout in the unlock step."""
|
||||||
device = get_device("Living Room")
|
device = get_device("Living Room")
|
||||||
mock_api = device.get_mock_api()
|
mock_api = device.get_mock_api()
|
||||||
mock_api.is_locked = True
|
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(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
|
@ -62,11 +62,11 @@ async def test_device_setup_authentication_error(hass):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_device_setup_device_offline(hass):
|
async def test_device_setup_network_timeout(hass):
|
||||||
"""Test we handle a device offline."""
|
"""Test we handle a network timeout."""
|
||||||
device = get_device("Office")
|
device = get_device("Office")
|
||||||
mock_api = device.get_mock_api()
|
mock_api = device.get_mock_api()
|
||||||
mock_api.auth.side_effect = blke.DeviceOfflineError()
|
mock_api.auth.side_effect = blke.NetworkTimeoutError()
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
hass.config_entries, "async_forward_entry_setup"
|
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
|
assert mock_init.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_device_setup_update_device_offline(hass):
|
async def test_device_setup_update_network_timeout(hass):
|
||||||
"""Test we handle a device offline in the update step."""
|
"""Test we handle a network timeout in the update step."""
|
||||||
device = get_device("Office")
|
device = get_device("Office")
|
||||||
mock_api = device.get_mock_api()
|
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(
|
with patch.object(
|
||||||
hass.config_entries, "async_forward_entry_setup"
|
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."""
|
"""Test we unload a device that failed the update step."""
|
||||||
device = get_device("Office")
|
device = get_device("Office")
|
||||||
mock_api = device.get_mock_api()
|
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"):
|
with patch.object(hass.config_entries, "async_forward_entry_setup"):
|
||||||
_, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
|
_, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user