Add Lichess sensors for variants, Ultra Bullet, and correspondence games#171988
Add Lichess sensors for variants, Ultra Bullet, and correspondence games#171988rlrghb wants to merge 4 commits into
Conversation
aiolichess.LichessStatistics has exposed puzzle and correspondence ratings (and puzzle games) since 1.2.0, but the integration only created sensors for the four standard time controls. Surface the existing library fields as three new sensors, disabled by default so existing installations are not flooded with new entities on update. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
aiolichess 1.3.0 exposes rating and games-played counts for every perf returned by /api/account. Add sensors for the missing perfs: - Ultra Bullet (rating + games) - Correspondence games (rating already added in home-assistant#171987) - Chess960, Crazyhouse, Antichess, Atomic, Horde, King of the Hill, Racing Kings, Three-check (rating + games each) All new sensors are disabled by default; users opt in via the entity registry for the perfs they actually play. Bumps aiolichess from 1.2.0 to 1.3.0: aryanhasgithub/aiolichess@1.2.0...1.3.0 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Hey there @aryanhasgithub, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Lichess integration to surface additional variant/time-control statistics as sensors, aligning with updated aiolichess data and extending test coverage via refreshed snapshots.
Changes:
- Bump
aiolichessfrom1.2.0to1.3.0. - Add sensors (and translations/icons) for additional Lichess variants (e.g., UltraBullet, Chess960, Antichess, Atomic, etc.).
- Expand test fixture statistics and update snapshots accordingly.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/lichess/sensor.py |
Adds many new LichessEntityDescription entries to expose additional statistics as sensors. |
homeassistant/components/lichess/strings.json |
Adds translation entries (names/units) for the newly introduced sensors. |
homeassistant/components/lichess/icons.json |
Adds icon mappings for the newly introduced sensors. |
homeassistant/components/lichess/manifest.json |
Updates integration requirement to aiolichess==1.3.0. |
requirements_all.txt |
Updates pinned dependency to aiolichess==1.3.0. |
tests/components/lichess/conftest.py |
Extends mocked LichessStatistics to include new fields required by added sensors. |
tests/components/lichess/snapshots/test_sensor.ambr |
Updates/expands snapshots to include the additional entities and their state. |
| @@ -56,13 +56,35 @@ def mock_lichess_client() -> Generator[AsyncMock]: | |||
| ) | |||
| client.get_user_id.return_value = "drnykterstien" | |||
| LichessEntityDescription( | ||
| key="ultra_bullet_rating", | ||
| translation_key="ultra_bullet_rating", | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| entity_registry_enabled_default=False, | ||
| value_fn=lambda state: state.ultra_bullet_rating, | ||
| ), | ||
| LichessEntityDescription( | ||
| key="ultra_bullet_games", | ||
| translation_key="ultra_bullet_games", | ||
| state_class=SensorStateClass.TOTAL_INCREASING, | ||
| entity_category=EntityCategory.DIAGNOSTIC, | ||
| entity_registry_enabled_default=False, | ||
| value_fn=lambda state: state.ultra_bullet_games, | ||
| ), |
|
Please move correspondence rating here. |
There was a problem hiding this comment.
Please create a separate unit of measurements for the additional ratings and games except the normal 4.
There was a problem hiding this comment.
Done in 3edca40 — inlined "games" as the literal unit_of_measurement on every new *_games entry (ultra_bullet, correspondence, chess960, crazyhouse, antichess, atomic, horde, king_of_the_hill, racing_kings, three_check). The four standards (blitz/rapid/classical still referencing bullet_games, plus bullet_games itself) are left alone as you indicated.
…icon, decouple unit, fix test typo - Remove the correspondence_rating sensor so it lands in home-assistant#171988 alongside the rest of the correspondence-perf surface (per code owner request). - Use mdi:puzzle for puzzle_games so it stays visually distinct from the other *_games sensors that share mdi:chess-pawn. - Inline "games" as puzzle_games' unit_of_measurement instead of referencing bullet_games' translation key, removing the implicit cross-entity coupling. - Rename the test fixture's player id from "drnykterstien" to "drnykterstein" so unique_ids match the canonical username used everywhere else in the tests. Pure test-data fix — production unique_ids come from the Lichess API. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror the puzzle_games icon swap, the unit_of_measurement decoupling, and the drnykterstien->drnykterstein test-fixture rename from home-assistant#171987 so the end-state of the lichess integration is identical regardless of merge order. correspondence_rating stays on this branch per code owner request. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
|
v1.3.0 is released. |
|
@home-assistant ready-for-review |
| }, | ||
| "puzzle_games": { | ||
| "name": "Puzzle games", | ||
| "unit_of_measurement": "games" |
| LichessEntityDescription( | ||
| key="ultra_bullet_rating", | ||
| translation_key="ultra_bullet_rating", | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| entity_registry_enabled_default=False, | ||
| value_fn=lambda state: state.ultra_bullet_rating, | ||
| ), | ||
| LichessEntityDescription( | ||
| key="ultra_bullet_games", | ||
| translation_key="ultra_bullet_games", | ||
| state_class=SensorStateClass.TOTAL_INCREASING, | ||
| entity_category=EntityCategory.DIAGNOSTIC, | ||
| entity_registry_enabled_default=False, | ||
| value_fn=lambda state: state.ultra_bullet_games, | ||
| ), |
Per code-owner request on home-assistant#171988: inline "games" as the literal unit_of_measurement on every new *_games translation entry (ultra_bullet, correspondence, chess960, crazyhouse, antichess, atomic, horde, king_of_the_hill, racing_kings, three_check) so none of the additions depend on bullet_games' translation key. The four original time-control entries (blitz/rapid/classical referencing bullet_games' literal "games") are intentionally left unchanged to keep this PR scoped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Proposed change
Add rating and games-played sensors for every remaining perf returned by Lichess's GET /api/account endpoint:
All 17 new sensors are registered with
entity_registry_enabled_default=Falseso existing installs aren't surprised with a flood of new entities — users opt in only for the perfs they care about.Dependency upgrade
Bumps
aiolichessfrom 1.2.0 to 1.3.0. Diff: aryanhasgithub/aiolichess@1.2.0...1.3.0The 1.3.0 bump is purely additive — existing
LichessStatisticsfields keep their names and types. The new release adds rating/games fields for every perf the account endpoint returns. See aryanhasgithub/aiolichess#1 for the source change.Type of change
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running: `python3 -m script.hassfest`.
Updated by running `python3 -m script.gen_requirements_all`.
To help with the load of incoming pull requests: