Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error fetching Yandex Weather updater data: 'prec_mm' #70

Closed
4 tasks done
DieMetRik opened this issue Mar 31, 2023 · 9 comments
Closed
4 tasks done

Unexpected error fetching Yandex Weather updater data: 'prec_mm' #70

DieMetRik opened this issue Mar 31, 2023 · 9 comments
Labels
bug Something isn't working work in progress We a working on it

Comments

@DieMetRik
Copy link

DieMetRik commented Mar 31, 2023

В чем проблема?

Эта ошибка возникла в кастомной интеграции.

Logger: custom_components.yandex_weather.updater
Source: custom_components/yandex_weather/updater.py:240
Integration: Яндекс.Погода (documentation, issues)
First occurred: 21:58:57 (3 occurrences)
Last logged: 22:55:25

Unexpected error fetching Yandex Weather updater data: 'prec_mm'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/yandex_weather/updater.py", line 240, in update
    forecast[ATTR_FORECAST_NATIVE_PRECIPITATION] = f["prec_mm"]  # type: ignore
KeyError: 'prec_mm'

При использовании какой версии интеграции возникает проблема?

v2.0.2

Какая версия Home Assistant используется?

2023.3.6

Какой способ установки Home Assistant используется?

Home Assistant Supervised

Самопроверка по созданию ключа

  • при добавлении ключа в кабинете разработчика он добавлялся как "тестовый"
  • тип ключа в кабинете разработчика был изменен на "погода для сайта"
  • после изменения типа ключа прошло не менее 20 минут
  • в кабинете разработчка я вижу что с запросы делаются именно с этим ключом

Есть что-нибудь полезное в логе?

No response

Дополнительная информация

No response

@heggi
Copy link

heggi commented Mar 31, 2023

Аналогичная проблема. Яндекс в ответе возвращает вот такое:

{
  "now": 1680292232,
  "now_dt": "2023-03-31T19:50:32.792147Z",
  "info": {
    "url": "xxxxx",
    "lat": xxxx,
    "lon": xxxx
  },
  "fact": {
    "obs_time": 1680289200,
    "temp": 3,
    "feels_like": -1,
    "icon": "ovc",
    "condition": "overcast",
    "wind_speed": 2.5,
    "wind_dir": "n",
    "pressure_mm": 751,
    "pressure_pa": 1001,
    "humidity": 75,
    "daytime": "n",
    "polar": false,
    "season": "spring",
    "wind_gust": 5.6
  },
  "forecast": {
    "date": "2023-04-01",
    "date_ts": 1680292800,
    "week": 13,
    "sunrise": "06:14",
    "sunset": "19:12",
    "moon_code": 13,
    "moon_text": "moon-code-13",
    "parts": [
      {
        "part_name": "night",
        "temp_min": 1,
        "temp_avg": 2,
        "temp_max": 4,
        "wind_speed": 2.9,
        "wind_gust": 6.7,
        "wind_dir": "s",
        "pressure_mm": 751,
        "pressure_pa": 1001,
        "humidity": 77,
        "prec_mm": 0,
        "prec_prob": 0,
        "prec_period": 480,
        "icon": "bkn_n",
        "condition": "cloudy",
        "feels_like": -2,
        "daytime": "n",
        "polar": false
      },
      {
        "part_name": "morning",
        "temp_min": 1,
        "temp_avg": 2,
        "temp_max": 4,
        "wind_speed": 4.5,
        "wind_gust": 8.9,
        "wind_dir": "s",
        "pressure_mm": 751,
        "pressure_pa": 1001,
        "humidity": 75,
        "prec_period": 360,
        "icon": "bkn_d",
        "condition": "cloudy",
        "feels_like": -3,
        "daytime": "d",
        "polar": false
      }
    ]
  }
}

В объекте forecast.parts[1] отсутствуют поля prec_mm и prec_prob
У себя пока запатчил код заменой вызовов
f["prec_mm"] на f.get("prec_mm", 0)
f["prec_prob"] на f.get("prec_prob", 0)

@scaytrase
Copy link

угу. тоже самое, обновился на 2.0.2, получил в логе

Logger: homeassistant.components.weather
Source: helpers/update_coordinator.py:211
Integration: Weather (documentation, issues)
First occurred: 01:44:40 (4 occurrences)
Last logged: 01:48:47

Error adding entities for domain weather with platform yandex_weather
Error while setting up yandex_weather platform for weather
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/yandex_weather/updater.py", line 240, in update
    forecast[ATTR_FORECAST_NATIVE_PRECIPITATION] = f["prec_mm"]  # type: ignore
KeyError: 'prec_mm'

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 717, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 806, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/yandex_weather/weather.py", line 110, in async_added_to_hass
    await self.coordinator.async_config_entry_first_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 211, in async_config_entry_first_refresh
    raise ex
homeassistant.exceptions.ConfigEntryNotReady: 'prec_mm'

но судя по истории статусов отвалилось часа 4 назад, до обновления

@popovr
Copy link

popovr commented Mar 31, 2023

С вечера 2023.03.31 аналогичный
KeyError: 'prec_mm'

@falkongm
Copy link

falkongm commented Apr 1, 2023

Аналогично появилась ошибка после обновления на 2.0.2

Logger: custom_components.yandex_weather.updater
Source: custom_components/yandex_weather/updater.py:240
Integration: Яндекс.Погода (documentation, issues)
First occurred: 31 марта 2023 г. в 21:58:58 (25 occurrences)
Last logged: 08:50:01

Unexpected error fetching Yandex Weather updater data: 'prec_mm'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/yandex_weather/updater.py", line 240, in update
    forecast[ATTR_FORECAST_NATIVE_PRECIPITATION] = f["prec_mm"]  # type: ignore
KeyError: 'prec_mm'

@bisquit2003
Copy link

такая же проблема, недоступна погода...

@alexanderznamensky
Copy link

alexanderznamensky commented Apr 1, 2023

Мне кажется, что тут дело не в обновлении. откатился на 2.0.1 - тоже самое.
Возможно, Яндекс опять что-то сломал / ограничил. В последнее время они очень стали много всего обрезать (транспорт, карты....)

UPD:
Предложенный вариант heggi работает.
В файле \Your instance URL\config\custom_components\yandex_weather\updater.py меняем:
f["prec_mm"] на f.get("prec_mm", 0)
f["prec_prob"] на f.get("prec_prob", 0)
Потом нужно перегрузиться.

Да, и еще (для Игоря) у меня за несколько часов интеграция съела все 50 запросов от Яндекса. Похоже, что когда возникает подобная ошибка, интеграция ломится в Яндекс и сжирает весь лимит 50 запросов в день.

@mexpetrov
Copy link

alexanderznamensky

замена помогла, сейчас погода отображается

@IATkachenko
Copy link
Owner

Ухх...
Обожаю обновления в ночь на субботу...

@IATkachenko IATkachenko added bug Something isn't working work in progress We a working on it labels Apr 1, 2023
@IATkachenko IATkachenko pinned this issue Apr 1, 2023
@IATkachenko
Copy link
Owner

Исправлено в v2.0.3.

Извините что такое вылезло...
Еще один повод пересмотреть код updater'a...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working work in progress We a working on it
Projects
None yet
Development

No branches or pull requests

9 participants