Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump python-broadlink to 0.15.0 #39228

Merged
merged 2 commits into from Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions homeassistant/components/broadlink/config_flow.py
Expand Up @@ -7,7 +7,7 @@
from broadlink.exceptions import (
AuthenticationError,
BroadlinkException,
DeviceOfflineError,
NetworkTimeoutError,
)
import voluptuous as vol

Expand Down Expand Up @@ -139,7 +139,7 @@ async def async_step_auth(self):
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)

Expand Down Expand Up @@ -207,7 +207,7 @@ async def async_step_unlock(self, user_input=None):
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)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/broadlink/device.py
Expand Up @@ -9,7 +9,7 @@
AuthorizationError,
BroadlinkException,
ConnectionClosedError,
DeviceOfflineError,
NetworkTimeoutError,
)

from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_TIMEOUT, CONF_TYPE
Expand Down Expand Up @@ -82,7 +82,7 @@ async def async_setup(self):
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:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/broadlink/manifest.json
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions homeassistant/components/broadlink/remote.py
Expand Up @@ -9,7 +9,7 @@
from broadlink.exceptions import (
AuthorizationError,
BroadlinkException,
DeviceOfflineError,
NetworkTimeoutError,
ReadError,
StorageError,
)
Expand Down Expand Up @@ -262,7 +262,7 @@ async def async_send_command(self, command, **kwargs):
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

Expand Down Expand Up @@ -295,7 +295,7 @@ async def async_learn_command(self, **kwargs):
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

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/broadlink/updater.py
Expand Up @@ -9,7 +9,7 @@
AuthorizationError,
BroadlinkException,
CommandNotSupportedError,
DeviceOfflineError,
NetworkTimeoutError,
StorageError,
)

Expand Down Expand Up @@ -113,7 +113,7 @@ async def async_fetch_data(self):
)
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 {}


Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/components/broadlink/test_config_flow.py
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down
14 changes: 7 additions & 7 deletions tests/components/broadlink/test_device.py
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down