From bc72f8277656ca6044dadf4a5af69aab9ec386c1 Mon Sep 17 00:00:00 2001 From: Sid <27780930+autinerd@users.noreply.github.com> Date: Fri, 24 May 2024 10:53:05 +0200 Subject: [PATCH] Convert namedtuple to NamedTuple for smartthings (#115395) --- .../components/smartthings/sensor.py | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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: