diff --git a/custom_components/ftms/__init__.py b/custom_components/ftms/__init__.py index 150c6b9..3f6dfad 100644 --- a/custom_components/ftms/__init__.py +++ b/custom_components/ftms/__init__.py @@ -22,9 +22,9 @@ from .models import FtmsData PLATFORMS: list[Platform] = [ - Platform.SENSOR, Platform.BUTTON, Platform.NUMBER, + Platform.SENSOR, Platform.SWITCH, ] diff --git a/custom_components/ftms/number.py b/custom_components/ftms/number.py index 626fae3..a5159fc 100644 --- a/custom_components/ftms/number.py +++ b/custom_components/ftms/number.py @@ -1,7 +1,7 @@ """FTMS integration button platform.""" +import dataclasses as dc import logging -from typing import Any from homeassistant.components.number import ( NumberDeviceClass, @@ -18,15 +18,15 @@ _LOGGER = logging.getLogger(__name__) -_RESISTANCE_LEVEL: dict[str, Any] = { - "key": c.TARGET_RESISTANCE, -} +_RESISTANCE_LEVEL = NumberEntityDescription( + key=c.TARGET_RESISTANCE, +) -_POWER: dict[str, Any] = { - "key": c.TARGET_POWER, - "device_class": NumberDeviceClass.POWER, - "native_unit_of_measurement": UnitOfPower.WATT, -} +_POWER = NumberEntityDescription( + key=c.TARGET_POWER, + device_class=NumberDeviceClass.POWER, + native_unit_of_measurement=UnitOfPower.WATT, +) _ENTITIES = ( @@ -45,15 +45,15 @@ async def async_setup_entry( entities, ranges_ = [], entry.runtime_data.ftms.supported_ranges for desc in _ENTITIES: - if range_ := ranges_.get(desc["key"]): + if range_ := ranges_.get(desc.key): entities.append( FtmsNumberEntity( entry=entry, - description=NumberEntityDescription( + description=dc.replace( + desc, native_min_value=range_.min_value, native_max_value=range_.max_value, native_step=range_.step, - **desc, ), ) )