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

device22 type devices unable to connect if they do not have dp id 1 #451

Closed
nyok92 opened this issue Feb 22, 2023 · 8 comments
Closed

device22 type devices unable to connect if they do not have dp id 1 #451

nyok92 opened this issue Feb 22, 2023 · 8 comments

Comments

@nyok92
Copy link
Contributor

nyok92 commented Feb 22, 2023

Can't add new device :
Already reset it from the TUYA app, and add the new local key: still not working
Used Main branch
Home assistant docker 2023.2.5

Logger: custom_components.tuya_local.config_flow
Source: custom_components/tuya_local/config_flow.py:41
Integration: Tuya Local (documentation, issues)
First occurred: 12:41:25 (4 occurrences)
Last logged: 13:07:18

Unable to find device on network (specify IP address)

Logger: homeassistant.util.async_
Source: util/async_.py:182
First occurred: 12:41:42 (2 occurrences)
Last logged: 12:43:27

Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for tuya_local doing blocking calls at custom_components/tuya_local/device.py, line 70: self._api = tinytuya.Device(dev_id, address, local_key)

@nyok92 nyok92 added the bug Something isn't working label Feb 22, 2023
@make-all
Copy link
Owner

Unable to find device on network (specify IP address)

It seems you have not specified the IP address.

@make-all make-all removed the bug Something isn't working label Feb 22, 2023
@nyok92
Copy link
Contributor Author

nyok92 commented Feb 22, 2023

sorry , i wrote the wrong error issue . No w with IP Set i've got "Unable to connect to your device with those details. It could be an intermittent issue, or they may be incorrect."

@make-all
Copy link
Owner

Connection issues can be caused by any number of things. Do you have the mobile app open on the local network? Is localtuya already configured for this device? Do you have a separate Wifi network for your smart devices? is your docker networking set up correctly?

@n103
Copy link

n103 commented Mar 5, 2023

(Force) closing the android app worked for me. Thanks!

@nyok92
Copy link
Contributor Author

nyok92 commented Mar 7, 2023

hello make-all,
My mobile app is closed.

Here are debug log :

2023-03-07 14:28:35.819 DEBUG (MainThread) [custom_components.tuya_local.device] Refreshing device state for Test
2023-03-07 14:28:35.820 INFO (MainThread) [custom_components.tuya_local.device] Setting protocol version for Test to 3.3
2023-03-07 14:28:35.824 DEBUG (SyncWorker_18) [tinytuya.core] status() entry (dev_type is default)
2023-03-07 14:28:35.825 DEBUG (SyncWorker_18) [tinytuya.core] building command 10 payload=b'{"gwId":"hwxd4e6ede69af70bef6","devId":"hwxd4e6ede69af70bef6","uid":"hwxd4e6ede69af70bef6","t":"1678195715"}'
2023-03-07 14:28:35.832 DEBUG (SyncWorker_18) [tinytuya.core] sending payload
2023-03-07 14:28:35.833 DEBUG (SyncWorker_18) [tinytuya.core] payload encrypted=b'000055aa000000010000000a000000789e2db94fe4446f58ed2b86db74335c7c26bc17992bf0be3ab0b08245a3395cd1c41962c25d18745f4d99740eef329f2bce323914b17d6bd974b22b72dedbaf524af74ffc5f9f220c1e154d2aba4b222fae984ad245ab91ca1c7480481a42f24ade8d7c8ac9a813dd40d1da2c2fcd40f74c384b350000aa55'
2023-03-07 14:28:35.845 DEBUG (SyncWorker_18) [tinytuya.core] received data=b'000055aa000000010000000a0000002c00000001663b112c52e9b13db8b682ad720888dfe5add1416bdeca84d639f6cd667823b86507f2700000aa55'
2023-03-07 14:28:35.845 DEBUG (SyncWorker_18) [tinytuya.core] received message=TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'f;\x11,R\xe9\xb1=\xb8\xb6\x82\xadr\x08\x88\xdf\xe5\xad\xd1Ak\xde\xca\x84\xd69\xf6\xcdfx#\xb8', crc=1695019632, crc_good=True, prefix=21930, iv=None)
2023-03-07 14:28:35.846 DEBUG (SyncWorker_18) [tinytuya.core] raw unpacked message = TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'f;\x11,R\xe9\xb1=\xb8\xb6\x82\xadr\x08\x88\xdf\xe5\xad\xd1Ak\xde\xca\x84\xd69\xf6\xcdfx#\xb8', crc=1695019632, crc_good=True, prefix=21930, iv=None)
2023-03-07 14:28:35.846 DEBUG (SyncWorker_18) [tinytuya.core] decode payload=b'f;\x11,R\xe9\xb1=\xb8\xb6\x82\xadr\x08\x88\xdf\xe5\xad\xd1Ak\xde\xca\x84\xd69\xf6\xcdfx#\xb8'
2023-03-07 14:28:35.846 DEBUG (SyncWorker_18) [tinytuya.core] decrypting=b'f;\x11,R\xe9\xb1=\xb8\xb6\x82\xadr\x08\x88\xdf\xe5\xad\xd1Ak\xde\xca\x84\xd69\xf6\xcdfx#\xb8'
2023-03-07 14:28:35.847 DEBUG (SyncWorker_18) [tinytuya.core] decrypted 3.x payload='json obj data unvalid'
2023-03-07 14:28:35.847 DEBUG (SyncWorker_18) [tinytuya.core] payload type = <class 'str'>
2023-03-07 14:28:35.847 DEBUG (SyncWorker_18) [tinytuya.core] 'data unvalid' error detected: switching to dev_type 'device22'
2023-03-07 14:28:35.848 DEBUG (SyncWorker_18) [tinytuya.core] _decode_payload() failed!
2023-03-07 14:28:35.848 DEBUG (SyncWorker_18) [tinytuya.core] Device22 detected and updated (default -> device22) - Update payload and try again
2023-03-07 14:28:35.848 DEBUG (SyncWorker_18) [tinytuya.core] ERROR Device22 Detected: Retry Command - 908 - payload: null
2023-03-07 14:28:35.849 DEBUG (SyncWorker_18) [tinytuya.core] status() received data={'Error': 'Device22 Detected: Retry Command', 'Err': '908', 'Payload': None}
2023-03-07 14:28:35.850 DEBUG (SyncWorker_18) [tinytuya.core] status() rebuilding payload for device22
2023-03-07 14:28:35.851 DEBUG (SyncWorker_18) [tinytuya.core] building command 10 payload=b'{"devId":"hwxd4e6ede69af70bef6","uid":"hwxd4e6ede69af70bef6","t":"1678195715","dps":{"1":null}}'
2023-03-07 14:28:35.857 DEBUG (SyncWorker_18) [tinytuya.core] sending payload
2023-03-07 14:28:35.858 DEBUG (SyncWorker_18) [tinytuya.core] payload encrypted=b'000055aa000000020000000d00000077332e33000000000000000000000000349a334f8e61b1b45f5a48487cad26109061383608428de36afe679bdedddaa3adbe3bccd7632a7127fc1283fc0af2e10e40bd76188cc9142f1c699f3640e82343439d891b01129f3f73780ef91785aa8f97ac9bb6acdbd20bcf00f098fa73db929b91280000aa55'
2023-03-07 14:28:35.871 DEBUG (SyncWorker_18) [tinytuya.core] received data=b'000055aa000000020000000d0000000c000000008de14f440000aa55'
2023-03-07 14:28:35.872 DEBUG (SyncWorker_18) [tinytuya.core] received null payload (TuyaMessage(seqno=2, cmd=13, retcode=0, payload=b'', crc=2380353348, crc_good=True, prefix=21930, iv=None)), fetch new one - retry 0 / 1
2023-03-07 14:28:40.873 DEBUG (SyncWorker_18) [custom_components.tuya_local.device] Test refreshed device state: null
2023-03-07 14:28:40.874 DEBUG (SyncWorker_18) [custom_components.tuya_local.device] new state (incl pending): {"updated_at": 0}

I managed to get DPS value with tinytuya directly on my host with following script:

import tinytuya

tinytuya.set_debug(True)

d = tinytuya.OutletDevice(
      dev_id="bf0a4a3a4eb3586d1czint",
      address="192.168.1.4",
      local_key="XXXXXXXXX",
      dev_type = "device22",
      version=3.3)

d.add_dps_to_request(101)

data = d.status()
print('Device status: %r' % data)

I've tried to a add manually mydevice.yaml on devices folder of tuya_local :

name: Momos choice Ceres Pet Feeder
product:
  - id: 8zrzjldq07tlxnlv
primary_entity:
  entity: switch
  name: Indicator light
  icon: "mdi:Alarm-light"
  dps:
    - id: 101
      type: boolean
      name: switch
secondary_entities:
  - entity: switch
    name: Timestamp
    category: config
    icon: "mdi:timer-outline"
    dps:
      - id: 104
        type: boolean
        name: switch
  - entity: switch
    name: Nightvision
    category: config
    icon: "mdi:weather-night"
    dps:
      - id: 108
        type: boolean
        name: switch
  - entity: number
    name: SD card
    category: config
    icon: "mdi:Sd"
    dps:
      - id: 109
        type: string
        name: value
        unit: GB
        range:
          min: 0
          max: 255
        mapping:
          - scale: 10000
  - entity: switch
    name: Record to SD
    category: config
    icon: "mdi:record-rec"
    dps:
      - id: 150
        type: boolean
        name: switch
  - entity: select
    name: Recording mode
    icon: "mdi:timer"
    category: config
    dps:
      - id: 151
        name: option
        type: string
        mapping:
          - dps_val: 1
            value: events only
          - dps_val: 2
            value: continuous
  - entity: number
    name: Timer feed
    category: config
    icon: "mdi:clock-outline"
    dps:
      - id: 237
        type: integer
        name: value
        unit: portions
        range:
          min: 0
          max: 5
  - entity: sensor
    name: Feeding record
    category: diagnostic
    icon: "mdi:paw-outline"
    dps:
      - id: 242
        type: integer
        name: sensor
        unit: portions

but the tinytuya script is rrequesting DPS value 1 (and there is no feedback with DPS value 1 on this device)
What could be wrong ?

@nyok92
Copy link
Contributor Author

nyok92 commented Mar 7, 2023

#507 I've added Device request with more infos thanks

@make-all make-all added the bug Something isn't working label Mar 11, 2023
@make-all make-all reopened this Mar 11, 2023
@make-all make-all changed the title Unable to connect to your device with those details. It could be an intermittent issue, or they may be incorrect. device22 type devices unable to connect if they do not have dp id 1 Mar 11, 2023
@Avsynthe
Copy link

Avsynthe commented Apr 8, 2023

I too am having the same issue of "Unable to connect to your device with those details. It could be an intermittent issue, or they may be incorrect." with the IP address set.

I've added a simple YAML config for my device but I'm not sure if it's working or if I've done it right:

name: Arlec Grid Connect Smart 40W 4000lm LED Batten Light
product:
  - id: 4how2apjkfgidnoe
    name: ELGD11HA
primary_entity:
  entity: light
  dps:
    - id: 20
      type: boolean
      name: switch
    - id: 22
      type: integer
      name: brightness
      range:
        min: 29
        max: 1000

Any help would be greatly appreciated

@make-all
Copy link
Owner

make-all commented Apr 8, 2023

There is already a generic "dimming lightbulb" that covers that dp layout, so you shouldn't need a new config. Likely this device is also affected by the same issue.

make-all added a commit that referenced this issue Apr 21, 2023
dpsUsed is required by device22 devices in order to get informmation back
from async_refresh.  For other devices it doesn't seem to be used.
Default if not specified is "1" only, which is not enough for some devices.
Other common starting points for dps are 20 and 101.

Issue #451
@make-all make-all added awaiting confirmation Wating for confirmation the issue is solved unreleased Will be in next release labels Apr 21, 2023
@make-all make-all removed bug Something isn't working awaiting confirmation Wating for confirmation the issue is solved unreleased Will be in next release labels Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants