Refactor matter device entity value conversion (#90368)
This commit is contained in:
parent
fb4b35709d
commit
182af87f97
5 changed files with 60 additions and 39 deletions
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from abc import abstractmethod
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from typing import TYPE_CHECKING, Any, cast
|
||||
|
||||
|
@ -11,7 +12,7 @@ from matter_server.common.helpers.util import create_attribute_path
|
|||
from matter_server.common.models import EventType, ServerInfoMessage
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity, EntityDescription
|
||||
|
||||
from .const import DOMAIN, ID_TYPE_DEVICE_ID
|
||||
from .helpers import get_device_id
|
||||
|
@ -25,6 +26,14 @@ if TYPE_CHECKING:
|
|||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
class MatterEntityDescription(EntityDescription):
|
||||
"""Describe the Matter entity."""
|
||||
|
||||
# convert the value from the primary attribute to the value used by HA
|
||||
measurement_to_ha: Callable[[Any], Any] | None = None
|
||||
|
||||
|
||||
class MatterEntity(Entity):
|
||||
"""Entity class for Matter devices."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue