Skip to content

Commit

Permalink
gather diagnostics in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
siku2 committed Sep 16, 2023
1 parent 7a98754 commit bb7b849
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
36 changes: 19 additions & 17 deletions custom_components/vzug/diagnostics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from collections.abc import Awaitable
from typing import Any

Expand Down Expand Up @@ -28,23 +29,24 @@ async def do_one(key: str, pending: Awaitable[Any]) -> None:
except Exception as exc:
data[key] = _serialize_exception(exc)

await do_one("mac_address", shared.client.get_mac_address())
await do_one("model_description", shared.client.get_model_description())
await do_one("device_status", shared.client.get_device_status())
await do_one("update_status", shared.client.get_update_status())
await do_one("check_for_updates", shared.client.check_for_updates())
await do_one("last_push_notifications", shared.client.get_last_push_notifications())
await do_one("list_categories", shared.client.list_categories())
await do_one("hh_fw_version", shared.client.get_hh_fw_version())
await do_one("ai_fw_version", shared.client.get_ai_fw_version())
await do_one("zh_mode", shared.client.get_zh_mode())
await do_one("eco_info", shared.client.get_eco_info())
await do_one("device_info", shared.client.get_device_info())
await do_one("program", shared.client.get_program())
await do_one("all_program_ids", shared.client.get_all_program_ids())

# config aggregate
await do_one("aggregate_config", shared.client.aggregate_config())
await asyncio.gather(
do_one("mac_address", shared.client.get_mac_address()),
do_one("model_description", shared.client.get_model_description()),
do_one("device_status", shared.client.get_device_status()),
do_one("update_status", shared.client.get_update_status()),
do_one("check_for_updates", shared.client.check_for_updates()),
do_one("last_push_notifications", shared.client.get_last_push_notifications()),
do_one("list_categories", shared.client.list_categories()),
do_one("hh_fw_version", shared.client.get_hh_fw_version()),
do_one("ai_fw_version", shared.client.get_ai_fw_version()),
do_one("zh_mode", shared.client.get_zh_mode()),
do_one("eco_info", shared.client.get_eco_info()),
do_one("device_info", shared.client.get_device_info()),
do_one("program", shared.client.get_program()),
do_one("all_program_ids", shared.client.get_all_program_ids()),
# config aggregate
do_one("aggregate_config", shared.client.aggregate_config()),
)

return data

Expand Down
1 change: 1 addition & 0 deletions docs/api_versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

- Doesn't have the `alterable` key in commands. All commands are alterable by default.
- Returns `null` instead of an empty list for `getCategories` when there are no categories.
- `getUpdateStatus` isn't supported.

0 comments on commit bb7b849

Please sign in to comment.