Bump airly library to version 1.1.0 (#47163)

This commit is contained in:
Maciej Bieniek 2021-02-28 12:53:13 +01:00 committed by GitHub
parent eb7220ff26
commit 66027bcef5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 9 deletions

View file

@ -144,6 +144,12 @@ class AirlyDataUpdateCoordinator(DataUpdateCoordinator):
except (AirlyError, ClientConnectorError) as error: except (AirlyError, ClientConnectorError) as error:
raise UpdateFailed(error) from error raise UpdateFailed(error) from error
_LOGGER.debug(
"Requests remaining: %s/%s",
self.airly.requests_remaining,
self.airly.requests_per_day,
)
values = measurements.current["values"] values = measurements.current["values"]
index = measurements.current["indexes"][0] index = measurements.current["indexes"][0]
standards = measurements.current["standards"] standards = measurements.current["standards"]

View file

@ -3,7 +3,7 @@
"name": "Airly", "name": "Airly",
"documentation": "https://www.home-assistant.io/integrations/airly", "documentation": "https://www.home-assistant.io/integrations/airly",
"codeowners": ["@bieniu"], "codeowners": ["@bieniu"],
"requirements": ["airly==1.0.0"], "requirements": ["airly==1.1.0"],
"config_flow": true, "config_flow": true,
"quality_scale": "platinum" "quality_scale": "platinum"
} }

View file

@ -22,7 +22,9 @@
}, },
"system_health": { "system_health": {
"info": { "info": {
"can_reach_server": "Reach Airly server" "can_reach_server": "Reach Airly server",
"requests_remaining": "Remaining allowed requests",
"requests_per_day": "Allowed requests per day"
} }
} }
} }

View file

@ -4,6 +4,8 @@ from airly import Airly
from homeassistant.components import system_health from homeassistant.components import system_health
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from .const import DOMAIN
@callback @callback
def async_register( def async_register(
@ -15,8 +17,13 @@ def async_register(
async def system_health_info(hass): async def system_health_info(hass):
"""Get info for the info page.""" """Get info for the info page."""
requests_remaining = list(hass.data[DOMAIN].values())[0].airly.requests_remaining
requests_per_day = list(hass.data[DOMAIN].values())[0].airly.requests_per_day
return { return {
"can_reach_server": system_health.async_check_can_reach_url( "can_reach_server": system_health.async_check_can_reach_url(
hass, Airly.AIRLY_API_URL hass, Airly.AIRLY_API_URL
) ),
"requests_remaining": requests_remaining,
"requests_per_day": requests_per_day,
} }

View file

@ -233,7 +233,7 @@ aiounifi==26
aioymaps==1.1.0 aioymaps==1.1.0
# homeassistant.components.airly # homeassistant.components.airly
airly==1.0.0 airly==1.1.0
# homeassistant.components.aladdin_connect # homeassistant.components.aladdin_connect
aladdin_connect==0.3 aladdin_connect==0.3

View file

@ -152,7 +152,7 @@ aiounifi==26
aioymaps==1.1.0 aioymaps==1.1.0
# homeassistant.components.airly # homeassistant.components.airly
airly==1.0.0 airly==1.1.0
# homeassistant.components.ambiclimate # homeassistant.components.ambiclimate
ambiclimate==0.2.1 ambiclimate==0.2.1

View file

@ -18,7 +18,11 @@ async def test_airly_system_health(hass, aioclient_mock):
hass.data[DOMAIN] = {} hass.data[DOMAIN] = {}
hass.data[DOMAIN]["0123xyz"] = Mock( hass.data[DOMAIN]["0123xyz"] = Mock(
airly=Mock(AIRLY_API_URL="https://airapi.airly.eu/v2/") airly=Mock(
AIRLY_API_URL="https://airapi.airly.eu/v2/",
requests_remaining=42,
requests_per_day=100,
)
) )
info = await get_system_health_info(hass, DOMAIN) info = await get_system_health_info(hass, DOMAIN)
@ -27,7 +31,9 @@ async def test_airly_system_health(hass, aioclient_mock):
if asyncio.iscoroutine(val): if asyncio.iscoroutine(val):
info[key] = await val info[key] = await val
assert info == {"can_reach_server": "ok"} assert info["can_reach_server"] == "ok"
assert info["requests_remaining"] == 42
assert info["requests_per_day"] == 100
async def test_airly_system_health_fail(hass, aioclient_mock): async def test_airly_system_health_fail(hass, aioclient_mock):
@ -38,7 +44,11 @@ async def test_airly_system_health_fail(hass, aioclient_mock):
hass.data[DOMAIN] = {} hass.data[DOMAIN] = {}
hass.data[DOMAIN]["0123xyz"] = Mock( hass.data[DOMAIN]["0123xyz"] = Mock(
airly=Mock(AIRLY_API_URL="https://airapi.airly.eu/v2/") airly=Mock(
AIRLY_API_URL="https://airapi.airly.eu/v2/",
requests_remaining=0,
requests_per_day=1000,
)
) )
info = await get_system_health_info(hass, DOMAIN) info = await get_system_health_info(hass, DOMAIN)
@ -47,4 +57,6 @@ async def test_airly_system_health_fail(hass, aioclient_mock):
if asyncio.iscoroutine(val): if asyncio.iscoroutine(val):
info[key] = await val info[key] = await val
assert info == {"can_reach_server": {"type": "failed", "error": "unreachable"}} assert info["can_reach_server"] == {"type": "failed", "error": "unreachable"}
assert info["requests_remaining"] == 0
assert info["requests_per_day"] == 1000