Closed Dema323 closed 3 years ago
Are you pulling data from Tuya's cloud API or locally directly from the device?
i think locally ? i used the example code from the github, also no api calls are counted on my tuya developer account
Hmm, are you polling the device for updates or waiting for updates to be sent? Can you post your script?
Based on the research I've seen and a few dumps I've received from other users, when the app is open it's constantly sending a request to update the data, some mysterious "Command 18" type that seems un-documented. Some additional details are here:
Huh, interesting.
I think in this case it's probably the user's responsibility to request updates with that if they want. @Dema323, would you be able to try adding that and see if it works? Might be worth adding a note to the README about.
@codetheweb How could the user request the updates if TuyAPI doesn't have any way to send a command 18 to the device?
From my perspective the work required is to first figure out the exact structure of the packet (it looks like a 3.1 protocol packet with command type 18 and otherwise empty, basically like a heartbeat packet).
I actually almost wonder if "command 18" is just a new type of heatbeat packet. Perhaps a config option that uses command 18 instead of command 9 for heartbeat, just like some Tuya implementations have a config option to use command 13 instead of command 7 for control packets (I think TuyAPI also has an issue open about supporting devices that use command 13).
I had originally planned to try to do this work myself, but I've decided that Tuya seems intent on making it difficult to control your devices locally and I'm just going to give up my Tuya devices completely (I only have 4 left anyway, and 2 are easily converted to Tasmota, I'll just replace the other 2). While I believe I could implement the required changes in TuyAPI, I'm just no longer sure it's worth the effort.
@codetheweb I just realized that perhaps there was a misunderstanding here. While a user can certainly query the DPS values every 1 second if they want to, the issue is that doing this does not help. Based on what I can tell these devices don't update their DPS values unless the command 18 packet is sent to them.
And not all devices even update every 30 seconds, some only do it every 5 or 10 minutes. For example, I had a user that had a power monitoring outlet strip. He received updates ~every 300 seconds via tuya-mqtt. In tuya-mqtt I have an option to force an update, which directly queries the DPS values, but even when he did this, his device returned the same values for 300 seconds. However, if he opened the app, suddenly he would get updates every few seconds and the DPS values would actually change.
When looking at the packet trace with tuyadump of the app locally controlling the device, you could see the command 18 packets being sent which seemed to be the trigger to force the device to update the internal DPS values with the most recent values for power consumption.
Basically, without the ability to send this mysterious "Command 18" to the device, there appears to be no way to get more frequent updates.
Some more details in another project that appears to have implemented command 18. https://github.com/jasonacox/tinytuya/issues/8
im planning on just flashing tasmota and using mqtt.
@Dema323 yes, that always good idea whenever its possible. Unfortunately tuya started massively using non esp chips.
@Dema323 yes, that always good idea whenever its possible. Unfortunately tuya started massively using non esp chips.
I know, i bought 2 with no esp in them. But i got some that arrived today that should have esp's in them
While I believe I could implement the required changes in TuyAPI, I'm just no longer sure it's worth the effort.
Gotta agree with you there. 😛
Thanks for the additional information, I think I understand now. Unfortunately I don't have any devices that would require this so I can't really implement / test it.
While I believe I could implement the required changes in TuyAPI, I'm just no longer sure it's worth the effort.
Gotta agree with you there. 😛
Thanks for the additional information, I think I understand now. Unfortunately I don't have any devices that would require this so I can't really implement / test it.
I think most of us was suprised, when we discover that those devices arent esp anymore. Thats why I can see lot of 2-3years old projects for local tuya are reborn :D Any kind of local tuya project - nodejs, python, mqttt, power monitoring, node red integrations :D
I started implementing it, but I just need find more time to understand how nodejs is workig :D
Now seems to be working pretty well. Please check/test and provide feedback.
>node _debug.js Connected to device! DP_REFRESH data: { dps: { '19': 127 }, t: 1613388138 } Data from device: { dps: { '1': true, '9': 0, '17': 10, '18': 87, '19': 127, '20': 2466, '38': 'off', '41': '', '42': '', '43': '' } } Boolean status of default property: true. Data from device: { dps: { '1': false }, t: 1613388139 } Boolean status of default property: false. Disconnected from device.
Closed by #417.
Not a bug, more a question
When my phone is off or the app is not open im getting new data every 30s from the power plug. (consumption data) But when the i have Smart life open the data gets updated every 1-2s. Has anyone been able to get new data every second or so without having the app open ? Thanks