Add logbook describe event support to ZHA (#73077)

This commit is contained in:
David F. Mulcahey 2022-06-07 12:49:40 -04:00 committed by GitHub
parent 73f2bca377
commit a5dc7c5f28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 307 additions and 5 deletions

View file

@ -5,6 +5,7 @@ import asyncio
from collections.abc import Callable
from datetime import timedelta
from enum import Enum
from functools import cached_property
import logging
import random
import time
@ -280,7 +281,16 @@ class ZHADevice(LogMixin):
"""Return the gateway for this device."""
return self._zha_gateway
@property
@cached_property
def device_automation_commands(self) -> dict[str, list[tuple[str, str]]]:
"""Return the a lookup of commands to etype/sub_type."""
commands: dict[str, list[tuple[str, str]]] = {}
for etype_subtype, trigger in self.device_automation_triggers.items():
if command := trigger.get(ATTR_COMMAND):
commands.setdefault(command, []).append(etype_subtype)
return commands
@cached_property
def device_automation_triggers(self) -> dict[tuple[str, str], dict[str, str]]:
"""Return the device automation triggers for this device."""
triggers = {