Skip to content

Increment/Decrement doesn't work on step of 0.1 #744

@Dillz42

Description

@Dillz42

What version of Spook are you using?

2.2.4

What version of Home Assistant are you using?

2024.4.4

The problem

Spook doesn't seem to like incrementing or decrementing number entities with a step of 0.1. It looks like this has to do with the check for the amount being a multiple of the step. When incrementing 2 with a step of 0.1, the 'multiple' check gets that 2 is not a multiple of 0.1 due to decimal math inaccuracy (2 % 0.1 = 0.099999999 in python).

Anything in the logs? Paste it here!

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 971, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1043, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/spook/ectoplasms/number/services/increment.py", line 35, in async_handle_service
    raise ValueError(msg)
ValueError: ('Amount 2.0 not valid for number.office_desk_upsy_desky_target_desk_height, it needs to be a multiple of 0.1',)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions