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:
Askarov Rishat 2019-10-14 11:12:08 +03:00 committed by Martin Hjelmare
parent da29c1125f
commit ff4e35e0ad
6 changed files with 1577 additions and 2120 deletions

View file

@ -3,7 +3,7 @@
"name": "Yandex Transport",
"documentation": "https://www.home-assistant.io/integrations/yandex_transport",
"requirements": [
"ya_ma==0.3.7"
"ya_ma==0.3.8"
],
"dependencies": [],
"codeowners": [

View file

@ -79,18 +79,21 @@ class DiscoverMoscowYandexTransport(Entity):
transport_list = stop_metadata["Transport"]
for transport in transport_list:
route = transport["name"]
if self._routes and route not in self._routes:
# skip unnecessary route info
continue
if "Events" in transport["BriefSchedule"]:
for event in transport["BriefSchedule"]["Events"]:
if "Estimated" in event:
posix_time_next = int(event["Estimated"]["value"])
if closer_time is None or closer_time > posix_time_next:
closer_time = posix_time_next
if route not in attrs:
attrs[route] = []
attrs[route].append(event["Estimated"]["text"])
for thread in transport["threads"]:
if self._routes and route not in self._routes:
# skip unnecessary route info
continue
if "Events" not in thread["BriefSchedule"]:
continue
for event in thread["BriefSchedule"]["Events"]:
if "Estimated" not in event:
continue
posix_time_next = int(event["Estimated"]["value"])
if closer_time is None or closer_time > posix_time_next:
closer_time = posix_time_next
if route not in attrs:
attrs[route] = []
attrs[route].append(event["Estimated"]["text"])
attrs[STOP_NAME] = stop_name
attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
if closer_time is None:

View file

@ -1996,7 +1996,7 @@ xmltodict==0.12.0
xs1-api-client==2.3.5
# homeassistant.components.yandex_transport
ya_ma==0.3.7
ya_ma==0.3.8
# homeassistant.components.yweather
yahooweather==0.10

View file

@ -626,7 +626,7 @@ withings-api==2.0.0b8
xmltodict==0.12.0
# homeassistant.components.yandex_transport
ya_ma==0.3.7
ya_ma==0.3.8
# homeassistant.components.yweather
yahooweather==0.10

View file

@ -38,14 +38,14 @@ TEST_CONFIG = {
}
FILTERED_ATTRS = {
"т36": ["21:43", "21:47", "22:02"],
"т47": ["21:40", "22:01"],
"м10": ["21:48", "22:00"],
"т36": ["16:10", "16:17", "16:26"],
"т47": ["16:09", "16:10"],
"м10": ["16:12", "16:20"],
"stop_name": "7-й автобусный парк",
"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):

File diff suppressed because it is too large Load diff