xZetsubou / hass-localtuya

🔹 A Home Assistant integration to handle Tuya devices locally "fork from localtuya"
https://xzetsubou.github.io/hass-localtuya/
GNU General Public License v3.0
378 stars 43 forks source link

[Bug]: Thermostat is not detected automaticaly #319

Closed salos1982 closed 4 weeks ago

salos1982 commented 1 month ago

LocalTuya Version

2024.7.0

Home Assistant Version

2024.7.3

Environment

What happened?

I bought 2 new thermostats and added them to Tuya account. But when I'm trying to add these devices I see only some strange device IDs that I haven't added. image

There are no my devices in suggested devices. I made a screenshot from tuya developer image

Steps to reproduce.

Open Local Tuya Integration Click Setup Choose setup new device

Relevant log output

No response

Diagnostics information.

No response

xZetsubou commented 1 month ago

I can see that it detected device but not sure, Post the entry diagnostics.

salos1982 commented 1 month ago

home-assistant_localtuya_2024-08-05T08-52-35.607Z.log After updating Home Assistant to 2024.7.4 and reloading the wrong entities disappeared but local tuya still does not see my thermostats. There are no errors in logs

xZetsubou commented 1 month ago

Post the entry diagnostics

salos1982 commented 1 month ago

Diagnostic config_entry-localtuya-a4d08903b44ef944bbf42c78a89d95f3.json

xZetsubou commented 1 month ago

Have you tried to add the device manually? From the discovered devices list select add device manually then insert this bf4cd8b340a31d2fdfk8ww into device id field now in the name, ip, and localkey just instead any incorrect value for example xxxxxxxxx then click submit an error will shows up but the incorrect fields will be re-written with correct data. now in protocol version select "auto" then try to connect..

salos1982 commented 1 month ago

image I found this thermostat ip in my router but I still have the same error An unknown error occurred. [Errno 111] Connect call failed ('192.168.1.28', 6668). Official Tuya addon see the thermostats. The one thing that is quite interesting. When I try to check the connection to the thermostat from Tuya App it also could not reach the device but I can change temperature from the app.

xZetsubou commented 1 month ago

That is weird so basically the device doesn't expose it self locally? can you try to check if "6668" port is open on the device?

Using Powershell on windows: change 192.168.1.102 to your device ip

Test-NetConnection -ComputerName 192.168.1.102 -Port 6668

success results:

PS C:\WINDOWS\system32> Test-NetConnection -ComputerName 192.168.1.103 -Port 6668

ComputerName     : 192.168.1.103
RemoteAddress    : 192.168.1.103
RemotePort       : 6668
InterfaceAlias   : Ethernet
SourceAddress    : 192.168.1.18
TcpTestSucceeded : True

Also do you have the link product of your device?

salos1982 commented 1 month ago
WARNING : TCP connect to (192.168.1.28 : 6668) failed                                                             

ComputerName           : 192.168.1.28
RemoteAddress          : 192.168.1.28
RemotePort             : 6668
InterfaceAlias         : Ethernet
SourceAddress          : 192.168.1.20
PingSucceeded          : True
PingReplyDetails (RTT) : 943 ms
TcpTestSucceeded       : False

Link to Product

xZetsubou commented 1 month ago

If the device runs on batteries then it may be a low-power device so let's test if this is low-power device or not.

  1. Add the device with the correct inputs.
  2. in manual DPS add 0
  3. in Sleep time specify a number of average sleep device for the device to test use 86400 which is 1 day.
  4. Add the device.

It will probably goes to the next steps however if the status didn't shows up wait for the device to wake up and reports the status. If it takes long time without updating the status on Home Assistant then something is off, however if the device running on batteries then it most likely low-power device.

salos1982 commented 1 month ago

image I've set parameters like in the screenshot. However the same error

xZetsubou commented 1 month ago

I've set parameters like in the screenshot. However the same error

Try 3.4 protocol version instead of auto.

salos1982 commented 1 month ago

Changing protocol helps me to add the device but I have no data from it. Every sensor is disabled. home-assistant_localtuya_2024-08-09T05-39-27.121Z.log

xZetsubou commented 1 month ago

If the sensors hasn't been updated for the whole day I no longer think this is a low-power device.

How did you set-up the device? Wifi-Direct or the device connected to Router? or Are you using Gateway? Can you control the device using Cellular network away from the device?

salos1982 commented 1 month ago

I connected it with wifi. Nothing special, I switched to connection mode then in the Tuya app found the device and added it. I have no hubs or gateways. I probably need to switch to connection mode on the device. I already added the devices using the official Tuya integration. Thanks for you work.

Leo83-hash commented 1 month ago

I have the exact same issue. Did you manage to make your thermostat work?

I think it is just like PIR sensor, it must be added the exact same moment it connects to wifi, reporting its state. But in the case of this temperature/humidity sensor, I am not sure how to trigger the connection to add it in the right time.

In my case, both PIR and temp sensor are generic ones, bought from Aliexpress. They work with batteries.


I was mistaken, it is possible to connect to the device right away when putting batteries on it, but no data as salos1982 wrote before.

salos1982 commented 1 month ago

I have the exact same issue. Did you manage to make your thermostat work?

I think it is just like PIR sensor, it must be added the exact same moment it connects to wifi, reporting its state. But in the case of this temperature/humidity sensor, I am not sure how to trigger the connection to add it in the right time.

In my case, both PIR and temp sensor are generic ones, bought from Aliexpress. They work with batteries.

I was mistaken, it is possible to connect to the device right away when putting batteries on it, but no data as salos1982 wrote before.

No, I didn't manage. For me is ok to use a thermostat with online Tuya integration. I spent a lot of time trying to make it work.

xZetsubou commented 1 month ago

The issue is that the device it self reports that the port is closed https://github.com/xZetsubou/hass-localtuya/issues/319#issuecomment-2271270420 so I assumed that it low-power device, Also closed port can be happen if another connection is active with the device e.g. "smart life or any other Local integration"

I was mistaken, it is possible to connect to the device right away when putting batteries on it, but no data as salos1982 wrote before.

I have low-power device (Temperature & Humidity Sensor) I can connect to it when it wakes up however I don't do this always because If I know the IP of that device I can just add it and specify sleep time with 0 in manual DPS https://github.com/xZetsubou/hass-localtuya/issues/319#issuecomment-2272835916 now if the device wakes up later localtuya will update the entities,

Note: The low-power devices shows in discovered devices "even if it not connectable because it maybe is sleep" but salos1982 seems it devices not showing up at all this could happen only if the device is not connected directly to the router e.g. Wifi Direct or Bluetooth, or the port is closed because it busy.

To be honest I'm more confused why the device didn't get discovered instead of not connectable ^^ it should at least shows in discovered devices even after some hours.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.