mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Update yandex transport after api change (#27591)
* yandex maps api changed ("threads" in "Transport" added), ya_ma=>0.3.8 bug_fixed * Update homeassistant/components/yandex_transport/sensor.py Co-Authored-By: Paulus Schoutsen <paulus@home-assistant.io> * additional fix * reformat * fix mistake
This commit is contained in:
parent
da29c1125f
commit
ff4e35e0ad
@ -3,7 +3,7 @@
|
|||||||
"name": "Yandex Transport",
|
"name": "Yandex Transport",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/yandex_transport",
|
"documentation": "https://www.home-assistant.io/integrations/yandex_transport",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"ya_ma==0.3.7"
|
"ya_ma==0.3.8"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": [
|
"codeowners": [
|
||||||
|
@ -79,18 +79,21 @@ class DiscoverMoscowYandexTransport(Entity):
|
|||||||
transport_list = stop_metadata["Transport"]
|
transport_list = stop_metadata["Transport"]
|
||||||
for transport in transport_list:
|
for transport in transport_list:
|
||||||
route = transport["name"]
|
route = transport["name"]
|
||||||
if self._routes and route not in self._routes:
|
for thread in transport["threads"]:
|
||||||
# skip unnecessary route info
|
if self._routes and route not in self._routes:
|
||||||
continue
|
# skip unnecessary route info
|
||||||
if "Events" in transport["BriefSchedule"]:
|
continue
|
||||||
for event in transport["BriefSchedule"]["Events"]:
|
if "Events" not in thread["BriefSchedule"]:
|
||||||
if "Estimated" in event:
|
continue
|
||||||
posix_time_next = int(event["Estimated"]["value"])
|
for event in thread["BriefSchedule"]["Events"]:
|
||||||
if closer_time is None or closer_time > posix_time_next:
|
if "Estimated" not in event:
|
||||||
closer_time = posix_time_next
|
continue
|
||||||
if route not in attrs:
|
posix_time_next = int(event["Estimated"]["value"])
|
||||||
attrs[route] = []
|
if closer_time is None or closer_time > posix_time_next:
|
||||||
attrs[route].append(event["Estimated"]["text"])
|
closer_time = posix_time_next
|
||||||
|
if route not in attrs:
|
||||||
|
attrs[route] = []
|
||||||
|
attrs[route].append(event["Estimated"]["text"])
|
||||||
attrs[STOP_NAME] = stop_name
|
attrs[STOP_NAME] = stop_name
|
||||||
attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
|
attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
|
||||||
if closer_time is None:
|
if closer_time is None:
|
||||||
|
@ -1996,7 +1996,7 @@ xmltodict==0.12.0
|
|||||||
xs1-api-client==2.3.5
|
xs1-api-client==2.3.5
|
||||||
|
|
||||||
# homeassistant.components.yandex_transport
|
# homeassistant.components.yandex_transport
|
||||||
ya_ma==0.3.7
|
ya_ma==0.3.8
|
||||||
|
|
||||||
# homeassistant.components.yweather
|
# homeassistant.components.yweather
|
||||||
yahooweather==0.10
|
yahooweather==0.10
|
||||||
|
@ -626,7 +626,7 @@ withings-api==2.0.0b8
|
|||||||
xmltodict==0.12.0
|
xmltodict==0.12.0
|
||||||
|
|
||||||
# homeassistant.components.yandex_transport
|
# homeassistant.components.yandex_transport
|
||||||
ya_ma==0.3.7
|
ya_ma==0.3.8
|
||||||
|
|
||||||
# homeassistant.components.yweather
|
# homeassistant.components.yweather
|
||||||
yahooweather==0.10
|
yahooweather==0.10
|
||||||
|
@ -38,14 +38,14 @@ TEST_CONFIG = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FILTERED_ATTRS = {
|
FILTERED_ATTRS = {
|
||||||
"т36": ["21:43", "21:47", "22:02"],
|
"т36": ["16:10", "16:17", "16:26"],
|
||||||
"т47": ["21:40", "22:01"],
|
"т47": ["16:09", "16:10"],
|
||||||
"м10": ["21:48", "22:00"],
|
"м10": ["16:12", "16:20"],
|
||||||
"stop_name": "7-й автобусный парк",
|
"stop_name": "7-й автобусный парк",
|
||||||
"attribution": "Data provided by maps.yandex.ru",
|
"attribution": "Data provided by maps.yandex.ru",
|
||||||
}
|
}
|
||||||
|
|
||||||
RESULT_STATE = dt_util.utc_from_timestamp(1568659253).isoformat(timespec="seconds")
|
RESULT_STATE = dt_util.utc_from_timestamp(1570972183).isoformat(timespec="seconds")
|
||||||
|
|
||||||
|
|
||||||
async def assert_setup_sensor(hass, config, count=1):
|
async def assert_setup_sensor(hass, config, count=1):
|
||||||
|
3654
tests/fixtures/yandex_transport_reply.json
vendored
3654
tests/fixtures/yandex_transport_reply.json
vendored
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user