Skip to content

Commit f8ac978

Browse files
committed
Revert to default API dates for baseball
1 parent 0f83b4f commit f8ac978

7 files changed

Lines changed: 17 additions & 17 deletions

File tree

custom_components/teamtracker/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199

200200
# Misc
201201
TEAM_ID = ""
202-
VERSION = "v0.17.7"
202+
VERSION = "v0.17.8-beta.1"
203203
ISSUE_URL = "https://github.com/vasqued2/ha-teamtracker"
204204
DOMAIN = "teamtracker"
205205
COORDINATOR = "coordinator"

custom_components/teamtracker/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"iot_class": "cloud_polling",
99
"issue_tracker": "https://github.com/vasqued2/ha-teamtracker/issues",
1010
"requirements": ["arrow", "aiofiles"],
11-
"version": "0.17.7"
11+
"version": "0.17.8-beta.1"
1212
}

custom_components/teamtracker/provide_espn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ async def _async_fetch_scoreboard_data(self, hass, lang) -> dict:
155155
url_parms["lang"] = lang[:2]
156156
url_parms["limit"] = str(API_LIMIT)
157157

158-
if sport_path not in ("tennis"):
158+
if sport_path not in ("tennis", "baseball"):
159159
d1 = (date.today() - timedelta(days=1)).strftime("%Y%m%d")
160160
if league_path == "all":
161161
d2 = (date.today() + timedelta(days=5)).strftime("%Y%m%d")
162-
elif sport_path in ("baseball"):
163-
d2 = (date.today() + timedelta(days=1)).strftime("%Y%m%d")
162+
# elif sport_path in ("baseball"):
163+
# d2 = (date.today() + timedelta(days=1)).strftime("%Y%m%d")
164164
else:
165165
d2 = (date.today() + timedelta(days=90)).strftime("%Y%m%d")
166166
url_parms["dates"] = f"{d1}-{d2}"

custom_components/teamtracker/provide_mlbstats.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" Provide response from MLBSTATS APIs """
22
from __future__ import annotations
33

4-
from datetime import date, timedelta
4+
from datetime import timedelta
55
import json
66
import logging
77
from typing import TYPE_CHECKING
@@ -179,13 +179,13 @@ async def _async_fetch_scoreboard_data(self, hass, lang) -> dict:
179179
# If the game from the prior call was not live, get the schedule of games
180180
if self.live_game_pk is None:
181181
url = f"{MLBSTATS_BASE_URL}/v1/schedule/games"
182-
yesterday = (date.today() - timedelta(days=1)).isoformat()
183-
tomorrow = (date.today() + timedelta(days=1)).isoformat()
182+
# yesterday = (date.today() - timedelta(days=1)).isoformat()
183+
# tomorrow = (date.today() + timedelta(days=1)).isoformat()
184184

185185
url_parms = {
186186
"sportId": sportId,
187-
"startDate": yesterday,
188-
"endDate": tomorrow,
187+
# "startDate": yesterday,
188+
# "endDate": tomorrow,
189189
}
190190

191191
response = await self.async_call_mlbstats_api(hass, url, url_parms, sensor_name, team_id)

tests/__snapshots__/test_mlbstats.ambr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# name: test_mlbstats[api_error_invalid_league]
33
dict({
44
'api_message': None,
5-
'api_url': 'https://statsapi.mlb.com/api/v1/schedule/games?sportId=UNKNOWN_SPORTID&startDate=2026-05-22&endDate=2026-05-24',
5+
'api_url': 'https://statsapi.mlb.com/api/v1/schedule/games?sportId=UNKNOWN_SPORTID',
66
'attribution': 'Copyright 2026 MLB Advanced Media',
77
'balls': None,
88
'clock': 'Final',
@@ -170,7 +170,7 @@
170170
# name: test_mlbstats[test_invalid_team]
171171
dict({
172172
'api_message': "No competition scheduled for 'INVALID_TEAM_ID' in MLB Stats between 2026-05-30T00:00Z and 2026-05-30T00:00Z",
173-
'api_url': 'https://statsapi.mlb.com/api/v1/schedule/games?sportId=11&startDate=2026-05-22&endDate=2026-05-24',
173+
'api_url': 'https://statsapi.mlb.com/api/v1/schedule/games?sportId=11',
174174
'attribution': 'Copyright 2026 MLB Advanced Media',
175175
'balls': None,
176176
'clock': None,
@@ -248,7 +248,7 @@
248248
# name: test_mlbstats[test_post]
249249
dict({
250250
'api_message': None,
251-
'api_url': 'https://statsapi.mlb.com/api/v1/schedule/games?sportId=11&startDate=2026-05-22&endDate=2026-05-24',
251+
'api_url': 'https://statsapi.mlb.com/api/v1/schedule/games?sportId=11',
252252
'attribution': 'Copyright 2026 MLB Advanced Media',
253253
'balls': None,
254254
'clock': 'Final',
@@ -332,7 +332,7 @@
332332
# name: test_mlbstats[test_pre]
333333
dict({
334334
'api_message': None,
335-
'api_url': 'https://statsapi.mlb.com/api/v1/schedule/games?sportId=11&startDate=2026-05-22&endDate=2026-05-24',
335+
'api_url': 'https://statsapi.mlb.com/api/v1/schedule/games?sportId=11',
336336
'attribution': 'Copyright 2026 MLB Advanced Media',
337337
'balls': None,
338338
'clock': 'Scheduled',

tests/test_init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ async def test_setup_second_team_in_league(
245245
date = sensor_state.attributes.get("date")
246246
assert date == "2022-09-08T22:45Z"
247247
api_url = sensor_state.attributes.get("api_url")
248-
assert api_url == "https://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard?lang=en&limit=50&dates=20260320-20260322&groups=9999"
248+
assert api_url == "https://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard?lang=en&limit=50&groups=9999"
249249
api_message = sensor_state.attributes.get("api_message")
250250
assert api_message == None
251251

@@ -283,7 +283,7 @@ async def test_setup_second_team_in_league(
283283
date = sensor_state.attributes.get("date")
284284
assert date == "2022-09-08T18:20Z"
285285
api_url = sensor_state.attributes.get("api_url")
286-
assert api_url == "https://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard?lang=en&limit=50&dates=20260320-20260322&groups=9999"
286+
assert api_url == "https://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard?lang=en&limit=50&groups=9999"
287287
api_message = sensor_state.attributes.get("api_message")
288288
assert api_message == "Cached data"
289289

tests/test_sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async def test_sensor(hass, mock_call_espn_api, mocker):
6363
date = sensor_state.attributes.get("date")
6464
assert date == "2022-09-08T22:45Z"
6565
api_url = sensor_state.attributes.get("api_url")
66-
assert api_url == "https://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard?lang=en&limit=50&dates=20260320-20260322&groups=9999"
66+
assert api_url == "https://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard?lang=en&limit=50&groups=9999"
6767
api_message = sensor_state.attributes.get("api_message")
6868
assert api_message == None
6969

0 commit comments

Comments
 (0)