zaptec icon indicating copy to clipboard operation
zaptec copied to clipboard

Refactor services.py

Open steinmn opened this issue 6 months ago • 0 comments

async_setup_services should be run in async_setup, not in async_setup_entry (https://developers.home-assistant.io/docs/core/integration-quality-scale/rules/action-setup/) and async_unload_services seems to have been dropped entirely (https://github.com/home-assistant/core/pull/146048#discussion_r2121194482). Haven't been able to find where the recommendation this comment refers to is, but I do see that `async_unload_services is no longer used anywhere in the core-repo.

Looking at some of the integrations in core that implement async_setup_services, they rarely contain more than hass.services.async_register-calls within the function itself.

Prerequisite: Ensure good test coverage for services before refactoring to avoid introducing regressions.

Main tasks:

  • Move call to async_setup_services from async_setup_entry to async_setup
  • Move function definitions out of async_setup_services
  • Investigate if iter_objects can be simplified and/or makes more sense as a function inside ZaptecManager
  • remove async_unload_services

steinmn avatar Jul 27 '25 20:07 steinmn