Bump nettigo-air-monitor
to version 2.1.0 (#88569)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
356c316b39
commit
a54e523731
7 changed files with 26 additions and 21 deletions
|
@ -9,9 +9,9 @@ from aiohttp.client_exceptions import ClientConnectorError, ClientError
|
|||
import async_timeout
|
||||
from nettigo_air_monitor import (
|
||||
ApiError,
|
||||
AuthFailed,
|
||||
AuthFailedError,
|
||||
ConnectionOptions,
|
||||
InvalidSensorData,
|
||||
InvalidSensorDataError,
|
||||
NAMSensors,
|
||||
NettigoAirMonitor,
|
||||
)
|
||||
|
@ -58,7 +58,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
await nam.async_check_credentials()
|
||||
except ApiError as err:
|
||||
raise ConfigEntryNotReady from err
|
||||
except AuthFailed as err:
|
||||
except AuthFailedError as err:
|
||||
raise ConfigEntryAuthFailed from err
|
||||
|
||||
coordinator = NAMDataUpdateCoordinator(hass, nam, entry.unique_id)
|
||||
|
@ -116,7 +116,7 @@ class NAMDataUpdateCoordinator(DataUpdateCoordinator[NAMSensors]):
|
|||
data = await self.nam.async_update()
|
||||
# We do not need to catch AuthFailed exception here because sensor data is
|
||||
# always available without authorization.
|
||||
except (ApiError, ClientConnectorError, InvalidSensorData) as error:
|
||||
except (ApiError, ClientConnectorError, InvalidSensorDataError) as error:
|
||||
raise UpdateFailed(error) from error
|
||||
|
||||
return data
|
||||
|
|
|
@ -11,8 +11,8 @@ from aiohttp.client_exceptions import ClientConnectorError
|
|||
import async_timeout
|
||||
from nettigo_air_monitor import (
|
||||
ApiError,
|
||||
AuthFailed,
|
||||
CannotGetMac,
|
||||
AuthFailedError,
|
||||
CannotGetMacError,
|
||||
ConnectionOptions,
|
||||
NettigoAirMonitor,
|
||||
)
|
||||
|
@ -95,7 +95,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
config = await async_get_config(self.hass, self.host)
|
||||
except (ApiError, ClientConnectorError, asyncio.TimeoutError):
|
||||
errors["base"] = "cannot_connect"
|
||||
except CannotGetMac:
|
||||
except CannotGetMacError:
|
||||
return self.async_abort(reason="device_unsupported")
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.exception("Unexpected exception")
|
||||
|
@ -127,7 +127,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
if user_input is not None:
|
||||
try:
|
||||
await async_check_credentials(self.hass, self.host, user_input)
|
||||
except AuthFailed:
|
||||
except AuthFailedError:
|
||||
errors["base"] = "invalid_auth"
|
||||
except (ApiError, ClientConnectorError, asyncio.TimeoutError):
|
||||
errors["base"] = "cannot_connect"
|
||||
|
@ -158,7 +158,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self._config = await async_get_config(self.hass, self.host)
|
||||
except (ApiError, ClientConnectorError, asyncio.TimeoutError):
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
except CannotGetMac:
|
||||
except CannotGetMacError:
|
||||
return self.async_abort(reason="device_unsupported")
|
||||
|
||||
await self.async_set_unique_id(format_mac(self._config.mac_address))
|
||||
|
@ -206,7 +206,12 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
if user_input is not None:
|
||||
try:
|
||||
await async_check_credentials(self.hass, self.host, user_input)
|
||||
except (ApiError, AuthFailed, ClientConnectorError, asyncio.TimeoutError):
|
||||
except (
|
||||
ApiError,
|
||||
AuthFailedError,
|
||||
ClientConnectorError,
|
||||
asyncio.TimeoutError,
|
||||
):
|
||||
return self.async_abort(reason="reauth_unsuccessful")
|
||||
|
||||
self.hass.config_entries.async_update_entry(
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"iot_class": "local_polling",
|
||||
"loggers": ["nettigo_air_monitor"],
|
||||
"quality_scale": "platinum",
|
||||
"requirements": ["nettigo-air-monitor==2.0.0"],
|
||||
"requirements": ["nettigo-air-monitor==2.1.0"],
|
||||
"zeroconf": [
|
||||
{
|
||||
"type": "_http._tcp.local.",
|
||||
|
|
|
@ -1183,7 +1183,7 @@ netdisco==3.0.0
|
|||
netmap==0.7.0.2
|
||||
|
||||
# homeassistant.components.nam
|
||||
nettigo-air-monitor==2.0.0
|
||||
nettigo-air-monitor==2.1.0
|
||||
|
||||
# homeassistant.components.neurio_energy
|
||||
neurio==0.3.1
|
||||
|
|
|
@ -879,7 +879,7 @@ netdisco==3.0.0
|
|||
netmap==0.7.0.2
|
||||
|
||||
# homeassistant.components.nam
|
||||
nettigo-air-monitor==2.0.0
|
||||
nettigo-air-monitor==2.1.0
|
||||
|
||||
# homeassistant.components.nexia
|
||||
nexia==2.0.6
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import asyncio
|
||||
from unittest.mock import patch
|
||||
|
||||
from nettigo_air_monitor import ApiError, AuthFailed, CannotGetMac
|
||||
from nettigo_air_monitor import ApiError, AuthFailedError, CannotGetMacError
|
||||
import pytest
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
|
@ -169,7 +169,7 @@ async def test_reauth_unsuccessful(hass: HomeAssistant) -> None:
|
|||
"error",
|
||||
[
|
||||
(ApiError("API Error"), "cannot_connect"),
|
||||
(AuthFailed("Auth Error"), "invalid_auth"),
|
||||
(AuthFailedError("Auth Error"), "invalid_auth"),
|
||||
(asyncio.TimeoutError, "cannot_connect"),
|
||||
(ValueError, "unknown"),
|
||||
],
|
||||
|
@ -179,7 +179,7 @@ async def test_form_with_auth_errors(hass: HomeAssistant, error) -> None:
|
|||
exc, base_error = error
|
||||
with patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor.async_check_credentials",
|
||||
side_effect=AuthFailed("Auth Error"),
|
||||
side_effect=AuthFailedError("Auth Error"),
|
||||
), patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor.async_get_mac_address",
|
||||
return_value="aa:bb:cc:dd:ee:ff",
|
||||
|
@ -236,7 +236,7 @@ async def test_form_abort(hass: HomeAssistant) -> None:
|
|||
return_value=DEVICE_CONFIG,
|
||||
), patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor.async_get_mac_address",
|
||||
side_effect=CannotGetMac("Cannot get MAC address from device"),
|
||||
side_effect=CannotGetMacError("Cannot get MAC address from device"),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -323,7 +323,7 @@ async def test_zeroconf_with_auth(hass: HomeAssistant) -> None:
|
|||
"""Test that the zeroconf step with auth works."""
|
||||
with patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor.async_check_credentials",
|
||||
side_effect=AuthFailed("Auth Error"),
|
||||
side_effect=AuthFailedError("Auth Error"),
|
||||
), patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor.async_get_mac_address",
|
||||
return_value="aa:bb:cc:dd:ee:ff",
|
||||
|
@ -388,7 +388,7 @@ async def test_zeroconf_host_already_configured(hass: HomeAssistant) -> None:
|
|||
"error",
|
||||
[
|
||||
(ApiError("API Error"), "cannot_connect"),
|
||||
(CannotGetMac("Cannot get MAC address from device"), "device_unsupported"),
|
||||
(CannotGetMacError("Cannot get MAC address from device"), "device_unsupported"),
|
||||
],
|
||||
)
|
||||
async def test_zeroconf_errors(hass: HomeAssistant, error) -> None:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Test init of Nettigo Air Monitor integration."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from nettigo_air_monitor import ApiError, AuthFailed
|
||||
from nettigo_air_monitor import ApiError, AuthFailedError
|
||||
|
||||
from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_PLATFORM
|
||||
from homeassistant.components.nam.const import DOMAIN
|
||||
|
@ -73,7 +73,7 @@ async def test_config_auth_failed(hass: HomeAssistant) -> None:
|
|||
|
||||
with patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor.async_check_credentials",
|
||||
side_effect=AuthFailed("Authorization has failed"),
|
||||
side_effect=AuthFailedError("Authorization has failed"),
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
assert entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue