Skip to content

Commit 525c8a2

Browse files
committed
add bin type friendly
1 parent 5c86ca7 commit 525c8a2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

custom_components/greyhound_bin/api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import async_timeout
1212
from bs4 import BeautifulSoup, Tag
1313

14-
from .const import CALENDAR_URL, LOGIN_URL
14+
from .const import BIN_DESCRIPTIONS, CALENDAR_URL, LOGIN_URL
1515

1616
_LOGGER = logging.getLogger(__name__)
1717

@@ -184,6 +184,9 @@ async def async_get_data(self) -> dict[str, Any]:
184184
summary = {
185185
"next_collection_date": next_event["date"].isoformat(),
186186
"bin_types": ", ".join(next_event["bins"]),
187+
"bin_types_friendly": ", ".join(
188+
BIN_DESCRIPTIONS[bin_type] for bin_type in next_event["bins"]
189+
),
187190
"days_until_collection": days_until,
188191
"collection_status": (
189192
"Today"

custom_components/greyhound_bin/sensor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def available(self) -> bool: # type: ignore
123123
def extra_state_attributes(self): # type: ignore
124124
"""Return the next collection date per bin type."""
125125

126+
# Case 1: next_bin_collections → dictionary of bin type friendly names and dates
126127
if self.entity_description.key == "next_bin_collections":
127128
events = self.coordinator.data.get("events", [])
128129
next_dates = {}
@@ -135,3 +136,14 @@ def extra_state_attributes(self): # type: ignore
135136
].isoformat()
136137

137138
return {"next_bin_collections": next_dates}
139+
140+
# Case 2: bin_types → add bin_types_friendly attribute
141+
if self.entity_description.key == "bin_types":
142+
return {
143+
"bin_types_friendly": self.coordinator.data.get("sensors", {}).get(
144+
"bin_types_friendly"
145+
)
146+
}
147+
148+
# All other sensors → no extra attributes
149+
return None

0 commit comments

Comments
 (0)