Skip to content

Add issue sensors to Overseerr integration#158888

Merged
joostlek merged 6 commits intohome-assistant:devfrom
AmGarera:feature/overseerr-issue-sensors
Dec 16, 2025
Merged

Add issue sensors to Overseerr integration#158888
joostlek merged 6 commits intohome-assistant:devfrom
AmGarera:feature/overseerr-issue-sensors

Conversation

@AmGarera
Copy link
Copy Markdown
Contributor

@AmGarera AmGarera commented Dec 13, 2025

Description

This PR adds 6 new sensors to track issue statistics in Overseerr. This is the first part of comprehensive issue management functionality - service actions will be added in a separate PR per review guidelines.

Note: This PR is now based on #158924 and depends on it being merged first.

Changes

New Sensors

  • Total issues
  • Open issues
  • Closed issues
  • Video issues
  • Audio issues
  • Subtitle issues

Technical Changes

  • Created models.py with OverseerrData composite model containing both RequestCount and IssueCount
  • Updated coordinator.py to fetch both request and issue counts in single update cycle
  • Modified sensor.py to use composite data model (data.requests.* and data.issues.*)
  • Added ISSUES constant to const.py
  • Added webhook support for issue notification types (ISSUE_REPORTED, ISSUE_COMMENTED, ISSUE_RESOLVED, ISSUE_REOPENED)
  • Added sensor translations to strings.json

Dependencies

Type of change

  • New integration
  • New feature for existing integration
  • Bugfix for existing integration
  • Breaking change
  • Code quality improvements

Additional information

  • Services for issue management will be added in a follow-up PR
  • All new code follows Platinum quality scale requirements
  • Test coverage maintained above 95%

Checklist

Related Issues/PRs

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @joostlek, mind taking a look at this pull request as it has been labeled with an integration (overseerr) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of overseerr can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign overseerr Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@AmGarera
Copy link
Copy Markdown
Contributor Author

AmGarera commented Dec 13, 2025

Implementation Plan

This PR is part 1 of a 2-part implementation for comprehensive issue management in Overseerr.

Dependencies

This PR depends on python-overseerr#291 which adds the issue management API methods to the python-overseerr library (v0.8.0).

PR Split Rationale

Per the review process guidelines, sensor changes and service introductions should be in separate PRs. This allows for:

  • Easier review of focused changes
  • Independent testing and validation
  • Clearer git history

Implementation Sequence

  1. python-overseerr library enhancement (PR #291) - Approved, awaiting merge
  2. 🔄 This PR: Add issue sensors - Adds 6 sensors and updates coordinator
  3. Future PR: Add issue services - Will add 4 services (get_issues, create_issue, update_issue, delete_issue) after this PR merges
  4. Documentation (PR #42494) - Covers both sensors and services, to be merged after both implementation PRs

What's in This PR

  • 6 new issue sensors (total, open, closed, video, audio, subtitle)
  • Composite data model (OverseerrData) in coordinator
  • Webhook support for issue notifications
  • Updated translations

What's NOT in This PR (coming in part 2)

  • Service actions for issue management
  • Service schemas and definitions
  • Service-related constants

@joostlek
Copy link
Copy Markdown
Member

I published v0.8.0, please bump in a separate PR

@AmGarera AmGarera mentioned this pull request Dec 13, 2025
16 tasks
@AmGarera
Copy link
Copy Markdown
Contributor Author

AmGarera commented Dec 13, 2025

I've split out the dependency bump into #158924 as requested. Once that's merged, this PR will be ready for review.

The updated order is:

  1. ✅ python-overseerr v0.8.0 released
  2. 🔄 Bump python-overseerr to 0.8.0 #158924 - Version bump (Done/Merged)
  3. ⏳ This PR - Issue sensors (Ready For Review)
  4. ⏳ Follow-up PR - Issue services (after this merges)

@AmGarera AmGarera force-pushed the feature/overseerr-issue-sensors branch from 20d7c65 to 47bcdb7 Compare December 13, 2025 16:34
Copy link
Copy Markdown
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests for this?



class OverseerrCoordinator(DataUpdateCoordinator[RequestCount]):
class OverseerrCoordinator(DataUpdateCoordinator[OverseerrData]):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice to split up the coordinators so we can specifically only update the parts that need it. I am happy to help with this part, but justletting it know

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to split them in this PR or in another PR, after this one? I'm good with either approach.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd rather do it in this PR.

@home-assistant
Copy link
Copy Markdown
Contributor

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant Bot marked this pull request as draft December 13, 2025 21:19
@AmGarera
Copy link
Copy Markdown
Contributor Author

Can we add tests for this?

I'll get these added

@AmGarera
Copy link
Copy Markdown
Contributor Author

AmGarera commented Dec 14, 2025

I've added comprehensive tests for the coordinator in commit 493ea08.

The test coverage now includes:

  • Successful data fetch for both requests and issues
  • Authentication error handling (for both API calls)
  • Connection error handling (for both API calls)
  • Data refresh functionality
  • Proper exception raising (ConfigEntryAuthFailed, UpdateFailed)

@AmGarera AmGarera marked this pull request as ready for review December 14, 2025 17:14
@home-assistant home-assistant Bot requested a review from joostlek December 14, 2025 17:14
@AmGarera AmGarera marked this pull request as draft December 14, 2025 17:14
@AmGarera AmGarera marked this pull request as ready for review December 15, 2025 01:46
Copy link
Copy Markdown
Member

@joostlek joostlek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to message me on Discord btw



class OverseerrCoordinator(DataUpdateCoordinator[RequestCount]):
class OverseerrCoordinator(DataUpdateCoordinator[OverseerrData]):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd rather do it in this PR.

"iot_class": "local_push",
"quality_scale": "platinum",
"requirements": ["python-overseerr==0.7.1"]
"requirements": ["python-overseerr==0.8.0"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We bumped this in a separate PR right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did

),
OverseerrSensorEntityDescription(
key="total_issues",
native_unit_of_measurement=ISSUES,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh we can move the unit of measurement to the translations and then we can translate it :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to test the coordinator directly, instead we should observe it via the state machine, like we do in the snapshot test (that's why test_sensor.ambr is updated).

Also, I think that we should have a test where we get an issue related webhook and observe what that does

@home-assistant home-assistant Bot marked this pull request as draft December 15, 2025 13:58
Add 6 new sensors to track issues in Overseerr:
- Total issues
- Open issues
- Closed issues
- Video issues
- Audio issues
- Subtitle issues

Update coordinator to fetch both request and issue counts.
Add webhook support for issue notifications.
Add test coverage for the OverseerrCoordinator including:
- Successful data fetch for both requests and issues
- Authentication error handling
- Connection error handling
- Data refresh functionality
- Proper exception raising (ConfigEntryAuthFailed, UpdateFailed)

Also add issue_count.json test fixture and update conftest to mock
get_issue_count API method.
Update test assertions to use actual values from request_count.json
fixture instead of hardcoded incorrect values.
- Update REGISTERED_NOTIFICATIONS value from 222 to 4062 (now includes issue notifications)
- Remove 'Bigger scope' test case as we now use all notification types
- Update webhook_config.json fixture with new notification types value
- Update snapshots for new issue sensors
- All 52 tests passing with 100% coverage
Replace placeholder 'none' entity IDs with proper translation-key-based IDs:
- sensor.overseerr_none → sensor.overseerr_total_issues
- sensor.overseerr_none_2 → sensor.overseerr_open_issues
- sensor.overseerr_none_3 → sensor.overseerr_closed_issues
- sensor.overseerr_none_4 → sensor.overseerr_video_issues
- sensor.overseerr_none_5 → sensor.overseerr_audio_issues
- sensor.overseerr_none_6 → sensor.overseerr_subtitle_issues

This fixes CI test failures on Python 3.14.2 where snapshots were not found.
- Move unit_of_measurement from hardcoded ISSUES constant to translation strings
- Remove ISSUES constant from const.py (no longer needed)
- Add 'state.measurement' translations for all 6 issue sensors
- Remove direct coordinator tests (test via state machine instead)
- Add webhook test for issue events (test_webhook_issue_trigger_update)
- Fix webhook handler to refresh coordinator for REQUEST_ and ISSUE_ events
- Add webhook_issue_reported.json test fixture
- Update snapshots for new unit_of_measurement approach

This allows the unit 'issues' to be translated to different languages.
@AmGarera AmGarera force-pushed the feature/overseerr-issue-sensors branch from 9bca18c to cb6bed5 Compare December 16, 2025 02:02
@AmGarera AmGarera marked this pull request as ready for review December 16, 2025 16:07
@home-assistant home-assistant Bot requested a review from joostlek December 16, 2025 16:07
@joostlek joostlek merged commit 3f57b46 into home-assistant:dev Dec 16, 2025
36 checks passed
@AmGarera AmGarera deleted the feature/overseerr-issue-sensors branch December 16, 2025 16:38
heindrichpaul pushed a commit to heindrichpaul/core that referenced this pull request Dec 17, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants