Convert namedtuple to NamedTuple for smartthings (#115395)
This commit is contained in:
parent
1ad2e4951d
commit
bc72f82776
1 changed files with 14 additions and 6 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import namedtuple
|
||||
from collections.abc import Sequence
|
||||
from typing import NamedTuple
|
||||
|
||||
from pysmartthings import Attribute, Capability
|
||||
from pysmartthings.device import DeviceEntity
|
||||
|
@ -34,9 +34,17 @@ from homeassistant.util import dt as dt_util
|
|||
from . import SmartThingsEntity
|
||||
from .const import DATA_BROKERS, DOMAIN
|
||||
|
||||
Map = namedtuple(
|
||||
"Map", "attribute name default_unit device_class state_class entity_category"
|
||||
)
|
||||
|
||||
class Map(NamedTuple):
|
||||
"""Tuple for mapping Smartthings capabilities to Home Assistant sensors."""
|
||||
|
||||
attribute: str
|
||||
name: str
|
||||
default_unit: str | None
|
||||
device_class: SensorDeviceClass | None
|
||||
state_class: SensorStateClass | None
|
||||
entity_category: EntityCategory | None
|
||||
|
||||
|
||||
CAPABILITY_TO_SENSORS: dict[str, list[Map]] = {
|
||||
Capability.activity_lighting_mode: [
|
||||
|
@ -629,8 +637,8 @@ class SmartThingsSensor(SmartThingsEntity, SensorEntity):
|
|||
device: DeviceEntity,
|
||||
attribute: str,
|
||||
name: str,
|
||||
default_unit: str,
|
||||
device_class: SensorDeviceClass,
|
||||
default_unit: str | None,
|
||||
device_class: SensorDeviceClass | None,
|
||||
state_class: str | None,
|
||||
entity_category: EntityCategory | None,
|
||||
) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue