Skip to content

Commit

Permalink
dc.replace
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanov committed Jul 18, 2024
1 parent e1071c6 commit f2f9d7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion custom_components/ftms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
from .models import FtmsData

PLATFORMS: list[Platform] = [
Platform.SENSOR,
Platform.BUTTON,
Platform.NUMBER,
Platform.SENSOR,
Platform.SWITCH,
]

Expand Down
24 changes: 12 additions & 12 deletions custom_components/ftms/number.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""FTMS integration button platform."""

import dataclasses as dc
import logging
from typing import Any

from homeassistant.components.number import (
NumberDeviceClass,
Expand All @@ -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 = (
Expand All @@ -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,
),
)
)
Expand Down

0 comments on commit f2f9d7a

Please sign in to comment.