mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Bump gios
library to version 3.1.0 (#89044)
This commit is contained in:
parent
b407227d4a
commit
1538f639ae
@ -7,7 +7,8 @@ from typing import Any, cast
|
|||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
from aiohttp.client_exceptions import ClientConnectorError
|
from aiohttp.client_exceptions import ClientConnectorError
|
||||||
from async_timeout import timeout
|
from async_timeout import timeout
|
||||||
from gios import ApiError, Gios, InvalidSensorsData, NoStationError
|
from gios import Gios
|
||||||
|
from gios.exceptions import GiosError
|
||||||
|
|
||||||
from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_PLATFORM
|
from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_PLATFORM
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -89,10 +90,5 @@ class GiosDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
try:
|
try:
|
||||||
async with timeout(API_TIMEOUT):
|
async with timeout(API_TIMEOUT):
|
||||||
return cast(dict[str, Any], await self.gios.async_update())
|
return cast(dict[str, Any], await self.gios.async_update())
|
||||||
except (
|
except (GiosError, ClientConnectorError) as error:
|
||||||
ApiError,
|
|
||||||
NoStationError,
|
|
||||||
ClientConnectorError,
|
|
||||||
InvalidSensorsData,
|
|
||||||
) as error:
|
|
||||||
raise UpdateFailed(error) from error
|
raise UpdateFailed(error) from error
|
||||||
|
@ -6,7 +6,7 @@ from typing import Any
|
|||||||
|
|
||||||
from aiohttp.client_exceptions import ClientConnectorError
|
from aiohttp.client_exceptions import ClientConnectorError
|
||||||
from async_timeout import timeout
|
from async_timeout import timeout
|
||||||
from gios import ApiError, Gios, InvalidSensorsData, NoStationError
|
from gios import ApiError, Gios, InvalidSensorsDataError, NoStationError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
@ -50,7 +50,7 @@ class GiosFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except NoStationError:
|
except NoStationError:
|
||||||
errors[CONF_STATION_ID] = "wrong_station_id"
|
errors[CONF_STATION_ID] = "wrong_station_id"
|
||||||
except InvalidSensorsData:
|
except InvalidSensorsDataError:
|
||||||
errors[CONF_STATION_ID] = "invalid_sensors_data"
|
errors[CONF_STATION_ID] = "invalid_sensors_data"
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
@ -8,5 +8,5 @@
|
|||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["dacite", "gios"],
|
"loggers": ["dacite", "gios"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["gios==2.3.0"]
|
"requirements": ["gios==3.1.0"]
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,10 @@ SENSOR_TYPES: tuple[GiosSensorEntityDescription, ...] = (
|
|||||||
key=ATTR_AQI,
|
key=ATTR_AQI,
|
||||||
name="AQI",
|
name="AQI",
|
||||||
value=None,
|
value=None,
|
||||||
|
icon="mdi:air-filter",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=["very_bad", "bad", "sufficient", "moderate", "good", "very_good"],
|
||||||
|
translation_key="aqi",
|
||||||
),
|
),
|
||||||
GiosSensorEntityDescription(
|
GiosSensorEntityDescription(
|
||||||
key=ATTR_C6H6,
|
key=ATTR_C6H6,
|
||||||
|
@ -22,5 +22,19 @@
|
|||||||
"info": {
|
"info": {
|
||||||
"can_reach_server": "Reach GIO\u015a server"
|
"can_reach_server": "Reach GIO\u015a server"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"sensor": {
|
||||||
|
"aqi": {
|
||||||
|
"state": {
|
||||||
|
"very_bad": "Very bad",
|
||||||
|
"bad": "Bad",
|
||||||
|
"sufficient": "Sufficient",
|
||||||
|
"moderate": "Moderate",
|
||||||
|
"good": "Good",
|
||||||
|
"very_good": "Very good"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -786,7 +786,7 @@ georss_qld_bushfire_alert_client==0.5
|
|||||||
getmac==0.8.2
|
getmac==0.8.2
|
||||||
|
|
||||||
# homeassistant.components.gios
|
# homeassistant.components.gios
|
||||||
gios==2.3.0
|
gios==3.1.0
|
||||||
|
|
||||||
# homeassistant.components.gitter
|
# homeassistant.components.gitter
|
||||||
gitterpy==0.1.7
|
gitterpy==0.1.7
|
||||||
|
@ -602,7 +602,7 @@ georss_qld_bushfire_alert_client==0.5
|
|||||||
getmac==0.8.2
|
getmac==0.8.2
|
||||||
|
|
||||||
# homeassistant.components.gios
|
# homeassistant.components.gios
|
||||||
gios==2.3.0
|
gios==3.1.0
|
||||||
|
|
||||||
# homeassistant.components.glances
|
# homeassistant.components.glances
|
||||||
glances_api==0.4.1
|
glances_api==0.4.1
|
||||||
|
@ -3,48 +3,48 @@
|
|||||||
"name": "AQI",
|
"name": "AQI",
|
||||||
"id": null,
|
"id": null,
|
||||||
"index": null,
|
"index": null,
|
||||||
"value": "dobry"
|
"value": "good"
|
||||||
},
|
},
|
||||||
"c6h6": {
|
"c6h6": {
|
||||||
"name": "benzen",
|
"name": "benzene",
|
||||||
"id": 658,
|
"id": 658,
|
||||||
"index": "bardzo dobry",
|
"index": "very_good",
|
||||||
"value": 0.23789
|
"value": 0.23789
|
||||||
},
|
},
|
||||||
"co": {
|
"co": {
|
||||||
"name": "tlenek węgla",
|
"name": "carbon monoxide",
|
||||||
"id": 660,
|
"id": 660,
|
||||||
"index": "dobry",
|
"index": "good",
|
||||||
"value": 251.874
|
"value": 251.874
|
||||||
},
|
},
|
||||||
"no2": {
|
"no2": {
|
||||||
"name": "dwutlenek azotu",
|
"name": "nitrogen dioxide",
|
||||||
"id": 665,
|
"id": 665,
|
||||||
"index": "dobry",
|
"index": "good",
|
||||||
"value": 7.13411
|
"value": 7.13411
|
||||||
},
|
},
|
||||||
"o3": {
|
"o3": {
|
||||||
"name": "ozon",
|
"name": "ozone",
|
||||||
"id": 667,
|
"id": 667,
|
||||||
"index": "dobry",
|
"index": "good",
|
||||||
"value": 95.7768
|
"value": 95.7768
|
||||||
},
|
},
|
||||||
"pm10": {
|
"pm10": {
|
||||||
"name": "py\u0142 zawieszony PM10",
|
"name": "particulate matter 10",
|
||||||
"id": 14395,
|
"id": 14395,
|
||||||
"index": "dobry",
|
"index": "good",
|
||||||
"value": 16.8344
|
"value": 16.8344
|
||||||
},
|
},
|
||||||
"pm25": {
|
"pm25": {
|
||||||
"name": "py\u0142 zawieszony PM2.5",
|
"name": "particulate matter 2.5",
|
||||||
"id": 670,
|
"id": 670,
|
||||||
"index": "dobry",
|
"index": "good",
|
||||||
"value": 4
|
"value": 4
|
||||||
},
|
},
|
||||||
"so2": {
|
"so2": {
|
||||||
"name": "dwutlenek siarki",
|
"name": "sulfur dioxide",
|
||||||
"id": 672,
|
"id": 672,
|
||||||
"index": "bardzo dobry",
|
"index": "very_good",
|
||||||
"value": 4.35478
|
"value": 4.35478
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
{
|
{
|
||||||
"id": 123,
|
"id": 123,
|
||||||
"stCalcDate": "2020-07-31 15:10:17",
|
"stCalcDate": "2020-07-31 15:10:17",
|
||||||
"stIndexLevel": { "id": 1, "indexLevelName": "dobry" },
|
"stIndexLevel": { "id": 1, "indexLevelName": "Dobry" },
|
||||||
"stSourceDataDate": "2020-07-31 14:00:00",
|
"stSourceDataDate": "2020-07-31 14:00:00",
|
||||||
"so2CalcDate": "2020-07-31 15:10:17",
|
"so2CalcDate": "2020-07-31 15:10:17",
|
||||||
"so2IndexLevel": { "id": 0, "indexLevelName": "bardzo dobry" },
|
"so2IndexLevel": { "id": 0, "indexLevelName": "Bardzo dobry" },
|
||||||
"so2SourceDataDate": "2020-07-31 14:00:00",
|
"so2SourceDataDate": "2020-07-31 14:00:00",
|
||||||
"no2CalcDate": 1596201017000,
|
"no2CalcDate": 1596201017000,
|
||||||
"no2IndexLevel": { "id": 0, "indexLevelName": "dobry" },
|
"no2IndexLevel": { "id": 0, "indexLevelName": "Dobry" },
|
||||||
"no2SourceDataDate": "2020-07-31 14:00:00",
|
"no2SourceDataDate": "2020-07-31 14:00:00",
|
||||||
"coCalcDate": "2020-07-31 15:10:17",
|
"coCalcDate": "2020-07-31 15:10:17",
|
||||||
"coIndexLevel": { "id": 0, "indexLevelName": "dobry" },
|
"coIndexLevel": { "id": 0, "indexLevelName": "Dobry" },
|
||||||
"coSourceDataDate": "2020-07-31 14:00:00",
|
"coSourceDataDate": "2020-07-31 14:00:00",
|
||||||
"pm10CalcDate": "2020-07-31 15:10:17",
|
"pm10CalcDate": "2020-07-31 15:10:17",
|
||||||
"pm10IndexLevel": { "id": 0, "indexLevelName": "dobry" },
|
"pm10IndexLevel": { "id": 0, "indexLevelName": "Dobry" },
|
||||||
"pm10SourceDataDate": "2020-07-31 14:00:00",
|
"pm10SourceDataDate": "2020-07-31 14:00:00",
|
||||||
"pm25CalcDate": "2020-07-31 15:10:17",
|
"pm25CalcDate": "2020-07-31 15:10:17",
|
||||||
"pm25IndexLevel": { "id": 0, "indexLevelName": "dobry" },
|
"pm25IndexLevel": { "id": 0, "indexLevelName": "Dobry" },
|
||||||
"pm25SourceDataDate": "2020-07-31 14:00:00",
|
"pm25SourceDataDate": "2020-07-31 14:00:00",
|
||||||
"o3CalcDate": "2020-07-31 15:10:17",
|
"o3CalcDate": "2020-07-31 15:10:17",
|
||||||
"o3IndexLevel": { "id": 1, "indexLevelName": "dobry" },
|
"o3IndexLevel": { "id": 1, "indexLevelName": "Dobry" },
|
||||||
"o3SourceDataDate": "2020-07-31 14:00:00",
|
"o3SourceDataDate": "2020-07-31 14:00:00",
|
||||||
"c6h6CalcDate": "2020-07-31 15:10:17",
|
"c6h6CalcDate": "2020-07-31 15:10:17",
|
||||||
"c6h6IndexLevel": { "id": 0, "indexLevelName": "bardzo dobry" },
|
"c6h6IndexLevel": { "id": 0, "indexLevelName": "Bardzo dobry" },
|
||||||
"c6h6SourceDataDate": "2020-07-31 14:00:00",
|
"c6h6SourceDataDate": "2020-07-31 14:00:00",
|
||||||
"stIndexStatus": true,
|
"stIndexStatus": true,
|
||||||
"stIndexCrParam": "OZON"
|
"stIndexCrParam": "OZON"
|
||||||
|
@ -12,6 +12,7 @@ from homeassistant.components.gios.const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
|
ATTR_OPTIONS,
|
||||||
ATTR_STATE_CLASS,
|
ATTR_STATE_CLASS,
|
||||||
DOMAIN as PLATFORM,
|
DOMAIN as PLATFORM,
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
@ -50,7 +51,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
|||||||
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:molecule"
|
assert state.attributes.get(ATTR_ICON) == "mdi:molecule"
|
||||||
assert state.attributes.get(ATTR_INDEX) == "bardzo dobry"
|
assert state.attributes.get(ATTR_INDEX) == "very_good"
|
||||||
|
|
||||||
entry = registry.async_get("sensor.home_c6h6")
|
entry = registry.async_get("sensor.home_c6h6")
|
||||||
assert entry
|
assert entry
|
||||||
@ -67,7 +68,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
|||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_INDEX) == "dobry"
|
assert state.attributes.get(ATTR_INDEX) == "good"
|
||||||
|
|
||||||
entry = registry.async_get("sensor.home_co")
|
entry = registry.async_get("sensor.home_co")
|
||||||
assert entry
|
assert entry
|
||||||
@ -84,7 +85,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
|||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_INDEX) == "dobry"
|
assert state.attributes.get(ATTR_INDEX) == "good"
|
||||||
|
|
||||||
entry = registry.async_get("sensor.home_no2")
|
entry = registry.async_get("sensor.home_no2")
|
||||||
assert entry
|
assert entry
|
||||||
@ -101,7 +102,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
|||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_INDEX) == "dobry"
|
assert state.attributes.get(ATTR_INDEX) == "good"
|
||||||
|
|
||||||
entry = registry.async_get("sensor.home_o3")
|
entry = registry.async_get("sensor.home_o3")
|
||||||
assert entry
|
assert entry
|
||||||
@ -118,7 +119,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
|||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_INDEX) == "dobry"
|
assert state.attributes.get(ATTR_INDEX) == "good"
|
||||||
|
|
||||||
entry = registry.async_get("sensor.home_pm10")
|
entry = registry.async_get("sensor.home_pm10")
|
||||||
assert entry
|
assert entry
|
||||||
@ -135,7 +136,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
|||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_INDEX) == "dobry"
|
assert state.attributes.get(ATTR_INDEX) == "good"
|
||||||
|
|
||||||
entry = registry.async_get("sensor.home_pm2_5")
|
entry = registry.async_get("sensor.home_pm2_5")
|
||||||
assert entry
|
assert entry
|
||||||
@ -152,7 +153,7 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
|||||||
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
||||||
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
== CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
)
|
)
|
||||||
assert state.attributes.get(ATTR_INDEX) == "bardzo dobry"
|
assert state.attributes.get(ATTR_INDEX) == "very_good"
|
||||||
|
|
||||||
entry = registry.async_get("sensor.home_so2")
|
entry = registry.async_get("sensor.home_so2")
|
||||||
assert entry
|
assert entry
|
||||||
@ -160,11 +161,19 @@ async def test_sensor(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
state = hass.states.get("sensor.home_aqi")
|
state = hass.states.get("sensor.home_aqi")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "dobry"
|
assert state.state == "good"
|
||||||
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
|
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
|
||||||
assert state.attributes.get(ATTR_STATION) == "Test Name 1"
|
assert state.attributes.get(ATTR_STATION) == "Test Name 1"
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is None
|
assert state.attributes.get(ATTR_STATE_CLASS) is None
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
|
||||||
|
assert state.attributes.get(ATTR_OPTIONS) == [
|
||||||
|
"very_bad",
|
||||||
|
"bad",
|
||||||
|
"sufficient",
|
||||||
|
"moderate",
|
||||||
|
"good",
|
||||||
|
"very_good",
|
||||||
|
]
|
||||||
|
|
||||||
entry = registry.async_get("sensor.home_aqi")
|
entry = registry.async_get("sensor.home_aqi")
|
||||||
assert entry
|
assert entry
|
||||||
@ -342,7 +351,7 @@ async def test_aqi_sensor_availability(hass: HomeAssistant) -> None:
|
|||||||
state = hass.states.get("sensor.home_aqi")
|
state = hass.states.get("sensor.home_aqi")
|
||||||
assert state
|
assert state
|
||||||
assert state.state != STATE_UNAVAILABLE
|
assert state.state != STATE_UNAVAILABLE
|
||||||
assert state.state == "dobry"
|
assert state.state == "good"
|
||||||
|
|
||||||
future = utcnow() + timedelta(minutes=60)
|
future = utcnow() + timedelta(minutes=60)
|
||||||
with patch(
|
with patch(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user