Skip to content

Move service registration to async_setup in Streamlabs Water - #175507

Merged
erwindouna merged 3 commits into
home-assistant:devfrom
some-random-climber:streamlabswater
Jul 3, 2026
Merged

Move service registration to async_setup in Streamlabs Water#175507
erwindouna merged 3 commits into
home-assistant:devfrom
some-random-climber:streamlabswater

Conversation

@some-random-climber

Copy link
Copy Markdown
Contributor

Proposed change

Move service registration to async_setup in Streamlabs Water.

Part of home-assistant/epics#65

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

  • I understand the code I am submitting and can explain how it works.
  • 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.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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 diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

@erwindouna erwindouna left a comment

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.

One small nit, and then it looks good. :)

Comment thread homeassistant/components/streamlabswater/services.py Outdated
@home-assistant
home-assistant Bot marked this pull request as draft July 3, 2026 14:19
@home-assistant

home-assistant Bot commented Jul 3, 2026

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR is part of the Home Assistant epic to register integration services in async_setup (instead of async_setup_entry), so services are available for automation validation even when the config entry is not loaded. For the streamlabswater integration, it extracts the set_away_mode service into a dedicated services.py module and adds a CONFIG_SCHEMA.

Changes:

  • Added homeassistant/components/streamlabswater/services.py with the set_away_mode handler and an async_setup_services registrar.
  • Removed the inline service registration (and the associated constants/schema) from async_setup_entry in __init__.py.
  • Added CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) to __init__.py.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
homeassistant/components/streamlabswater/services.py New module defining the set_away_mode handler and async_setup_services; resolves the config entry via service.async_get_config_entry.
homeassistant/components/streamlabswater/__init__.py Removes inline service registration and related constants; adds CONFIG_SCHEMA. However, it does not add an async_setup that calls async_setup_services, so the service is never registered.

Key finding: the refactor is incomplete — async_setup_services is never invoked because __init__.py lacks an async_setup function and does not import it, so the set_away_mode service will no longer be registered.

Comment thread homeassistant/components/streamlabswater/__init__.py
Comment thread homeassistant/components/streamlabswater/services.py Outdated
Comment thread homeassistant/components/streamlabswater/services.py Outdated
@some-random-climber
some-random-climber marked this pull request as ready for review July 3, 2026 14:27
Copilot AI review requested due to automatic review settings July 3, 2026 14:27
@home-assistant
home-assistant Bot requested a review from erwindouna July 3, 2026 14:27

@erwindouna erwindouna left a comment

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.

@epenet
epenet marked this pull request as draft July 3, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread homeassistant/components/streamlabswater/__init__.py
Comment thread homeassistant/components/streamlabswater/services.py
Comment thread homeassistant/components/streamlabswater/services.py
Comment thread homeassistant/components/streamlabswater/services.py
@some-random-climber
some-random-climber marked this pull request as ready for review July 3, 2026 14:43
Copilot AI review requested due to automatic review settings July 3, 2026 14:43
@home-assistant
home-assistant Bot requested a review from erwindouna July 3, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment on lines +26 to +35
def set_away_mode(call: ServiceCall) -> None:
"""Set the StreamLabsWater Away Mode."""
entry: StreamlabsConfigEntry = service.async_get_config_entry(
call.hass, DOMAIN, None
)
coordinator = entry.runtime_data
coordinator.client.update_location(
call.data.get(CONF_LOCATION_ID) or list(coordinator.data)[0],
call.data[ATTR_AWAY_MODE],
)
@erwindouna
erwindouna merged commit fd9c7d4 into home-assistant:dev Jul 3, 2026
33 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 4, 2026
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.

Move service registration to async_setup in streamlabswater

3 participants