Move service registration to async_setup in Streamlabs Water - #175507
Conversation
erwindouna
left a comment
There was a problem hiding this comment.
One small nit, and then it looks good. :)
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
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.pywith theset_away_modehandler and anasync_setup_servicesregistrar. - Removed the inline service registration (and the associated constants/schema) from
async_setup_entryin__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.
erwindouna
left a comment
There was a problem hiding this comment.
Thanks @some-random-climber!
| 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], | ||
| ) |
Proposed change
Move service registration to async_setup in Streamlabs Water.
Part of home-assistant/epics#65
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: