diff --git a/homeassistant/components/smartthings/sensor.py b/homeassistant/components/smartthings/sensor.py index 13315c30031..2a61be3dc75 100644 --- a/homeassistant/components/smartthings/sensor.py +++ b/homeassistant/components/smartthings/sensor.py @@ -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: