1
mirror of https://github.com/home-assistant/core synced 2024-09-28 03:04:04 +02:00

Small code clean up (#103603)

This commit is contained in:
Michael Hansen 2023-11-07 13:52:58 -06:00 committed by GitHub
parent 0d63e2f9b5
commit 9c2febc72e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -79,13 +79,16 @@ class OnOffIntentHandler(intent.ServiceIntentHandler):
if state.domain == COVER_DOMAIN: if state.domain == COVER_DOMAIN:
# on = open # on = open
# off = close # off = close
if self.service == SERVICE_TURN_ON:
service_name = SERVICE_OPEN_COVER
else:
service_name = SERVICE_CLOSE_COVER
await self._run_then_background( await self._run_then_background(
hass.async_create_task( hass.async_create_task(
hass.services.async_call( hass.services.async_call(
COVER_DOMAIN, COVER_DOMAIN,
SERVICE_OPEN_COVER service_name,
if self.service == SERVICE_TURN_ON
else SERVICE_CLOSE_COVER,
{ATTR_ENTITY_ID: state.entity_id}, {ATTR_ENTITY_ID: state.entity_id},
context=intent_obj.context, context=intent_obj.context,
blocking=True, blocking=True,
@ -97,13 +100,16 @@ class OnOffIntentHandler(intent.ServiceIntentHandler):
if state.domain == LOCK_DOMAIN: if state.domain == LOCK_DOMAIN:
# on = lock # on = lock
# off = unlock # off = unlock
if self.service == SERVICE_TURN_ON:
service_name = SERVICE_LOCK
else:
service_name = SERVICE_UNLOCK
await self._run_then_background( await self._run_then_background(
hass.async_create_task( hass.async_create_task(
hass.services.async_call( hass.services.async_call(
LOCK_DOMAIN, LOCK_DOMAIN,
SERVICE_LOCK service_name,
if self.service == SERVICE_TURN_ON
else SERVICE_UNLOCK,
{ATTR_ENTITY_ID: state.entity_id}, {ATTR_ENTITY_ID: state.entity_id},
context=intent_obj.context, context=intent_obj.context,
blocking=True, blocking=True,

View File

@ -278,7 +278,8 @@ def _convert_audio(
if proc.returncode != 0: if proc.returncode != 0:
_LOGGER.error(stderr.decode()) _LOGGER.error(stderr.decode())
raise RuntimeError( 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) output_file.seek(0)