mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
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:
parent
1e1016aa5f
commit
b65b47f25e
@ -160,7 +160,8 @@ def async_cluster_exists(hass, cluster_id):
|
|||||||
return False
|
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."""
|
"""Get a ZHA device for the given device registry id."""
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
registry_device = device_registry.async_get(device_id)
|
registry_device = device_registry.async_get(device_id)
|
||||||
|
@ -61,7 +61,7 @@ async def async_get_actions(
|
|||||||
) -> list[dict[str, str]]:
|
) -> list[dict[str, str]]:
|
||||||
"""List device actions."""
|
"""List device actions."""
|
||||||
try:
|
try:
|
||||||
zha_device = await async_get_zha_device(hass, device_id)
|
zha_device = async_get_zha_device(hass, device_id)
|
||||||
except (KeyError, AttributeError):
|
except (KeyError, AttributeError):
|
||||||
return []
|
return []
|
||||||
cluster_channels = [
|
cluster_channels = [
|
||||||
@ -89,7 +89,7 @@ async def _execute_service_based_action(
|
|||||||
action_type = config[CONF_TYPE]
|
action_type = config[CONF_TYPE]
|
||||||
service_name = SERVICE_NAMES[action_type]
|
service_name = SERVICE_NAMES[action_type]
|
||||||
try:
|
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):
|
except (KeyError, AttributeError):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ async def async_validate_trigger_config(hass, config):
|
|||||||
if "zha" in hass.config.components:
|
if "zha" in hass.config.components:
|
||||||
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
|
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
|
||||||
try:
|
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:
|
except (KeyError, AttributeError) as err:
|
||||||
raise InvalidDeviceAutomationConfig from err
|
raise InvalidDeviceAutomationConfig from err
|
||||||
if (
|
if (
|
||||||
@ -44,7 +44,7 @@ async def async_attach_trigger(hass, config, action, automation_info):
|
|||||||
"""Listen for state changes based on configuration."""
|
"""Listen for state changes based on configuration."""
|
||||||
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
|
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
|
||||||
try:
|
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):
|
except (KeyError, AttributeError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ async def async_get_triggers(hass, device_id):
|
|||||||
Make sure the device supports device automations and
|
Make sure the device supports device automations and
|
||||||
if it does return the trigger list.
|
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:
|
if not zha_device.device_automation_triggers:
|
||||||
return
|
return
|
||||||
|
@ -76,5 +76,5 @@ async def async_get_device_diagnostics(
|
|||||||
hass: HomeAssistant, config_entry: ConfigEntry, device: dr.DeviceEntry
|
hass: HomeAssistant, config_entry: ConfigEntry, device: dr.DeviceEntry
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""Return diagnostics for a device."""
|
"""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)
|
return async_redact_data(zha_device.zha_device_info, KEYS_TO_REDACT)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user