diff --git a/homeassistant/core.py b/homeassistant/core.py index 9a373f7a159..aa15872c29b 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -2014,9 +2014,10 @@ class Service: service: str, context: Context | None = None, supports_response: SupportsResponse = SupportsResponse.NONE, + job_type: HassJobType | None = None, ) -> None: """Initialize a service.""" - self.job = HassJob(func, f"service {domain}.{service}") + self.job = HassJob(func, f"service {domain}.{service}", job_type=job_type) self.schema = schema self.supports_response = supports_response @@ -2158,6 +2159,7 @@ class ServiceRegistry: ], schema: vol.Schema | None = None, supports_response: SupportsResponse = SupportsResponse.NONE, + job_type: HassJobType | None = None, ) -> None: """Register a service. @@ -2168,7 +2170,12 @@ class ServiceRegistry: domain = domain.lower() service = service.lower() service_obj = Service( - service_func, schema, domain, service, supports_response=supports_response + service_func, + schema, + domain, + service, + supports_response=supports_response, + job_type=job_type, ) if domain in self._services: diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index 389dd69900a..40b665ed373 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -22,6 +22,7 @@ from homeassistant.const import ( from homeassistant.core import ( Event, HassJob, + HassJobType, HomeAssistant, ServiceCall, ServiceResponse, @@ -278,6 +279,7 @@ class EntityComponent(Generic[_EntityT]): ), schema, supports_response, + job_type=HassJobType.Coroutinefunction, ) async def async_setup_platform(