Skip to content

Commit

Permalink
Add long_name attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
vasqued2 committed Jan 25, 2025
1 parent a10b438 commit 2ab5997
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions custom_components/teamtracker/clear_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async def async_clear_values() -> dict:
"odds": None,
"overunder": None,
"team_name": None,
"team_long_name": None,
"team_id": None,
"team_record": None,
"team_rank": None,
Expand All @@ -35,6 +36,7 @@ async def async_clear_values() -> dict:
"team_winner": None,
"team_timeouts": None,
"opponent_name": None,
"opponent_long_name": None,
"opponent_id": None,
"opponent_record": None,
"opponent_rank": None,
Expand Down
4 changes: 4 additions & 0 deletions custom_components/teamtracker/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry, config: ConfigType)
self._overunder = None

self._team_name = None
self._team_long_name = None
self._team_id = None
self._team_record = None
self._team_rank = None
Expand All @@ -225,6 +226,7 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry, config: ConfigType)
self._team_timeouts = None

self._opponent_name = None
self._opponent_long_name = None
self._opponent_id = None
self._opponent_record = None
self._opponent_rank = None
Expand Down Expand Up @@ -317,6 +319,7 @@ def extra_state_attributes(self) -> dict[str, Any]:
attrs["overunder"] = self.coordinator.data["overunder"]

attrs["team_name"] = self.coordinator.data["team_name"]
attrs["team_long_name"] = self.coordinator.data["team_long_name"]
attrs["team_id"] = self.coordinator.data["team_id"]
attrs["team_record"] = self.coordinator.data["team_record"]
attrs["team_rank"] = self.coordinator.data["team_rank"]
Expand All @@ -331,6 +334,7 @@ def extra_state_attributes(self) -> dict[str, Any]:
attrs["team_timeouts"] = self.coordinator.data["team_timeouts"]

attrs["opponent_name"] = self.coordinator.data["opponent_name"]
attrs["opponent_long_name"] = self.coordinator.data["opponent_long_name"]
attrs["opponent_id"] = self.coordinator.data["opponent_id"]
attrs["opponent_record"] = self.coordinator.data["opponent_record"]
attrs["opponent_rank"] = self.coordinator.data["opponent_rank"]
Expand Down
16 changes: 16 additions & 0 deletions custom_components/teamtracker/set_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ async def async_set_universal_values(
default=await async_get_value(competitor, "roster", "shortDisplayName")
),
)
new_values["team_long_name"] = await async_get_value(
competitor,
"team",
"displayName",
default=await async_get_value(competitor, "athlete", "displayName",
default=await async_get_value(competitor, "roster", "DisplayName")
),
)
new_values["opponent_name"] = await async_get_value(
opponent,
"team",
Expand All @@ -279,6 +287,14 @@ async def async_set_universal_values(
default=await async_get_value(opponent, "roster", "shortDisplayName"),
),
)
new_values["opponent_long_name"] = await async_get_value(
opponent,
"team",
"displayName",
default=await async_get_value(opponent, "athlete", "displayName",
default=await async_get_value(opponent, "roster", "DisplayName")
),
)

new_values["team_record"] = await async_get_value(
competitor, "records", 0, "summary"
Expand Down

0 comments on commit 2ab5997

Please sign in to comment.