fix: handle undated Lichfield collection cards - #2179
Conversation
📝 WalkthroughWalkthroughLichfield’s parser now processes each collection card independently, calculates explicit and weekday-based dates relative to the current date, preserves the ChangesLichfield parser behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Hi @robbrad, this is ready for review. The fix has been validated against the live Lichfield site and in Home Assistant, including the Food Waste and Purple Bin collection dates. The fork workflows are currently awaiting maintainer approval. When you have a chance, could you please approve the workflows and review the PR? Thanks. |
|
@JasSmiths thanks mate I'll get to it this weekend |
|
Thanks for the detailed writeup and tests on this — the synthetic-weekday-date approach for the dateless Food Waste card and the year-rollover fix were both good catches. #2187 fixed the same underlying bug independently (card-scoped heading/date pairing), so rather than pick one over the other I synthesized both into a single fix in the consolidated "July Part 2" release: #2189. It keeps your weekly-frequency fallback and year-rollover fix, combined with #2187's cleaner heading-text extraction (stripping the visually-hidden spans instead of slicing words). Your regression tests are included too. Closing this one out — credited in the PR. Generated by Claude Code |
LichfieldDistrictCouncil zipped a page-wide heading list and a page-wide date list together by index. Two things on the current page break that: the calendar-download link reuses the heading class but has no date, and a bin with no scheduled collection (Food Waste Caddy) renders a "Collected every <day>" frequency instead of a date. Either one shifts every later bin onto the wrong date and drops the last bin. Iterate each card and read its own date instead of pairing by position. When a card has no date but does have a weekly frequency, derive the next occurrence of that weekday so the entity keeps reporting (previously it silently inherited a neighboring bin's date). Extract the bin name by removing the visually-hidden heading spans rather than slicing words, so three-word names like "Food Waste Caddy" survive; that value is then mapped back to "Food Waste" to preserve the existing Home Assistant entity identity. Also fix year rollover to compare against today's date directly instead of a month heuristic. Synthesizes PR robbrad#2179 by JasSmiths and PR robbrad#2187 by alec-pinson, which independently reported and fixed this bug.
Summary
Food Wastebin type used by Home Assistant entitiesRoot cause
Lichfield added a Food Waste Caddy card that contains a weekly collection weekday but no
bin-collection-tasks__dateelement. The scraper collected all headings and all dates into separate lists and paired them by position. The undated card shifted every subsequent date onto the wrong bin and omitted the final dated bin.Impact
Collection dates remain attached to their own cards, so Brown, Blue, Black, and Purple Bin data is returned correctly. The weekly Food Waste collection is also exposed without changing its existing entity identity.
Validation
Summary by CodeRabbit
Bug Fixes
Tests