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

Move System Bridge services to dedicated file #114903

Closed

Conversation

timmo001
Copy link
Contributor

@timmo001 timmo001 commented Apr 4, 2024

Proposed change

The init file was getting crowded so this moves setup and unload of services into a dedicated file. No other changes made

(Tests to be added after #114896)

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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 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.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Can you please rebase and fix the merge conflicts?

After that, I can start reviewing your PR

@home-assistant home-assistant bot marked this pull request as draft May 28, 2024 16:08
@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.

@timmo001 timmo001 force-pushed the system-bridge-services-file branch from e5b32ba to f2100a8 Compare May 29, 2024 15:14
@timmo001 timmo001 marked this pull request as ready for review May 29, 2024 15:16
@home-assistant home-assistant bot requested a review from edenhaus May 29, 2024 15:16
@timmo001
Copy link
Contributor Author

Rebased

@timmo001 timmo001 force-pushed the system-bridge-services-file branch from f2100a8 to d630920 Compare June 8, 2024 14:58
supports_response=SupportsResponse.ONLY,
)
if not hass.services.has_service(DOMAIN, SERVICE_OPEN_URL):
async_setup_services(hass)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should register service in async_setup and not in the async_setup_entry

Comment on lines +219 to +220
if not hass.data[DOMAIN] or hass.data[DOMAIN] == {}:
async_unload_services(hass)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if not hass.data[DOMAIN] or hass.data[DOMAIN] == {}:
async_unload_services(hass)

We should not remove services with the last config entry

Comment on lines +263 to +266
@callback
def async_unload_services(hass: HomeAssistant) -> None:
"""Unload System Bridge services."""
hass.services.async_remove(DOMAIN, SERVICE_OPEN_PATH)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@callback
def async_unload_services(hass: HomeAssistant) -> None:
"""Unload System Bridge services."""
hass.services.async_remove(DOMAIN, SERVICE_OPEN_PATH)

@home-assistant home-assistant bot marked this pull request as draft June 18, 2024 07:21
@timmo001
Copy link
Contributor Author

May return to this in future

@timmo001 timmo001 closed this Jun 21, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 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

2 participants