Skip to content

Commit

Permalink
Merge pull request #94 from Remko76/patch-1
Browse files Browse the repository at this point in the history
Update Number.py to match new NumberEntity Definition
  • Loading branch information
binsentsu authored Aug 1, 2022
2 parents 2fad552 + 8826c75 commit a68aa76
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions custom_components/solaredge_modbus/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def __init__(self,
self._register = register
self._fmt = fmt

self._attr_min_value = attrs["min"]
self._attr_max_value = attrs["max"]
self._attr_native_min_value = attrs["min"]
self._attr_native_max_value = attrs["max"]
if "unit" in attrs.keys():
self._attr_unit_of_measurement = attrs["unit"]
self._attr_native_unit_of_measurement = attrs["unit"]

async def async_added_to_hass(self) -> None:
"""Register callbacks."""
Expand Down Expand Up @@ -102,11 +102,11 @@ def should_poll(self) -> bool:
return False

@property
def value(self) -> float:
def native_value(self) -> float:
if self._key in self._hub.data:
return self._hub.data[self._key]

async def async_set_value(self, value: float) -> None:
async def async_set_native_value(self, value: float) -> None:
"""Change the selected value."""
builder = BinaryPayloadBuilder(byteorder=Endian.Big, wordorder=Endian.Little)

Expand All @@ -119,4 +119,3 @@ async def async_set_value(self, value: float) -> None:

self._hub.data[self._key] = value
self.async_write_ha_state()

0 comments on commit a68aa76

Please sign in to comment.