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:
parent
0d63e2f9b5
commit
9c2febc72e
@ -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,
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user