File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
custom_components/greyhound_bin Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 11
11
import async_timeout
12
12
from bs4 import BeautifulSoup , Tag
13
13
14
- from .const import CALENDAR_URL , LOGIN_URL
14
+ from .const import BIN_DESCRIPTIONS , CALENDAR_URL , LOGIN_URL
15
15
16
16
_LOGGER = logging .getLogger (__name__ )
17
17
@@ -184,6 +184,9 @@ async def async_get_data(self) -> dict[str, Any]:
184
184
summary = {
185
185
"next_collection_date" : next_event ["date" ].isoformat (),
186
186
"bin_types" : ", " .join (next_event ["bins" ]),
187
+ "bin_types_friendly" : ", " .join (
188
+ BIN_DESCRIPTIONS [bin_type ] for bin_type in next_event ["bins" ]
189
+ ),
187
190
"days_until_collection" : days_until ,
188
191
"collection_status" : (
189
192
"Today"
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ def available(self) -> bool: # type: ignore
123
123
def extra_state_attributes (self ): # type: ignore
124
124
"""Return the next collection date per bin type."""
125
125
126
+ # Case 1: next_bin_collections → dictionary of bin type friendly names and dates
126
127
if self .entity_description .key == "next_bin_collections" :
127
128
events = self .coordinator .data .get ("events" , [])
128
129
next_dates = {}
@@ -135,3 +136,14 @@ def extra_state_attributes(self): # type: ignore
135
136
].isoformat ()
136
137
137
138
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
You can’t perform that action at this time.
0 commit comments