mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Bump pypck to 0.8.1 (#133646)
Co-authored-by: Robert Resch <robert@resch.dev>
This commit is contained in:
parent
ad7a334147
commit
92195ff77d
@ -6,7 +6,14 @@ from functools import partial
|
||||
import logging
|
||||
|
||||
import pypck
|
||||
from pypck.connection import PchkConnectionManager
|
||||
from pypck.connection import (
|
||||
PchkAuthenticationError,
|
||||
PchkConnectionFailedError,
|
||||
PchkConnectionManager,
|
||||
PchkConnectionRefusedError,
|
||||
PchkLcnNotConnectedError,
|
||||
PchkLicenseError,
|
||||
)
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
@ -20,6 +27,7 @@ from homeassistant.const import (
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
@ -81,24 +89,21 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||
settings=settings,
|
||||
connection_id=config_entry.entry_id,
|
||||
)
|
||||
|
||||
try:
|
||||
# establish connection to PCHK server
|
||||
await lcn_connection.async_connect(timeout=15)
|
||||
except pypck.connection.PchkAuthenticationError:
|
||||
_LOGGER.warning('Authentication on PCHK "%s" failed', config_entry.title)
|
||||
return False
|
||||
except pypck.connection.PchkLicenseError:
|
||||
_LOGGER.warning(
|
||||
(
|
||||
'Maximum number of connections on PCHK "%s" was '
|
||||
"reached. An additional license key is required"
|
||||
),
|
||||
config_entry.title,
|
||||
)
|
||||
return False
|
||||
except TimeoutError:
|
||||
_LOGGER.warning('Connection to PCHK "%s" failed', config_entry.title)
|
||||
return False
|
||||
except (
|
||||
PchkAuthenticationError,
|
||||
PchkLicenseError,
|
||||
PchkConnectionRefusedError,
|
||||
PchkConnectionFailedError,
|
||||
PchkLcnNotConnectedError,
|
||||
) as ex:
|
||||
await lcn_connection.async_close()
|
||||
raise ConfigEntryNotReady(
|
||||
f"Unable to connect to {config_entry.title}: {ex}"
|
||||
) from ex
|
||||
|
||||
_LOGGER.debug('LCN connected to "%s"', config_entry.title)
|
||||
hass.data[DOMAIN][config_entry.entry_id] = {
|
||||
@ -106,6 +111,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||
DEVICE_CONNECTIONS: {},
|
||||
ADD_ENTITIES_CALLBACKS: {},
|
||||
}
|
||||
|
||||
# Update config_entry with LCN device serials
|
||||
await async_update_config_entry(hass, config_entry)
|
||||
|
||||
@ -121,6 +127,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||
input_received = partial(
|
||||
async_host_input_received, hass, config_entry, device_registry
|
||||
)
|
||||
|
||||
lcn_connection.register_for_inputs(input_received)
|
||||
|
||||
return True
|
||||
|
@ -96,7 +96,10 @@ async def validate_connection(data: ConfigType) -> str | None:
|
||||
host_name,
|
||||
)
|
||||
error = "license_error"
|
||||
except (TimeoutError, ConnectionRefusedError):
|
||||
except (
|
||||
pypck.connection.PchkConnectionFailedError,
|
||||
pypck.connection.PchkConnectionRefusedError,
|
||||
):
|
||||
_LOGGER.warning('Connection to PCHK "%s" failed', host_name)
|
||||
error = "connection_refused"
|
||||
|
||||
|
@ -8,5 +8,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/lcn",
|
||||
"iot_class": "local_push",
|
||||
"loggers": ["pypck"],
|
||||
"requirements": ["pypck==0.7.24", "lcn-frontend==0.2.2"]
|
||||
"requirements": ["pypck==0.8.1", "lcn-frontend==0.2.2"]
|
||||
}
|
||||
|
@ -2174,7 +2174,7 @@ pypalazzetti==0.1.15
|
||||
pypca==0.0.7
|
||||
|
||||
# homeassistant.components.lcn
|
||||
pypck==0.7.24
|
||||
pypck==0.8.1
|
||||
|
||||
# homeassistant.components.pjlink
|
||||
pypjlink2==1.2.1
|
||||
|
@ -1767,7 +1767,7 @@ pyownet==0.10.0.post1
|
||||
pypalazzetti==0.1.15
|
||||
|
||||
# homeassistant.components.lcn
|
||||
pypck==0.7.24
|
||||
pypck==0.8.1
|
||||
|
||||
# homeassistant.components.pjlink
|
||||
pypjlink2==1.2.1
|
||||
|
@ -2,7 +2,12 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from pypck.connection import PchkAuthenticationError, PchkLicenseError
|
||||
from pypck.connection import (
|
||||
PchkAuthenticationError,
|
||||
PchkConnectionFailedError,
|
||||
PchkConnectionRefusedError,
|
||||
PchkLicenseError,
|
||||
)
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
@ -98,7 +103,8 @@ async def test_step_user_existing_host(
|
||||
[
|
||||
(PchkAuthenticationError, {CONF_BASE: "authentication_error"}),
|
||||
(PchkLicenseError, {CONF_BASE: "license_error"}),
|
||||
(TimeoutError, {CONF_BASE: "connection_refused"}),
|
||||
(PchkConnectionFailedError, {CONF_BASE: "connection_refused"}),
|
||||
(PchkConnectionRefusedError, {CONF_BASE: "connection_refused"}),
|
||||
],
|
||||
)
|
||||
async def test_step_user_error(
|
||||
@ -149,7 +155,8 @@ async def test_step_reconfigure(hass: HomeAssistant, entry: MockConfigEntry) ->
|
||||
[
|
||||
(PchkAuthenticationError, {CONF_BASE: "authentication_error"}),
|
||||
(PchkLicenseError, {CONF_BASE: "license_error"}),
|
||||
(TimeoutError, {CONF_BASE: "connection_refused"}),
|
||||
(PchkConnectionFailedError, {CONF_BASE: "connection_refused"}),
|
||||
(PchkConnectionRefusedError, {CONF_BASE: "connection_refused"}),
|
||||
],
|
||||
)
|
||||
async def test_step_reconfigure_error(
|
||||
|
@ -2,7 +2,13 @@
|
||||
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from pypck.connection import PchkAuthenticationError, PchkLicenseError
|
||||
from pypck.connection import (
|
||||
PchkAuthenticationError,
|
||||
PchkConnectionFailedError,
|
||||
PchkConnectionRefusedError,
|
||||
PchkLcnNotConnectedError,
|
||||
PchkLicenseError,
|
||||
)
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
@ -84,21 +90,30 @@ async def test_async_setup_entry_update(
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"exception", [PchkAuthenticationError, PchkLicenseError, TimeoutError]
|
||||
"exception",
|
||||
[
|
||||
PchkAuthenticationError,
|
||||
PchkLicenseError,
|
||||
PchkConnectionRefusedError,
|
||||
PchkConnectionFailedError,
|
||||
PchkLcnNotConnectedError,
|
||||
],
|
||||
)
|
||||
async def test_async_setup_entry_raises_authentication_error(
|
||||
async def test_async_setup_entry_fails(
|
||||
hass: HomeAssistant, entry: MockConfigEntry, exception: Exception
|
||||
) -> None:
|
||||
"""Test that an authentication error is handled properly."""
|
||||
with patch(
|
||||
"homeassistant.components.lcn.PchkConnectionManager.async_connect",
|
||||
side_effect=exception,
|
||||
"""Test that an error is handled properly."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.lcn.PchkConnectionManager.async_connect",
|
||||
side_effect=exception,
|
||||
),
|
||||
):
|
||||
entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.state is ConfigEntryState.SETUP_ERROR
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
@patch("homeassistant.components.lcn.PchkConnectionManager", MockPchkConnectionManager)
|
||||
|
Loading…
x
Reference in New Issue
Block a user