From 9c2febc72eabe31deb08fe6672c27fea4719c123 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 7 Nov 2023 13:52:58 -0600 Subject: [PATCH] Small code clean up (#103603) --- homeassistant/components/intent/__init__.py | 18 ++++++++++++------ homeassistant/components/tts/__init__.py | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/intent/__init__.py b/homeassistant/components/intent/__init__.py index 4d256795f55..306f169106b 100644 --- a/homeassistant/components/intent/__init__.py +++ b/homeassistant/components/intent/__init__.py @@ -79,13 +79,16 @@ class OnOffIntentHandler(intent.ServiceIntentHandler): if state.domain == COVER_DOMAIN: # on = open # off = close + if self.service == SERVICE_TURN_ON: + service_name = SERVICE_OPEN_COVER + else: + service_name = SERVICE_CLOSE_COVER + await self._run_then_background( hass.async_create_task( hass.services.async_call( COVER_DOMAIN, - SERVICE_OPEN_COVER - if self.service == SERVICE_TURN_ON - else SERVICE_CLOSE_COVER, + service_name, {ATTR_ENTITY_ID: state.entity_id}, context=intent_obj.context, blocking=True, @@ -97,13 +100,16 @@ class OnOffIntentHandler(intent.ServiceIntentHandler): if state.domain == LOCK_DOMAIN: # on = lock # off = unlock + if self.service == SERVICE_TURN_ON: + service_name = SERVICE_LOCK + else: + service_name = SERVICE_UNLOCK + await self._run_then_background( hass.async_create_task( hass.services.async_call( LOCK_DOMAIN, - SERVICE_LOCK - if self.service == SERVICE_TURN_ON - else SERVICE_UNLOCK, + service_name, {ATTR_ENTITY_ID: state.entity_id}, context=intent_obj.context, blocking=True, diff --git a/homeassistant/components/tts/__init__.py b/homeassistant/components/tts/__init__.py index f84c819e739..38715825875 100644 --- a/homeassistant/components/tts/__init__.py +++ b/homeassistant/components/tts/__init__.py @@ -278,7 +278,8 @@ def _convert_audio( if proc.returncode != 0: _LOGGER.error(stderr.decode()) raise RuntimeError( - f"Unexpected error while running ffmpeg with arguments: {command}. See log for details." + f"Unexpected error while running ffmpeg with arguments: {command}." + "See log for details." ) output_file.seek(0)