rospogrigio / localtuya

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

Can't add my Pool Heater (Garden Pac Inverter) to Local Tuya #1710

Open paazevedo opened 1 month ago

paazevedo commented 1 month ago

The problem

Not able to connect my Pool Heater (Garden Pac Pool Heater with Local Tuya integration. It detects the device, but when I try to add it, it gives me the following error: 3678 2024-05-08 14:04:56.495 DEBUG (MainThread) [custom_components.localtuya.pytuya] [800...188] ERROR Unexpected Payload from Device - 904 - payload: null

Environment

Home Assistant (docker container running on Synology NAS) localtuya latest one available to the date Core 2024.4.1 Frontend 20240404.1

Steps to reproduce

  1. After installing the custom_integration, I skip the cloud config
  2. Going to the Devices&Services, clicking on the vertical (...) I'm able to add the device and identify 2 devices image
  3. When I add the local key and add the device name, it gives me the following error: image

DP dump

DEBUG:localtuya.pytuya:[800...188] Command 10 waiting for sequence number 1
DEBUG:localtuya.pytuya:[800...188] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'\xa4\x03\xc6\xda\x99K\xe4\xeb\xcf)\x03\xb3\xb8\xb2\xa2\x02K\xf8X\xea\xa0,l\x014\x8fi\xa0\xb8\xbf\xc6\xb9', crc=153091458, crc_good=True)
DEBUG:localtuya.pytuya:[800...188] Deciphered data = ''
DEBUG:localtuya.pytuya:[800...188] ERROR Invalid JSON Response from Device - 900 - payload: ""
AVAILABLE DPS ARE [{}]
INFO:localtuya:COMPLETE response from device 800702032cf43203d188 [192.168.1.99].
**** deviceInfo returned OK ****
TuyaDebug (Tuya DPs dump) [1.0.0]

TinyTuyaDump

DEBUG:tinytuya.scanner:Invalid UDP Packet: {'ip': '192.168.1.99'}
Unknown v Device   Product ID =   [Unknown payload]:
    Address = 192.168.1.99,  Device ID = , Local Key = ,  Version = , MAC =
    No Stats for 192.168.1.99: DEVICE KEY required to poll for status
*  Unexpected payload=%r
 b'\xd0\x97fgo3i\xeb\x10\xb5\xe9\xf12\xfd\x80*\x96\x8f\xe9\x07\xf9\xa7\xd5:4\x05\x8cd\xdd~\x84)\xcd\xd1\t\xaa\xe3H\x8f\x8ex2\xd9\x1cxg\xee`?\xfbGOT\x12\x85\xa3\xf9\xe0\x82\xf7\xa7[\xeffrV\xf9\x92\xef\x0b\xb3\xc9\x94ol\xa8\xe2\xe1HS.\r\xbc\x9a\x92\xc31r\x86\xeb\xf28\xbeW\x97\x86\x08\xf3UQ\xa3\xa7\x1b\x8d\x1dC\xbdo8\xbd*!Y\x1b\xcb\xaei\xb8\xc2\x9e\x9f\xd6\x15\xda\x05\x03\xe2ko\xbd\xac>\x9d\xd4\xc5\x9e\xd6\x07z7\x13\xa1\xf54\xc5\xf7\\\xc6\x9cj\x0e\x151`\xa1{\xc4\n\xcc\x9b\xf7\x10\xaa\xe3\x02u\x84W\x04\xb3Gi\xa7\xf2\x18\x1a'

Provide Home Assistant traceback/logs

2716 2024-05-08 14:02:13.860 DEBUG (MainThread) [custom_components.localtuya.discovery] Discovered device: {'ip': '192.168.1.99', 'gwId': '800702032cf43203d188', 'active': 2, 'ability': 0, 'mode': 0, 'encrypt': True, 'productKey': 'qrlLaHWwIsZsV31f', 'version': '3.3'}
3673 2024-05-08 14:04:56.477 DEBUG (MainThread) [custom_components.localtuya.pytuya] [800...188] Sending command 10 (device type: type_0a)
3674 2024-05-08 14:04:56.477 DEBUG (MainThread) [custom_components.localtuya.pytuya] [800...188] Sending payload: b'{"gwId":"800702032cf43203d188","devId":"800702032cf43203d188","uid":"800702032cf43203d188","t":"1715177096"}'
3675 2024-05-08 14:04:56.481 DEBUG (MainThread) [custom_components.localtuya.pytuya] [800...188] Command 10 waiting for seq. number 1
3676 2024-05-08 14:04:56.492 DEBUG (MainThread) [custom_components.localtuya.pytuya] [800...188] Dispatching message CMD 10 TuyaMessage(seqno=1, cmd=10, retcode=1, payload=b'\xa4\x03\xc6\xda\x99K\xe4\xeb\xcf)\x03\xb3\xb8\xb2\xa2\x02K\xf8X\xea\xa0,l\x014\x8fi\xa0\xb8\xbf\xc6\xb9', crc=153091458, crc_good=True)
3677 2024-05-08 14:04:56.495 DEBUG (MainThread) [custom_components.localtuya.pytuya] [800...188] incomplete payload=b'\xa4\x03\xc6\xda\x99K\xe4\xeb\xcf)\x03\xb3\xb8\xb2\xa2\x02K\xf8X\xea\xa0,l\x014\x8fi\xa0\xb8\xbf\xc6\xb9' with len:32 ('utf-8' codec can't decode byte 0xdc in position 5: invalid continuation byte)
3678 2024-05-08 14:04:56.495 DEBUG (MainThread) [custom_components.localtuya.pytuya] [800...188] ERROR Unexpected Payload from Device - 904 - payload: null
3679 2024-05-08 14:04:56.496 DEBUG (MainThread) [custom_components.localtuya.config_flow] Detected DPS: {}
3680 2024-05-08 14:04:56.496 DEBUG (MainThread) [custom_components.localtuya.pytuya] [800...188] Closing connection
3681 2024-05-08 14:04:56.505 DEBUG (MainThread) [custom_components.localtuya.pytuya] [800...188] Connection lost: None

Additional information

As stated from the SmartLife application, I'm able to see the Inverter and all the components: image From the Developer site under Tuya: It just shows a switch true or false, which leads me to think that currently this is what we'll be able to get. But there is anything we can do to get the rest of the parameters ?

image

hugoleosp commented 1 month ago

I have several devices I can't get the DP list, sometimes changing the protocol works, Local Tuya tries 3.3 version, and when I change to 3.4 it sometimes works again.

Another approach is to go to Tuya API Explorer and extract the DPs from there and add manually on Local Tuya, this worked for me in some devices.

But weird thing, I have a PIR (motion detection) that I had to use the manual approach and it worked for weeks, but all of a sudden it started to reject a few DPs with Local Tuya saying they're unsupported and the device wasn't updated for sure (I always turn this feature off as soon as I install them).

But try one of these two approaches and you might get your pool heated again. I had to do this with my solar controller, the official integration was only able to get switch/difference but not current temperature which I couldn't work out good automations.

A last suggestion you could try Tuya Local integration instead, it's more simplistic and no manual approach, but they update their devices list very often and I could get one circuit breaker working there that the Local Tuya couldn't.

paazevedo commented 1 month ago

Tuya API Explorer

@hugoleosp do appreciate your input\help. Well that's part of the problem, as you noticed above, on the Tuya Dev Environment I only see the switch capability. I give a try on the Tuya API explorer and using the "Get the instruction set of the device" for my inverter device ID, this is what I get:

{ "result": { "category": "rs", "functions": [ { "code": "switch", "desc": "switch", "name": "switch", "type": "Boolean", "values": "{}" } ] }, "success": true, "t": 1715340015315, "tid": "4649ae670ebf11ef960bd6dfde92944e" } But I I look into the Device logs, I'm able to see the different DP's and the changes : image

Indeed what I'm missing is indeed the DP's codes but I make no idea how we currently get get them. This seemed to work till 2021 but after that it's broken.

webhoffi commented 1 month ago

Are u running your HA container in host or in bridge mod? If in bridge mod forward port 6666-6668 inside the container.

paazevedo commented 1 month ago

Are u running your HA container in host or in bridge mod? If in bridge mod forward port 6666-6668 inside the container.

It's running on host I believe, I would need to go back and check the container settings, but do you mind to elaborate a bit more on why I would need to forward to those ports ? Asking this because if you notice in one of the screenshots I add above, the devices are found after the broadcast...the problem is what the device is returning...not the expected for the integration...