rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.83k stars 544 forks source link

[master] failed to call service cover/set.cover.position unsupported operand type(s) for -: 'float' and 'str' #537

Open teunaldo opened 3 years ago

teunaldo commented 3 years ago

The problem

I try to add the Zemismart AM15 roller blinds (With RF to wifi converter) The up & down movement work flawless. Percentage isn't working anyway. It is exposed when I look at it with Tinytuya

In LocalTuya version 3.2.2 the timer up and down is working, but when I want to set it at 50% it sometimes stops at 75% or something. It doesn't matter if it goes up and down.

The release I now use is "master". When I configured the 'timer', I get the following error in the log:

failed to call service cover/set.cover.position unsupported operand type(s) for -: 'float' and 'str'

Environment

Steps to reproduce

  1. Add cover this way (https://gyazo.com/64f9213170d0f835245379e5e932188b)
  2. Try to change cover position with slider

Configuration configuration.yaml or config_flow

https://gyazo.com/64f9213170d0f835245379e5e932188b

DP dump

    "result": [
        {
            "category": "cl",
            "active_time": 1627742257,
            "sub": false,
            "uuid": "xxxxxxxxxxxxxxxxxxxxxxxxx",
            "name": "zemismart wifi curtain",
            "uid": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
            "ip": "x.x.x.x",
            "lon": "0",
            "time_zone": "+02:00",
            "product_name": "zemismart wifi curtain",
            "local_key": "xxxxxxxxxxxxxxx",
            "biz_type": 18,
            "create_time": 1627742257,
            "status": [
                {
                    "code": "control",
                    "value": "stop"
                },
                {
                    "code": "percent_control",
                    "value": 0
                },
                {
                    "code": "percent_state",
                    "value": 0
                },
                {
                    "code": "mode",
                    "value": "morning"
                },
                {
                    "code": "control_back_mode",
                    "value": "forward"
                },
                {
                    "code": "work_state",
                    "value": "opening"
                },
                {
                    "code": "countdown_left",
                    "value": 0
                },
                {
                    "code": "time_total",
                    "value": 10000
                },
                {
                    "code": "border",
                    "value": "down"
                }
            ],
            "online": true,
            "lat": "0",
            "update_time": 1628026675,
            "owner_id": "xxxxxxxxxxx",
            "product_id": "xrp8umdaamqiogn8",
            "id": "xxxxxxxxxxxxxxxxxxxxxxxx",
            "icon": "smart/icon/ay1540610793051la24K/458610419e35cdd92001edf33368aff4.png"
        }
    ],
    "success": true,
    "t": 1628446462621

Provide Home Assistant taceback/logs

2021-08-08 21:25:14 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139703228107696] unsupported operand type(s) for -: 'float' and 'str'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 658, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 856, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 695, in _handle_entity_call
    await result
  File "/config/custom_components/localtuya/cover.py", line 130, in async_set_cover_position
    posdiff = abs(newpos - currpos)
TypeError: unsupported operand type(s) for -: 'float' and 'str'

Additional information

chay1406 commented 2 years ago

Did we make any progress on this?

R1Z0 commented 1 year ago

I have this same problem. stored_state.attributes.get("current_position") returns state like (open, close, stop) not int position