Skip to content

Commit

Permalink
Refactor number entity overrides
Browse files Browse the repository at this point in the history
Relates to issues [929](#929), [939](#939) & [941](#941)
I do not have any suitable tuya devices in use to test against this number entity however the warning in logs "LocaltuyaNumber is overriding deprecated methods on an instance of NumberEntity] is now gone

https://developers.home-assistant.io/blog/2022/06/14/number_entity_refactoring/
  • Loading branch information
markvader authored and rospogrigio committed Aug 29, 2022
1 parent 205a844 commit 43c01ee
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions custom_components/localtuya/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

_LOGGER = logging.getLogger(__name__)

CONF_MIN_VALUE = "min_value"
CONF_MAX_VALUE = "max_value"
CONF_MIN_VALUE = "native_min_value"
CONF_MAX_VALUE = "native_max_value"

DEFAULT_MIN = 0
DEFAULT_MAX = 100000
Expand Down Expand Up @@ -52,17 +52,17 @@ def __init__(
self._max_value = self._config.get(CONF_MAX_VALUE)

@property
def value(self) -> float:
def native_value(self) -> float:
"""Return sensor state."""
return self._state

@property
def min_value(self) -> float:
def native_min_value(self) -> float:
"""Return the minimum value."""
return self._min_value

@property
def max_value(self) -> float:
def native_max_value(self) -> float:
"""Return the maximum value."""
return self._max_value

Expand All @@ -71,7 +71,7 @@ def device_class(self):
"""Return the class of this device."""
return self._config.get(CONF_DEVICE_CLASS)

async def async_set_value(self, value: float) -> None:
async def async_set_native_value(self, value: float) -> None:
"""Update the current value."""
await self._device.set_dp(value, self._dp_id)

Expand Down

0 comments on commit 43c01ee

Please sign in to comment.