sebcaps / atmofrance

About Home assistant component to get air quality for french cities
MIT License
7 stars 3 forks source link

StopIteration quand il n'y a pas de donnée pour le jour #18

Open lhochet opened 8 months ago

lhochet commented 8 months ago

extrait du debug log:

2024-01-31 22:38:11.085 DEBUG (MainThread) [custom_components.atmofrance.api] Getting data from https://admindata.atmo-france.org/api/data/112/{"code_zone":{"operator":"=","value":"37261"},"date_ech":{"operator":">=","value":"2024-01-31"}}?withGeom=false
2024-01-31 22:38:13.949 DEBUG (MainThread) [custom_components.atmofrance.api] Got response {'type': 'FeatureCollection', 'name': 'national_data.national_ind_atmo', 'crs': {'type': 'name', 'properties': {'name': 'urn:ogc:def:crs:EPSG::3857'}}, 'features': [{'type': 'Feature', 'properties': {'gml_id': 884738069, 'aasqa': '24', 'date_maj': '2024/01/31 13:30:55.965+01', 'partition_field': '242024w5', 'code_no2': 1, 'code_o3': 1, 'code_pm10': 2, 'code_pm25': 3, 'code_qual': 3, 'code_so2': 1, 'code_zone': '37261', 'coul_qual': '#f0e641', 'date_dif': '2024/01/31', 'date_ech': '2024-02-01', 'epsg_reg': '2154', 'lib_qual': 'Dégradé', 'lib_zone': 'TOURS', 'source': "Lig'Air", 'type_zone': 'COMMUNE', 'x_reg': 526257.299840776, 'x_wgs84': 0.696174928815865, 'y_reg': 6702367.07491042, 'y_wgs84': 47.3988426088866}, 'geometry': None}]} 
2024-01-31 22:38:13.950 DEBUG (MainThread) [custom_components.atmofrance.api] Extracting data for INSEE 37261 and date 2024-01-31
2024-01-31 22:38:13.951 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Atmo France - Tours for atmofrance
Traceback (most recent call last):
  File "/config/custom_components/atmofrance/api.py", line 70, in get_data
    self._data = next(
                 ^^^^^
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 406, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/atmofrance/__init__.py", line 37, in async_setup_entry
    databycity = await api.get_data(entry.data[CONF_INSEE_CODE])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: coroutine raised StopIteration

Le site Atmo France indiquait également que les données étaient indisponibles pour le 31.