rospogrigio / localtuya

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

No attribute "isupper" #610

Open slavak78 opened 3 years ago

slavak78 commented 3 years ago

There is no attribute "isupper". I'm trying to connect an electric motor for blinds from tuya via localtuya. Writes an error in line 197 in the file cover.py that there is no attribute "isupper". And the electric motor does not connect to the home assitant. Please help me solve this problem.

WarlaxZ commented 2 years ago

so i had the same problem for ages, turns out you need to set the 'id' for the cover to whatever the current state is

WarlaxZ commented 2 years ago

(so it should look like 'open' or 'closed') - for me it was ID 1, but ymmv

donburch888 commented 2 years ago

I have added LocalTuya and tried to configure a zemismart blind motor. On http://homeassistant.local:8123/hassio/system in the "core" Log Provider I am getting the following repeating:

2022-02-27 18:22:43 WARNING (SyncWorker_3) [custom_components.localtuya.binary_sensor] [382...7d8] State for entity binary_sensor.control_back_mode did not match state patterns
2022-02-27 18:22:43 WARNING (SyncWorker_3) [custom_components.localtuya.binary_sensor] [382...7d8] State for entity binary_sensor.status did not match state patterns
2022-02-27 18:22:43 ERROR (SyncWorker_6) [homeassistant.util.logging] Exception in _update_handler when dispatching 'localtuya_38262640e868e7ef17d8': ({'1': 'stop', '2': 100, '5': False, '7': 'opening'},)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/common.py", line 281, in _update_handler
    self.status_updated()
  File "/config/custom_components/localtuya/cover.py", line 195, in status_updated
    if self._state.isupper():
AttributeError: 'int' object has no attribute 'isupper'
WarlaxZ commented 2 years ago

you need to readd the component and pick a different id

johngianni commented 2 years ago

I'm having the same problem. It seems that the device status does not contain a useful value for the integration. Infact, using a 102 ID (STOP) will let the integration work, but not reporting the OPEN/CLOSE correct status, that should be derived by the POSITION value. Anyone willing to help to code the change in the cover.py file please? Here's the status response from the API Explorer:

{ "result": [ { "code": "position", "value": 0 }, { "code": "mach_operate", "value": "STOP" }, { "code": "opposite", "value": false } ], "success": true, "t": 1652975275441, "tid": "0ca15399d78b11eca733f2b4cd1fee5a" }