Skip to content

Update NumberEntity to use native values #3

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions custom_components/buttplug/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ def __init__(
self._dev = dev
self._cmd_type = cmd_type
self._index = index
self._attr_value = 0
self._attr_max_value = 100
self._attr_min_value = -100 if cmd_type == CMD_TYPE_ROTATE else 0
self._attr_native_value = 0
self._attr_native_max_value = 100
self._attr_native_min_value = -100 if cmd_type == CMD_TYPE_ROTATE else 0
self._attr_native_step = 1
self._attr_mode = NumberMode.SLIDER
self._attr_step = 1

self._attr_device_info = DeviceInfo(identifiers={dev.name})

Expand All @@ -116,7 +116,7 @@ def __init__(
base_attr_name if sole_index else f"{base_attr_name} ({index})"
) # TODO client name too?

async def async_set_value(self, value: float) -> None:
async def async_set_native_value(self, value: float) -> None:
"""Update the current value."""
internal_value = value / 100
try:
Expand Down Expand Up @@ -148,7 +148,7 @@ async def async_set_value(self, value: float) -> None:
err,
)
else:
self._attr_value = value
self._attr_native_value = value

# async def async_added_to_hass(self) -> None:
# """Call when entity is added."""
Expand Down