tuyapi icon indicating copy to clipboard operation
tuyapi copied to clipboard

Refresh-Method: Some devices might react strange and disconnect

Open Apollon77 opened this issue 4 years ago • 5 comments

A user have a device "LSC WLAN Video Doorbell" which is not supporting normal "get" operation and respinds with "json unvalid" error.

The try to get the known IDs via refresh results in an immediate "disconnect" from the device :-(

2021-04-02 13:21:28.257  - debug: tuya.0 (4097) xxxxxx: Error from device (0): App still open on your mobile phone? json obj data unvalid
2021-04-02 13:21:28.257  - debug: tuya.0 (4097) xxxxxx: Received data: {"1":null,"2":null,"3":null,"101":null,"102":null,"103":null}
2021-04-02 13:21:28.258  - debug: tuya.0 (4097) xxxxxx: Ignore invalid data (Counter: 1)
2021-04-02 13:21:28.357  - debug: tuya.0 (4097) xxxxxx request data via refresh for [103,104,106,108,109,110,111,115,117,134,136,150,151,154,160]
2021-04-02 13:21:28.416  - debug: tuya.0 (4097) xxxxxx: Disconnected from device

@stevoh6 did you also experienced such cases as you developed it?

I think the documentation should at least state that because it might be problematic

Apollon77 avatar Apr 02 '21 16:04 Apollon77

It really seems that some devices restart themself when receiving refresh calls :-( So you need to be very careful with the refresh method

Apollon77 avatar Apr 02 '21 17:04 Apollon77

Does this happen with other devices or just the doorbell? If it's just the doorbell I'd put it down to it being a weird video-enabled device.

codetheweb avatar Apr 05 '21 23:04 codetheweb

I have no idea because this was the only report where I saw it while experiementing with one user ...

For the refresh in general I experimented a bit with a user and in the end really ended up in checking if the schema I know contains any of the fields from ones defined for refresh in library and if yes use refresh (still waiting for a user report to see if that worked) and else do that "get via set command and "null" as value directly what is the refresh fallback.

Additionally i added a "device disonnected after refresh command before response" detection and never send a refresh then again ... but still waiting toget more user reports ...

Apollon77 avatar Apr 06 '21 08:04 Apollon77

I would propose to add an info to the refreshapi docs that t can happen so devs can be aware and maybe add a "refresh via set to null" method separately as second "refresh" option?

Apollon77 avatar Apr 06 '21 08:04 Apollon77

@Apollon77 I didnt experience such a problem since I dont own doorbell devices and even people who tested it didnt reported any problem. This is new. In documentation was a mention if you have a outlet wich didnt correctly report power usage, then try use dp-refresh, but I see that doorbels dont send dps:1 in data, thats why it causeing problems.

stevoh6 avatar Apr 06 '21 20:04 stevoh6