Bump nettigo_air_monitor
to version 3.1.0 (#118227)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
This commit is contained in:
parent
e7ce01e649
commit
805f634634
7 changed files with 21 additions and 21 deletions
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
import logging
|
||||||
|
@ -50,7 +49,6 @@ async def async_get_config(hass: HomeAssistant, host: str) -> NamConfig:
|
||||||
options = ConnectionOptions(host)
|
options = ConnectionOptions(host)
|
||||||
nam = await NettigoAirMonitor.create(websession, options)
|
nam = await NettigoAirMonitor.create(websession, options)
|
||||||
|
|
||||||
async with asyncio.timeout(10):
|
|
||||||
mac = await nam.async_get_mac_address()
|
mac = await nam.async_get_mac_address()
|
||||||
|
|
||||||
return NamConfig(mac, nam.auth_enabled)
|
return NamConfig(mac, nam.auth_enabled)
|
||||||
|
@ -66,7 +64,6 @@ async def async_check_credentials(
|
||||||
|
|
||||||
nam = await NettigoAirMonitor.create(websession, options)
|
nam = await NettigoAirMonitor.create(websession, options)
|
||||||
|
|
||||||
async with asyncio.timeout(10):
|
|
||||||
await nam.async_check_credentials()
|
await nam.async_check_credentials()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ ATTR_SPS30_P2: Final = f"{ATTR_SPS30}{SUFFIX_P2}"
|
||||||
ATTR_SPS30_P4: Final = f"{ATTR_SPS30}{SUFFIX_P4}"
|
ATTR_SPS30_P4: Final = f"{ATTR_SPS30}{SUFFIX_P4}"
|
||||||
ATTR_UPTIME: Final = "uptime"
|
ATTR_UPTIME: Final = "uptime"
|
||||||
|
|
||||||
DEFAULT_UPDATE_INTERVAL: Final = timedelta(minutes=6)
|
DEFAULT_UPDATE_INTERVAL: Final = timedelta(minutes=4)
|
||||||
DOMAIN: Final = "nam"
|
DOMAIN: Final = "nam"
|
||||||
MANUFACTURER: Final = "Nettigo"
|
MANUFACTURER: Final = "Nettigo"
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
"""The Nettigo Air Monitor coordinator."""
|
"""The Nettigo Air Monitor coordinator."""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from aiohttp.client_exceptions import ClientConnectorError
|
|
||||||
from nettigo_air_monitor import (
|
from nettigo_air_monitor import (
|
||||||
ApiError,
|
ApiError,
|
||||||
InvalidSensorDataError,
|
InvalidSensorDataError,
|
||||||
NAMSensors,
|
NAMSensors,
|
||||||
NettigoAirMonitor,
|
NettigoAirMonitor,
|
||||||
)
|
)
|
||||||
|
from tenacity import RetryError
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
|
||||||
|
@ -47,11 +46,10 @@ class NAMDataUpdateCoordinator(DataUpdateCoordinator[NAMSensors]):
|
||||||
async def _async_update_data(self) -> NAMSensors:
|
async def _async_update_data(self) -> NAMSensors:
|
||||||
"""Update data via library."""
|
"""Update data via library."""
|
||||||
try:
|
try:
|
||||||
async with asyncio.timeout(10):
|
|
||||||
data = await self.nam.async_update()
|
data = await self.nam.async_update()
|
||||||
# We do not need to catch AuthFailed exception here because sensor data is
|
# We do not need to catch AuthFailed exception here because sensor data is
|
||||||
# always available without authorization.
|
# always available without authorization.
|
||||||
except (ApiError, ClientConnectorError, InvalidSensorDataError) as error:
|
except (ApiError, InvalidSensorDataError, RetryError) as error:
|
||||||
raise UpdateFailed(error) from error
|
raise UpdateFailed(error) from error
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["nettigo_air_monitor"],
|
"loggers": ["nettigo_air_monitor"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["nettigo-air-monitor==3.0.1"],
|
"requirements": ["nettigo-air-monitor==3.1.0"],
|
||||||
"zeroconf": [
|
"zeroconf": [
|
||||||
{
|
{
|
||||||
"type": "_http._tcp.local.",
|
"type": "_http._tcp.local.",
|
||||||
|
|
|
@ -1386,7 +1386,7 @@ netdata==1.1.0
|
||||||
netmap==0.7.0.2
|
netmap==0.7.0.2
|
||||||
|
|
||||||
# homeassistant.components.nam
|
# homeassistant.components.nam
|
||||||
nettigo-air-monitor==3.0.1
|
nettigo-air-monitor==3.1.0
|
||||||
|
|
||||||
# homeassistant.components.neurio_energy
|
# homeassistant.components.neurio_energy
|
||||||
neurio==0.3.1
|
neurio==0.3.1
|
||||||
|
|
|
@ -1122,7 +1122,7 @@ nessclient==1.0.0
|
||||||
netmap==0.7.0.2
|
netmap==0.7.0.2
|
||||||
|
|
||||||
# homeassistant.components.nam
|
# homeassistant.components.nam
|
||||||
nettigo-air-monitor==3.0.1
|
nettigo-air-monitor==3.1.0
|
||||||
|
|
||||||
# homeassistant.components.nexia
|
# homeassistant.components.nexia
|
||||||
nexia==2.0.8
|
nexia==2.0.8
|
||||||
|
|
|
@ -5,9 +5,11 @@ from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
from freezegun.api import FrozenDateTimeFactory
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
from nettigo_air_monitor import ApiError
|
from nettigo_air_monitor import ApiError
|
||||||
|
import pytest
|
||||||
from syrupy import SnapshotAssertion
|
from syrupy import SnapshotAssertion
|
||||||
|
from tenacity import RetryError
|
||||||
|
|
||||||
from homeassistant.components.nam.const import DOMAIN
|
from homeassistant.components.nam.const import DEFAULT_UPDATE_INTERVAL, DOMAIN
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorDeviceClass
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorDeviceClass
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_CLASS,
|
ATTR_DEVICE_CLASS,
|
||||||
|
@ -96,7 +98,10 @@ async def test_incompleta_data_after_device_restart(hass: HomeAssistant) -> None
|
||||||
assert state.state == STATE_UNAVAILABLE
|
assert state.state == STATE_UNAVAILABLE
|
||||||
|
|
||||||
|
|
||||||
async def test_availability(hass: HomeAssistant) -> None:
|
@pytest.mark.parametrize("exc", [ApiError("API Error"), RetryError])
|
||||||
|
async def test_availability(
|
||||||
|
hass: HomeAssistant, freezer: FrozenDateTimeFactory, exc: Exception
|
||||||
|
) -> None:
|
||||||
"""Ensure that we mark the entities unavailable correctly when device causes an error."""
|
"""Ensure that we mark the entities unavailable correctly when device causes an error."""
|
||||||
nam_data = load_json_object_fixture("nam/nam_data.json")
|
nam_data = load_json_object_fixture("nam/nam_data.json")
|
||||||
|
|
||||||
|
@ -107,22 +112,21 @@ async def test_availability(hass: HomeAssistant) -> None:
|
||||||
assert state.state != STATE_UNAVAILABLE
|
assert state.state != STATE_UNAVAILABLE
|
||||||
assert state.state == "7.6"
|
assert state.state == "7.6"
|
||||||
|
|
||||||
future = utcnow() + timedelta(minutes=6)
|
|
||||||
with (
|
with (
|
||||||
patch("homeassistant.components.nam.NettigoAirMonitor.initialize"),
|
patch("homeassistant.components.nam.NettigoAirMonitor.initialize"),
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.nam.NettigoAirMonitor._async_http_request",
|
"homeassistant.components.nam.NettigoAirMonitor._async_http_request",
|
||||||
side_effect=ApiError("API Error"),
|
side_effect=exc,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, future)
|
freezer.tick(DEFAULT_UPDATE_INTERVAL)
|
||||||
|
async_fire_time_changed(hass)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state = hass.states.get("sensor.nettigo_air_monitor_bme280_temperature")
|
state = hass.states.get("sensor.nettigo_air_monitor_bme280_temperature")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == STATE_UNAVAILABLE
|
assert state.state == STATE_UNAVAILABLE
|
||||||
|
|
||||||
future = utcnow() + timedelta(minutes=12)
|
|
||||||
update_response = Mock(json=AsyncMock(return_value=nam_data))
|
update_response = Mock(json=AsyncMock(return_value=nam_data))
|
||||||
with (
|
with (
|
||||||
patch("homeassistant.components.nam.NettigoAirMonitor.initialize"),
|
patch("homeassistant.components.nam.NettigoAirMonitor.initialize"),
|
||||||
|
@ -131,7 +135,8 @@ async def test_availability(hass: HomeAssistant) -> None:
|
||||||
return_value=update_response,
|
return_value=update_response,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
async_fire_time_changed(hass, future)
|
freezer.tick(DEFAULT_UPDATE_INTERVAL)
|
||||||
|
async_fire_time_changed(hass)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
state = hass.states.get("sensor.nettigo_air_monitor_bme280_temperature")
|
state = hass.states.get("sensor.nettigo_air_monitor_bme280_temperature")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue