Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Overseerr Issues feature #137969

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from

Conversation

cliffordwhansen
Copy link
Contributor

@cliffordwhansen cliffordwhansen commented Feb 8, 2025

Proposed change

Adding support for Overseerr Issues

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented Feb 8, 2025

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.

@MartinHjelmare MartinHjelmare changed the title Added support for Overseerr Issues feature Add support for Overseerr Issues feature Feb 22, 2025
@@ -18,9 +18,9 @@ async def async_get_config_entry_diagnostics(

has_cloudhooks = CONF_CLOUDHOOK_URL in entry.data

data = entry.runtime_data
data: OverseerrData = entry.runtime_data.data
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
data: OverseerrData = entry.runtime_data.data
data = entry.runtime_data.data

Shouldn't be needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's nice to have things typed, but I agree not useful here.

Copy link
Member

Choose a reason for hiding this comment

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

Oh but the catch is that the entry already is typed, so we're able to find out what the type of entry.runtime_data.data is without explicitly defining it :)

translation_key="last_issue_event",
event_types=[
"reported",
"comment",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"comment",
"commented",

I kinda like the idea of having the states answer the question "what happened?" "somebody ". But I can also see that it makes the code uglier, so I am fine with it as it is, just wanted to write down my thought

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, this change will require a change in the upstream library aswell

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see what you mean

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just did some tests and the webhook returns the following:

{'notification_type': 'ISSUE_COMMENT', 'subject': "xxx", 'message': 'Ended early :(', 'media': {'media_type': 'tv', 'tmdb_id': xxx, 'tvdb_id': xxx, 'status': 'partially_available', 'status4k': 'unknown'}, 'request': None, 'issue': {'issue_id': 12, 'issue_type': 'VIDEO', 'issue_status': 'OPEN', 'reported_by_email': 'xxx', 'reported_by_username': 'xxx', 'reported_by_avatar': 'xxx', 'reported_by_settings_discord_id': '', 'reported_by_settings_telegram_chat_id': ''}}

So unfortunately we need to use comment :(

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, but in theory we can use a dict to map between the 2 values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

something like this? (last commit)

@@ -108,7 +119,6 @@ def available(self) -> bool:

def parse_event(event: dict[str, Any], nullable_fields: list[str]) -> dict[str, Any]:
"""Parse event."""
event.pop("notification_type")
Copy link
Member

Choose a reason for hiding this comment

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

I thought I removed this one as it is duplicate with the reported event

Copy link
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 also be nice to add a thing in test_event's test_entities that we already posted an issue update, so we can see the full state of the entity when it happened

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@home-assistant home-assistant bot marked this pull request as draft February 23, 2025 13:11
@home-assistant
Copy link

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.

@cliffordwhansen cliffordwhansen marked this pull request as ready for review February 23, 2025 14:34
@home-assistant home-assistant bot requested a review from joostlek February 23, 2025 14:34
@joostlek
Copy link
Member

I think that solves it, but I think we can just make sure we only do a {"comment": "commented"}.get(state, state) so to say, and that would either return commented or state, which is a bit smaller than defining everything that is the same

@cliffordwhansen
Copy link
Contributor Author

I think that solves it, but I think we can just make sure we only do a {"comment": "commented"}.get(state, state) so to say, and that would either return commented or state, which is a bit smaller than defining everything that is the same

I'm not sure where that would go, I've never used a call like that before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants