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 service to 17track to get packages #116067

Merged
merged 6 commits into from
Apr 24, 2024

Conversation

shaiu
Copy link
Contributor

@shaiu shaiu commented Apr 23, 2024

Proposed change

Add service to 17track

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][dev-checklist]
  • I have followed the [perfect PR recommendations][perfect-pr]
  • 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:

  • Documentation added/updated for [www.home-assistant.io][docs-repository]

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

  • The [manifest file][manifest-docs] 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.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

  • I have reviewed two other [open pull requests][prs] in this repository.

get_packages:
fields:
package_state:
example: "In Transit,Delivered"
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 we can make this a select selector since we already know all possible 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.

Done

return_response=SupportsResponse.ONLY,
)

assert len(service_response["packages"]) == 2
Copy link
Member

Choose a reason for hiding this comment

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

You can use snapshots here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool. Never knew about snapshot

@home-assistant home-assistant bot marked this pull request as draft April 24, 2024 07:23
@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.

@shaiu shaiu marked this pull request as ready for review April 24, 2024 10:29
@home-assistant home-assistant bot requested a review from joostlek April 24, 2024 10:29
@joostlek joostlek changed the title Add service to 17track Add service to 17track to get packages Apr 24, 2024
@joostlek joostlek merged commit 1f4585c into home-assistant:dev Apr 24, 2024
24 checks passed
@shaiu shaiu deleted the shaiu-17track-service branch April 24, 2024 14:21
@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 2024
DOMAIN,
SERVICE_GET_PACKAGES,
get_packages,
supports_response=SupportsResponse.ONLY,
Copy link
Member

Choose a reason for hiding this comment

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

I'm missing a service validation schema.

@home-assistant home-assistant unlocked this conversation May 2, 2024
"""Get packages from 17Track."""
config_entry_id = call.data[ATTR_CONFIG_ENTRY_ID]
package_states = call.data.get(ATTR_PACKAGE_STATE, [])
seventeen_coordinator: SeventeenTrackCoordinator = hass.data[DOMAIN][
Copy link
Member

Choose a reason for hiding this comment

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

We need to handle a missing or not loaded config entry before accessing hass.data. Raise ServiceValidationError.

@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2024
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.

None yet

3 participants