diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 53c5cf16a98..b02874780e5 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -400,19 +400,17 @@ class Camera(Entity): """Turn off camera.""" raise NotImplementedError() - @callback - def async_turn_off(self): + async def async_turn_off(self): """Turn off camera.""" - return self.hass.async_add_job(self.turn_off) + await self.hass.async_add_job(self.turn_off) def turn_on(self): """Turn off camera.""" raise NotImplementedError() - @callback - def async_turn_on(self): + async def async_turn_on(self): """Turn off camera.""" - return self.hass.async_add_job(self.turn_on) + await self.hass.async_add_job(self.turn_on) def enable_motion_detection(self): """Enable motion detection in the camera.""" diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index 89c2715a760..36bfd9c8cb0 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -370,9 +370,13 @@ async def _handle_service_platform_call( entity.async_set_context(context) if isinstance(func, str): - result = await hass.async_add_job(partial(getattr(entity, func), **data)) + result = hass.async_add_job(partial(getattr(entity, func), **data)) else: - result = await hass.async_add_job(func, entity, data) + result = hass.async_add_job(func, entity, data) + + # Guard because callback functions do not return a task when passed to async_add_job. + if result is not None: + result = await result if asyncio.iscoroutine(result): _LOGGER.error(