mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Guard for when Yandex Transport data fetching fails (#40131)
This commit is contained in:
parent
abca177894
commit
8dde59be02
@ -60,7 +60,7 @@ class DiscoverYandexTransport(Entity):
|
|||||||
self._name = name
|
self._name = name
|
||||||
self._attrs = None
|
self._attrs = None
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self, *, tries=0):
|
||||||
"""Get the latest data from maps.yandex.ru and update the states."""
|
"""Get the latest data from maps.yandex.ru and update the states."""
|
||||||
attrs = {}
|
attrs = {}
|
||||||
closer_time = None
|
closer_time = None
|
||||||
@ -73,8 +73,12 @@ class DiscoverYandexTransport(Entity):
|
|||||||
key_error,
|
key_error,
|
||||||
yandex_reply,
|
yandex_reply,
|
||||||
)
|
)
|
||||||
|
if tries > 0:
|
||||||
|
return
|
||||||
await self.requester.set_new_session()
|
await self.requester.set_new_session()
|
||||||
data = (await self.requester.get_stop_info(self._stop_id))["data"]
|
await self.async_update(tries=tries + 1)
|
||||||
|
return
|
||||||
|
|
||||||
stop_name = data["name"]
|
stop_name = data["name"]
|
||||||
transport_list = data["transports"]
|
transport_list = data["transports"]
|
||||||
for transport in transport_list:
|
for transport in transport_list:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user