Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed deprecation of NumberEntity members #903

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions custom_components/sonoff/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ def set_state(self, params: dict):
if self.round is not None:
# convert to int when round is zero
value = round(value, self.round or None)
self._attr_value = value
self._attr_native_value = value

async def async_set_value(self, value: float) -> None:
async def async_set_native_value(self, value: float) -> None:
if self.multiply:
value /= self.multiply
await self.ewelink.send(self.device, {self.param: int(value)})


class XPulseWidth(XEntity, NumberEntity):

_attr_max_value = 36000
_attr_min_value = 0.5
_attr_step = 0.5
_attr_native_max_value = 36000
_attr_native_min_value = 0.5
_attr_native_step = 0.5

def set_state(self, params: dict):
self._attr_value = params["pulseWidth"] / 1000
self._attr_native_value = params["pulseWidth"] / 1000

async def async_set_value(self, value: float) -> None:
async def async_set_native_value(self, value: float) -> None:
"""
we need to send {'pulse': 'on'} in order to also set the pilseWidth
else it'll reject the command
Expand Down