Cleanup zha async method which is not awaiting (#72093)

* Cleanup zha async method which is not awaiting

* Missed a commit
This commit is contained in:
epenet 2022-05-19 17:05:25 +02:00 committed by GitHub
parent 1e1016aa5f
commit b65b47f25e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

@ -160,7 +160,8 @@ def async_cluster_exists(hass, cluster_id):
return False
async def async_get_zha_device(hass, device_id):
@callback
def async_get_zha_device(hass, device_id):
"""Get a ZHA device for the given device registry id."""
device_registry = dr.async_get(hass)
registry_device = device_registry.async_get(device_id)

View File

@ -61,7 +61,7 @@ async def async_get_actions(
) -> list[dict[str, str]]:
"""List device actions."""
try:
zha_device = await async_get_zha_device(hass, device_id)
zha_device = async_get_zha_device(hass, device_id)
except (KeyError, AttributeError):
return []
cluster_channels = [
@ -89,7 +89,7 @@ async def _execute_service_based_action(
action_type = config[CONF_TYPE]
service_name = SERVICE_NAMES[action_type]
try:
zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID])
zha_device = async_get_zha_device(hass, config[CONF_DEVICE_ID])
except (KeyError, AttributeError):
return

View File

@ -28,7 +28,7 @@ async def async_validate_trigger_config(hass, config):
if "zha" in hass.config.components:
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
try:
zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID])
zha_device = async_get_zha_device(hass, config[CONF_DEVICE_ID])
except (KeyError, AttributeError) as err:
raise InvalidDeviceAutomationConfig from err
if (
@ -44,7 +44,7 @@ async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
try:
zha_device = await async_get_zha_device(hass, config[CONF_DEVICE_ID])
zha_device = async_get_zha_device(hass, config[CONF_DEVICE_ID])
except (KeyError, AttributeError):
return None
@ -71,7 +71,7 @@ async def async_get_triggers(hass, device_id):
Make sure the device supports device automations and
if it does return the trigger list.
"""
zha_device = await async_get_zha_device(hass, device_id)
zha_device = async_get_zha_device(hass, device_id)
if not zha_device.device_automation_triggers:
return

View File

@ -76,5 +76,5 @@ async def async_get_device_diagnostics(
hass: HomeAssistant, config_entry: ConfigEntry, device: dr.DeviceEntry
) -> dict:
"""Return diagnostics for a device."""
zha_device: ZHADevice = await async_get_zha_device(hass, device.id)
zha_device: ZHADevice = async_get_zha_device(hass, device.id)
return async_redact_data(zha_device.zha_device_info, KEYS_TO_REDACT)