Skip to content
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

no longer detecting all dp_id #838

Closed
donburch888 opened this issue May 29, 2022 · 7 comments
Closed

no longer detecting all dp_id #838

donburch888 opened this issue May 29, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@donburch888
Copy link

donburch888 commented May 29, 2022

The problem

My Zemismart blind motor recently stopped making the blind position available, so I tried reinstalling it - and found that previously available dp_id entries (including "percent_control") are no longer being detected.

Environment

  • Home Assistant OS 8.1 on a Raspberry Pi 4
  • Localtuya version: v3.5.0
  • Last working localtuya version (if known and relevant):
  • Home Assistant Core version: 2022.5.5
  • [] Are you using the Home Assistant Tuya Cloud component ?
  • [] Are you using the Tuya App in parallel ?

Steps to reproduce

  1. Go to Tuya IOT Platform website > Get device specification attributes and enter device ID. Result is :
{
  "result": {
    "category": "cl",
    "functions": [
      {
        "code": "control",
        "type": "Enum",
        "values": "{\"range\":[\"open\",\"stop\",\"close\"]}"
      },
      {
        "code": "percent_control",
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "control_back_mode",
        "type": "Enum",
        "values": "{\"range\":[\"forward\",\"back\"]}"
      },
      {
        "code": "border",
        "type": "Enum",
        "values": "{\"range\":[\"up\",\"down\",\"up_delete\",\"down_delete\",\"remove_top_bottom\"]}"
      },
      {
        "code": "position_best",
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      }
    ],
    "status": [
      {
        "code": "control",
        "type": "Enum",
        "values": "{\"range\":[\"open\",\"stop\",\"close\"]}"
      },
      {
        "code": "percent_control",
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      },
      {
        "code": "control_back_mode",
        "type": "Enum",
        "values": "{\"range\":[\"forward\",\"back\"]}"
      },
      {
        "code": "work_state",
        "type": "Enum",
        "values": "{\"range\":[\"opening\",\"closing\"]}"
      },
      {
        "code": "fault",
        "type": "Bitmap",
        "values": "{\"label\":[\"motor_fault\"]}"
      },
      {
        "code": "border",
        "type": "Enum",
        "values": "{\"range\":[\"up\",\"down\",\"up_delete\",\"down_delete\",\"remove_top_bottom\"]}"
      },
      {
        "code": "position_best",
        "type": "Integer",
        "values": "{\"unit\":\"%\",\"min\":0,\"max\":100,\"scale\":0,\"step\":1}"
      }
    ]
  },
  "success": true,
  "t": 1653863419008,
  "tid": "eb624a59df9e11ec872f2aa367714e21"
}

I note that the dp_id numbers are no longer being provided :-( Is this significant ?

  1. Install blind motor in localTuya on Home Assistant.
    Personally I prefer the older "Add new Entity" with drop-down fields, to the new layout where all options are listed in one super-long page. A screen shot would be helpful here.

the Add new entiry page starts by asking for ID with only 2 options listed, being:

1 (value: stop)
7 (value: opening)

These same two options are presented for Current position and Set position. In fact some playing around shows they are the only options presented for all platform types.

Configuration configuration.yaml or config_flow

I used the GUI to install the blind motor, but where is 'config_flow' ? Do you mean /config/custom_components/localtuya/config_flow.py ?

DP dump

don@muscle:~$ python3 tuyadebug/test.py 38262640e868e7ef17d8 192.168.1.160 d4f4327c3937d269
INFO:localtuya:localtuya version 1.0.0
INFO:localtuya:Python 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0] on linux
INFO:localtuya:Using pytuya version '8.1.0'
INFO:localtuya:Detecting list of available DPS of device 38262640e868e7ef17d8 [192.168.1.160], protocol 3.3.
DEBUG:localtuya.pytuya:Sending command status (device type: type_0a)
DEBUG:localtuya.pytuya:paylod=b'{"gwId":"38262640e868e7ef17d8","devId":"38262640e868e7ef17d8"}'
DEBUG:localtuya.pytuya:DATA RECEIVED!
DEBUG:localtuya.pytuya:decode payload=b'W\x8c<\xacO\xa3\x85\xb4\xe8\x16x<\xf9D\x08\x02h<\x86-\x05/\x9f\xd0Y\x97\x9d\x89\x1cVT\x7f\xc9[\xcd\xbb\x80+\xd5\x88\xd3\x92/?\xed\xf4"\xfb5\x97\xeb9\xf3f<\xb5~\xb4\x1du\x00\xf5H[><\xd1\x1dn\xb4\xae@\xbc1\xcb\xd7\xe7b\x14\xdf'
DEBUG:localtuya.pytuya:decrypted result='{"devId":"38262640e868e7ef17d8","dps":{"1":"stop","7":"opening"}}'
AVAILABLE DPS ARE [{'1': 'stop', '7': 'opening'}]
INFO:localtuya:COMPLETE response from device 38262640e868e7ef17d8 [192.168.1.160].

**** deviceInfo returned OK ****

TuyaDebug (Tuya DPs dump) [1.0.0]

Device 38262640e868e7ef17d8 at 192.168.1.160 key d4f4327c3937d269 protocol 3.3 dev_type type_0a:
    DPS [1] VALUE [stop] 
    DPS [7] VALUE [opening] 
don@muscle:~$

Provide Home Assistant taceback/logs

Logger: homeassistant.util.logging
Source: util/logging.py:114
First occurred: May 29, 2022, 9:08:50 AM (5 occurrences)
Last logged: 9:00:00 AM

Exception in _update_handler when dispatching 'localtuya_bfe74c868b1c942a54andf': ({'1': False, '9': 0, '18': 0, '19': 0, '20': 2432, '26': 0, '38': 'off'},) 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/select.py", line 96, in status_updated self._state_friendly = self._display_options[self._valid_options.index(state)] ValueError: 'off' is not in list
Exception in _update_handler when dispatching 'localtuya_bfe74c868b1c942a54andf': ({'1': True, '9': 0, '18': 0, '19': 0, '20': 2432, '26': 0, '38': 'off'},) 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/select.py", line 96, in status_updated self._state_friendly = self._display_options[self._valid_options.index(state)] ValueError: 'off' is not in list
Logger: homeassistant.helpers.service
Source: helpers/service.py:130
First occurred: May 29, 2022, 4:56:59 PM (4 occurrences)
Last logged: May 29, 2022, 11:31:41 PM

Unable to find referenced entities cover.blind_lr_control
Unable to find referenced entities switch.tv_light
This error originated from a custom integration.

Logger: custom_components.localtuya.config_flow
Source: custom_components/localtuya/pytuya/__init__.py:247
Integration: LocalTuya (documentation, issues)
First occurred: May 29, 2022, 1:03:55 PM (2 occurrences)
Last logged: May 29, 2022, 1:47:44 PM

Unexpected exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/locks.py", line 413, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for
    fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/config_flow.py", line 283, in async_step_basic_info
    self.dps_strings = await validate_input(self.hass, user_input)
  File "/config/custom_components/localtuya/config_flow.py", line 196, in validate_input
    detected_dps = await interface.detect_available_dps()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 539, in detect_available_dps
    data = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 481, in status
    status = await self.exchange(STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 460, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 247, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
This error originated from a custom integration.

Logger: custom_components.localtuya.pytuya
Source: custom_components/localtuya/pytuya/__init__.py:247
Integration: LocalTuya (documentation, issues)
First occurred: May 29, 2022, 1:03:55 PM (2 occurrences)
Last logged: May 29, 2022, 1:47:44 PM

[382...7d8] Failed to get status:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/locks.py", line 413, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 492, in wait_for
    fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 539, in detect_available_dps
    data = await self.status()
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 481, in status
    status = await self.exchange(STATUS)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 460, in exchange
    msg = await self.dispatcher.wait_for(seqno)
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 247, in wait_for
    await asyncio.wait_for(self.listeners[seqno].acquire(), timeout=timeout)
  File "/usr/local/lib/python3.9/asyncio/tasks.py", line 494, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

Additional information

I then enabled access through my router and managed to control all aspects of the blind motor using the Tuya phone app - indicating that it isn't a blind motor firmware problem.

@donburch888 donburch888 added the bug Something isn't working label May 29, 2022
@merrilr
Copy link

merrilr commented May 31, 2022

When i setup my local devices none of my p ids were detected. In all the tutorials i watched they showed. Is this a change on Tuya side

@simbesh
Copy link

simbesh commented Jun 7, 2022

Same issue here for adding a smart curtain, the options I was given in the wizard while adding the curtain, none looked like an ID field. ran the debug script:

λ python tuyadebug\test.py 18784500a4e57cb7b812 10.1.1.40 ff85d140ea97720f
INFO:localtuya:localtuya version 1.0.0
INFO:localtuya:Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
INFO:localtuya:Using pytuya version '8.1.0'
INFO:localtuya:Detecting list of available DPS of device 18784500a4e57cb7b812 [10.1.1.40], protocol 3.3.
DEBUG:localtuya.pytuya:Sending command status (device type: type_0a)
DEBUG:localtuya.pytuya:paylod=b'{"gwId":"18784500a4e57cb7b812","devId":"18784500a4e57cb7b812"}'
DEBUG:localtuya.pytuya:DATA RECEIVED!
DEBUG:localtuya.pytuya:decode payload=b"\xcf\xc2N\xf1\xa2\xda\xddt;WM+[\x95L~)\x9f\xf2\xe0\xc4\xeb\xc6\xdc&\x9d\x86tG\xe0\xa3\xc3Z\x03z\xfa\x8eY&f}\xb4\xdc\xc4\xca=k[+\xf0\x12\xbe^\x0e\xa5\x94q\xa5\xa9\x19\x14\xef\x1dx\x02B\x8d\xbe!\xf8\xd8E_\xbd\xf8\x9fCmnPt\xe9\x9fY\xf5K\x9c\x15a\xf8\x92Ul\x94\x87\xed\xf3\xbe5\x8e\xa6\x9e\x17\x84'\x05\xf2\xad\xec\x14n\x08\x8e\xc8.i\xd6ee[\x88\x97U\xb7\x96\xa6\xc7\xab"
DEBUG:localtuya.pytuya:decrypted result='{"devId":"18784500a4e57cb7b812","dps":{"1":"stop","2":33,"3":50,"5":"forward","7":"opening","11":"fully_open","102":true}}'
AVAILABLE DPS ARE [{'1': 'stop', '2': 33, '3': 50, '5': 'forward', '7': 'opening', '11': 'fully_open', '102': True}]
INFO:localtuya:COMPLETE response from device 18784500a4e57cb7b812 [10.1.1.40].

**** deviceInfo returned OK ****

TuyaDebug (Tuya DPs dump) [1.0.0]

Device 18784500a4e57cb7b812 at 10.1.1.40 key ff85d140ea97720f protocol 3.3 dev_type type_0a:
    DPS [1] VALUE [stop]
    DPS [2] VALUE [33]
    DPS [3] VALUE [50]
    DPS [5] VALUE [forward]
    DPS [7] VALUE [opening]
    DPS [11] VALUE [fully_open]
    DPS [102] VALUE [True]

@donburch888
Copy link
Author

Actually simbesh, I think those look OK.

Have you got the Device Specification Attribute from the Tuya IOT Platform website ? LocalTuya only shows the DP_ID number and current value - but the Tuya IoT Device Specification (once it's formatted) shows a name (which they call "code"), variable type, and range of possible values for each dp_id ... which makes it so much easier to guess what they are for. This thread has a better explanation.

Device 18784500a4e57cb7b812 at 10.1.1.40 key ff85d140ea97720f protocol 3.3 dev_type type_0a:
DPS [1] VALUE [stop]
DPS [2] VALUE [33]
DPS [3] VALUE [50]

My guess (based only on my own blind motor) is that DP_ID #1 is the main control mechanism, possibly with values "open", "close" and "stop"; and at the time you ran the above test.py the blind was stopped 33% closed.

In this thread i found that the Tuya IoT website has two menu entries for almost the same thing. Confusing :-(

@simbesh
Copy link

simbesh commented Jun 9, 2022

Hi Don,
I yep you are correct, 50 and 33 represent the set and current positions. however, it looks like there is no suitable option for the ID field the wizard requires:

image
image

@simbesh
Copy link

simbesh commented Jun 9, 2022

@donburch888 looks like ID is just looking for the state of the device and not an actual ID. added it as 1 and it seems to be working fine

@donburch888
Copy link
Author

Actually simbesh, I think those look OK.

Have you got the Device Specification Attribute from the Tuya IOT Platform website ? LocalTuya only shows the DP_ID number and current value - but the Tuya IoT Device Specification (once it's formatted) shows a name (which they call "code"), variable type, and range of possible values for each dp_id ... which makes it so much easier to guess what they are for. This thread has a better explanation.

Device 18784500a4e57cb7b812 at 10.1.1.40 key ff85d140ea97720f protocol 3.3 dev_type type_0a:
DPS [1] VALUE [stop]
DPS [2] VALUE [33]
DPS [3] VALUE [50]

My guess (based only on my own blind motor) is that DP_ID #1 is the main control mechanism, possibly with values "open", "close" and "stop"; and at the time you ran the above test.py the blind was stopped 33% closed.

In this thread i found that the Tuya IoT website has two menu entries for almost the same thing. Confusing :-(

@donburch888
Copy link
Author

I just updated my Home Assistant, and the LocalTuya inrtegration ... and tried to update one og my plugs.

It appears that all the dp_id's are back; so as far as I am concerned this issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants