rospogrigio / localtuya

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

Error on add a new device. Tuya WiFi Temperature and Humidity Sensor TH08 #1617

Open dmitrkov opened 8 months ago

dmitrkov commented 8 months ago

The problem

Error on add a new device. Tuya WiFi Temperature and Humidity Sensor TH08 https://www.aliexpress.com/item/1005005869866043.html

Environment

Steps to reproduce

  1. Add new device
  2. Pick automatically discovered devic
  3. Set name and local id
  4. Send

DP dump

Provide Home Assistant traceback/logs

Logger: custom_components.localtuya.config_flow
Source: custom_components/localtuya/config_flow.py:595
Integration: LocalTuya integration (documentation, issues)
First occurred: 12:35:14 (5 occurrences)
Last logged: 12:53:43

Unexpected exception: [Errno 113] Connect call failed ('192.168.50.55', 6668)
Traceback (most recent call last):
  File "/config/custom_components/localtuya/config_flow.py", line 595, in async_step_configure_device
    self.dps_strings = await validate_input(self.hass, user_input)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/config_flow.py", line 242, in validate_input
    interface = await pytuya.connect(
                ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/localtuya/pytuya/__init__.py", line 1182, in connect
    _, protocol = await loop.create_connection(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 628, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 668, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.50.55', 6668)
Shaolo commented 8 months ago

I don't know what happened, but most of us seem to be in this boat. The devices show up, but they can't be added to HA.

junemacaspac commented 8 months ago

I got the same issues

aizmob commented 8 months ago

No luck with this device too

dzabel commented 8 months ago

i was able to add mine using this way: https://github.com/rospogrigio/localtuya/issues/1426#issuecomment-1890196293

dmitrkov commented 8 months ago

i was able to add mine using this way: #1426 (comment)

Hmm, need to try. Thanks

dmitrkov commented 8 months ago

i was able to add mine using this way: #1426 (comment)

It was really possible to add the device this way. Only battary Id in my case is 4. But these sensors are permanently unavailable. Exactly, after a TH reboot the data shows up for a short period of time and then becomes unavailable again. I think this is because this device transmits data only once an hour

BroManDudeGuyPhD commented 8 months ago

You may need to manually query the DPS on the configuration during adding. There are 3 fields after the "Protocol Version" selection, one is called "Manual DPS"

Do you know how to query Tuya devices in the cloud? If not, these videos helped me https://www.youtube.com/watch?v=Q1ZShFJDvE0 https://www.youtube.com/watch?v=VCd0kYWLvMQ

In the Device Control > Query Properties query if you add the device ID you will get back a list of the dp_ids and vaguely what they do, enter the values you want to map there

I did NOT need to used bluestacks and all that mess, was able to get all the info from the Tuya IOT Platform

dmitrkov commented 8 months ago

You may need to manually query the DPS on the configuration during adding. There are 3 fields after the "Protocol Version" selection, one is called "Manual DPS"

Do you know how to query Tuya devices in the cloud? If not, these videos helped me https://www.youtube.com/watch?v=Q1ZShFJDvE0 https://www.youtube.com/watch?v=VCd0kYWLvMQ

In the Device Control > Query Properties query if you add the device ID you will get back a list of the dp_ids and vaguely what they do, enter the values you want to map there

I did NOT need to used bluestacks and all that mess, was able to get all the info from the Tuya IOT Platform

Thank you so much for this info

aizmob commented 8 months ago

Added successfully TH-08 device to HA (manually specifying its DPS). Reported values are correct, etc. But sensors are unavailable almost all the time, turning on for a few seconds only - after the device wakes up to make status report. Then deepsleep till the next sample.

The following message appears in system log: First occurred: 00:07:44 (248 occurrences) Last logged: 04:09:44 [bf5...aa3] Failed to connect to 192.168.14.120: [Errno 113] Connect call failed ('192.168.14.120', 6668) [bf5...aa3] Disconnected - waiting for discovery broadcast

248 occurences / 4 hours ~ 1 call per minute.

Smartlife mobile app and native Tuya integration are working fine.

ishimarumakoto commented 6 months ago

Having problem here today too.