Page 11 of 19

Re: [REQUEST] Plugin for Tuya

Posted: Monday 15 April 2019 19:01
by merlot
The point is that if I use packet capture with its app I can see the packets that I guess are the ones expected

Code: Select all

{
  "result": {
    "devId": "51817282840d8e5f63cd",
    "dpMaxTime": 1555161839644,
    "virtual": false,
    "productId": "0fHWRe8ULjtmnBNd",
    "dps": {
      "22": 626,
      "23": 30727,
      "1": true,
      "24": 17543,
      "25": 1190,
      "26": 0,
      "17": 5,
      "18": 0,
      "19": 0,
      "9": 0,
      "20": 0,
      "21": 1
    },
    "activeTime": 1555161828,
    "ip": "89.141.147.40",
    "lon": "",
    "moduleMap": {
      "wifi": {
        "upgradeStatus": 3,
        "bv": "5.42",
        "cdv": "1.0.0",
        "pv": "2.2",
        "verSw": "1.0.7",
        "isOnline": true,
        "id": 8256355,
        "cadv": ""
      },
      "mcu": {
        "upgradeStatus": 0,
        "cdv": "",
        "verSw": "1.0.7",
        "isOnline": true,
        "id": 8256356,
        "cadv": ""
      }
    },
    "uuid": "51817282840d8e5f63cd",
    "mac": "84:0d:8e:5f:63:cd",
    "devAttribute": 3,
    "name": "Smart Socket-10A",
    "isShare": false,
    "timezoneId": "Europe/Madrid",
    "iconUrl": "https://images.tuyaeu.com/smart/icon/15324342875tjvmpp9uw8_0.png",
    "lat": "",
    "runtimeEnv": "prod",
    "localKey": "1a9ae1ca27591e4a"
  },
  "t": 1555161843633,
  "success": true,
  "status": "ok"
}
Is this packet as expected?

Thank you again

Enviado desde mi Redmi Note 4 mediante Tapatalk


Re: [REQUEST] Plugin for Tuya

Posted: Monday 15 April 2019 19:49
by sincze
That look excellent indeed. But with the provided py script for testing it is not working?? Right?

Re: [REQUEST] Plugin for Tuya

Posted: Monday 15 April 2019 19:58
by merlot
sincze wrote:That look excellent indeed. But with the provided py script for testing it is not working?? Right?
Yes, it's not working.

I'm using the IP, device ID and localkey you can see in the packet shown.

Have you got any suggestion?

Thank's a lot

Enviado desde mi Redmi Note 4 mediante Tapatalk


Re: [REQUEST] Plugin for Tuya

Posted: Saturday 20 April 2019 12:43
by merlot
Hi,
Following my research to try to find out why it's not working in my device, I have activated the Debug=1 and uncommented the Degug level setting in pytuya script.
And I don't understand this difference.
From the Packet Capture of the Smart Life the POST packet payload is:

"postData" = "{"devId":"51817282840d8e5f63cd"}"

However in the debug output of get_dps_py, I can see

DEBUG:pytuya:json_payload=b'{"devId":"51817282840d8e5f63cd","gwId":"51817282840d8e5f63cd"}'

Moreover, the POST in the packet capture seems to be using the URL api.json with several options

[truncated]POST /api.json?appVersion=3.9.1&appRnVersion=5.12&channel=oem&sign=252e265bb7106e66e692cf4766287707d906c691ebe5a971edc62acd4dc1a933&deviceId=bdc1041d291a540b18114de6f5acd3dcb0580c0a6881&platform=Redmi%20Note%204&sid=eu155509I38

But I'm not able to see which URL is using pytuya.

Finally, is the localkey not requiered in the get_dps.py?

Thank you very much

Re: [REQUEST] Plugin for Tuya

Posted: Saturday 20 April 2019 15:38
by sincze
merlot wrote: Saturday 20 April 2019 12:43 Hi,
Following my research to try to find out why it's not working in my device, I have activated the Debug=1 and uncommented the Degug level setting in pytuya script.
And I don't understand this difference.
From the Packet Capture of the Smart Life the POST packet payload is:

"postData" = "{"devId":"51817282840d8e5f63cd"}"

However in the debug output of get_dps_py, I can see

DEBUG:pytuya:json_payload=b'{"devId":"51817282840d8e5f63cd","gwId":"51817282840d8e5f63cd"}'

Moreover, the POST in the packet capture seems to be using the URL api.json with several options

[truncated]POST /api.json?appVersion=3.9.1&appRnVersion=5.12&channel=oem&sign=252e265bb7106e66e692cf4766287707d906c691ebe5a971edc62acd4dc1a933&deviceId=bdc1041d291a540b18114de6f5acd3dcb0580c0a6881&platform=Redmi%20Note%204&sid=eu155509I38

But I'm not able to see which URL is using pytuya.

Finally, is the localkey not requiered in the get_dps.py?

Thank you very much
To discover the url use the app via a fiddler proxy :)

Re: [REQUEST] Plugin for Tuya

Posted: Monday 06 May 2019 17:34
by mirmil99
Hello

unfortunately, but Neo DS01W (door/window sensor) does not work;( , no changes in the virtual switch... Of course, everything is properly installed.

Code: Select all

2019-05-06 16:50:45.221 Status: (Door_1) Started.
2019-05-06 16:50:45.630 Status: (Door_1) Entering work loop.
2019-05-06 16:50:45.631 Status: (Door_1) Initialized version 1.0.0, author 'tixi_sincze'

Code: Select all

(Door_1) Pushing 'onHeartbeatCallback' on to queue
2019-05-06 17:22:25.756 (Door_1) Processing 'onHeartbeatCallback' message
2019-05-06 17:22:25.756 (Door_1) Calling message handler 'onHeartbeat'.
2019-05-06 17:22:25.757 (Door_1) Pushing 'ConnectDirective' on to queue
2019-05-06 17:22:25.757 (Door_1) Processing 'ConnectDirective' message
2019-05-06 17:22:25.757 (Door_1) Transport set to: 'TCP/IP', 192.168.100.28:6668.
2019-05-06 17:22:25.757 (Door_1) Connect directive received, action initiated successfully.
2019-05-06 17:22:26.638 EventSystem: Event triggered: ..................................
2019-05-06 17:22:28.891 (Door_1) Pushing 'onConnectCallback' on to queue
2019-05-06 17:22:28.891 (Door_1) Pushing 'DisconnectedEvent' on to queue
2019-05-06 17:22:28.914 (Door_1) Processing 'onConnectCallback' message
2019-05-06 17:22:28.914 (Door_1) Calling message handler 'onConnect'.
2019-05-06 17:22:28.915 (Door_1) OnConnect Error Status: 113
2019-05-06 17:22:28.915 (Door_1) Processing 'DisconnectedEvent' message
2019-05-06 17:22:28.915 (Door_1) Disconnect event received for '192.168.100.28:6668'.
2019-05-06 17:22:28.915 (Door_1) Pushing 'onDisconnectCallback' on to queue
2019-05-06 17:22:28.915 (Door_1) Processing 'onDisconnectCallback' message
2019-05-06 17:22:28.915 (Door_1) Calling message handler 'onDisconnect'.
2019-05-06 17:23:28.914 (Door_1) Disconnected from: 192.168.100.28:6668

Code: Select all

 (Door_1) Transport set to: 'TCP/IP', 192.168.100.28:6668.
2019-05-06 17:29:26.205 (Door_1) Connect directive received, action initiated successfully.
2019-05-06 17:29:26.205 (Door_1) Processing 'onDisconnectCallback' message
2019-05-06 17:29:26.205 (Door_1) Calling message handler 'onDisconnect'.
2019-05-06 17:29:26.205 (Door_1) Disconnected from: 192.168.100.28:6668
2019-05-06 17:29:26.207 (Door_1) Pushing 'onConnectCallback' on to queue
2019-05-06 17:29:26.207 (Door_1) Pushing 'DisconnectedEvent' on to queue
2019-05-06 17:29:26.255 (Door_1) Processing 'onConnectCallback' message
2019-05-06 17:29:26.255 (Door_1) Calling message handler 'onConnect'.
2019-05-06 17:29:26.255 (Door_1) OnConnect Error Status: 111
2019-05-06 17:29:26.256 (Door_1) Pushing 'ConnectDirective' on to queue
2019-05-06 17:29:26.256 (Door_1) Processing 'DisconnectedEvent' message
2019-05-06 17:29:26.256 (Door_1) Disconnect event received for '192.168.100.28:6668'.
2019-05-06 17:29:26.256 (Door_1) Pushing 'onDisconnectCallback' on to queue
2019-05-06 17:29:26.256 (Door_1) Processing 'ConnectDirective' message
2019-05-06 17:29:26.256 (Door_1) Transport set to: 'TCP/IP', 192.168.100.28:6668.
2019-05-06 17:29:26.256 (Door_1) Connect directive received, action initiated successfully.
2019-05-06 17:29:26.256 (Door_1) Processing 'onDisconnectCallback' message
2019-05-06 17:29:26.256 (Door_1) Calling message handler 'onDisconnect'.
2019-05-06 17:29:26.256 (Door_1) Disconnected from: 192.168.100.28:6668
2019-05-06 17:29:26.261 (Door_1) Pushing 'onConnectCallback' on to queue
2019-05-06 17:29:26.261 (Door_1) Pushing 'DisconnectedEvent' on to queue
2019-05-06 17:29:26.306 (Door_1) Processing 'onConnectCallback' message
2019-05-06 17:29:26.306 (Door_1) Calling message handler 'onConnect'.
2019-05-06 17:29:26.306 (Door_1) OnConnect Error Status: 111
2019-05-06 17:29:26.306 (Door_1) Pushing 'ConnectDirective' on to queue
2019-05-06 17:29:26.306 (Door_1) Processing 'DisconnectedEvent' message
2019-05-06 17:29:26.306 (Door_1) Disconnect event received for '192.168.100.28:6668'.
2019-05-06 17:29:26.306 (Door_1) Pushing 'onDisconnectCallback' on to queue
2019-05-06 17:29:26.306 (Door_1) Processing 'ConnectDirective' message
2019-05-06 17:29:26.306 (Door_1) Transport set to: 'TCP/IP', 192.168.100.28:6668.
2019-05-06 17:29:26.307 (Door_1) Connect directive received, action initiated successfully.
2019-05-06 17:29:26.307 (Door_1) Processing 'onDisconnectCallback' message
2019-05-06 17:29:26.307 (Door_1) Calling message handler 'onDisconnect'.
2019-05-06 17:29:26.307 (Door_1) Disconnected from: 192.168.100.28:6668
2019-05-06 17:29:26.311 (Door_1) Pushing 'onConnectCallback' on to queue
2019-05-06 17:29:26.311 (Door_1) Pushing 'DisconnectedEvent' on to queue
2019-05-06 17:29:26.357 (Door_1) Processing 'onConnectCallback' message
2019-05-06 17:29:26.357 (Door_1) Calling message handler 'onConnect'.
2019-05-06 17:29:26.357 (Door_1) OnConnect Error Status: 111
2019-05-06 17:29:26.357 (Door_1) Pushing 'ConnectDirective' on to queue
2019-05-06 17:29:26.357 (Door_1) Processing 'DisconnectedEvent' message
2019-05-06 17:29:26.357 (Door_1) Disconnect event received for '192.168.100.28:6668'.
2019-05-06 17:29:26.357 (Door_1) Pushing 'onDisconnectCallback' on to queue
2019-05-06 17:29:26.358 (Door_1) Processing 'ConnectDirective' message
2019-05-06 17:29:26.358 (Door_1) Transport set to: 'TCP/IP', 192.168.100.28:6668.
2019-05-06 17:29:26.358 (Door_1) Connect directive received, action initiated successfully.
2019-05-06 17:29:26.358 (Door_1) Processing 'onDisconnectCallback' message
2019-05-06 17:29:26.358 (Door_1) Calling message handler 'onDisconnect'.
2019-05-06 17:29:26.358 (Door_1) Disconnected from: 192.168.100.28:6668
2019-05-06 17:29:26.361 (Door_1) Pushing 'onConnectCallback' on to queue
2019-05-06 17:29:26.361 (Door_1) Pushing 'DisconnectedEvent' on to queue
2019-05-06 17:29:26.408 (Door_1) Processing 'onConnectCallback' message
2019-05-06 17:29:26.408 (Door_1) Calling message handler 'onConnect'.
2019-05-06 17:29:26.408 (Door_1) OnConnect Error Status: 111
2019-05-06 17:29:26.408 (Door_1) Pushing 'ConnectDirective' on to queue
2019-05-06 17:29:26.408 (Door_1) Processing 'DisconnectedEvent' message
2019-05-06 17:29:26.408 (Door_1) Disconnect event received for '192.168.100.28:6668'.
2019-05-06 17:29:26.408 (Door_1) Pushing 'onDisconnectCallback' on to queue
2019-05-06 17:29:26.408 (Door_1) Processing 'ConnectDirective' message
2019-05-06 17:29:26.408 (Door_1) Transport set to: 'TCP/IP', 192.168.100.28:6668.
2019-05-06 17:29:26.409 (Door_1) Connect directive received, action initiated successfully.
2019-05-06 17:29:26.409 (Door_1) Processing 'onDisconnectCallback' message
2019-05-06 17:29:26.409 (Door_1) Calling message handler 'onDisconnect'.
2019-05-06 17:29:26.409 (Door_1) Disconnected from: 192.168.100.28:6668
2019-05-06 17:29:26.410 (Door_1) Pushing 'onConnectCallback' on to queue
2019-05-06 17:29:26.410 (Door_1) Pushing 'DisconnectedEvent' on to queue
2019-05-06 17:29:26.459 (Door_1) Processing 'onConnectCallback' message
2019-05-06 17:29:26.459 (Door_1) Calling message handler 'onConnect'.
2019-05-06 17:29:26.459 (Door_1) OnConnect Error Status: 111
2019-05-06 17:29:26.459 (Door_1) Pushing 'ConnectDirective' on to queue
2019-05-06 17:29:26.459 (Door_1) Processing 'DisconnectedEvent' message
2019-05-06 17:29:26.459 (Door_1) Disconnect event received for '192.168.100.28:6668'.
2019-05-06 17:29:26.459 (Door_1) Pushing 'onDisconnectCallback' on to queue
2019-05-06 17:29:26.459 (Door_1) Processing 'ConnectDirective' message
2019-05-06 17:29:26.459 (Door_1) Transport set to: 'TCP/IP', 192.168.100.28:6668.
2019-05-06 17:29:26.459 (Door_1) Connect directive received, action initiated successfully.
2019-05-06 17:29:26.459 (Door_1) Processing 'onDisconnectCallback' message
2019-05-06 17:29:26.459 (Door_1) Calling message handler 'onDisconnect'.
2019-05-06 17:29:26.459 (Door_1) Disconnected from: 192.168.100.28:6668
2019-05-06 17:29:26.461 (Door_1) Pushing 'onConnectCallback' on to queue
2019-05-06 17:29:26.461 (Door_1) Pushing 'DisconnectedEvent' on to queue
2019-05-06 17:29:26.509 (Door_1) Processing 'onConnectCallback' message
2019-05-06 17:29:26.510 (Door_1) Calling message handler 'onConnect'.
2019-05-06 17:29:26.510 (Door_1) OnConnect Error Status: 111
2019-05-06 17:29:26.510 (Door_1) Pushing 'ConnectDirective' on to queue
2019-05-06 17:29:26.510 (Door_1) Processing 'DisconnectedEvent' message
2019-05-06 17:29:26.510 (Door_1) Disconnect event received for '192.168.100.28:6668'.
2019-05-06 17:29:26.510 (Door_1) Pushing 'onDisconnectCallback' on to queue
2019-05-06 17:29:26.510 (Door_1) Processing 'ConnectDirective' message
2019-05-06 17:29:26.510 (Door_1) Transport set to: 'TCP/IP', 192.168.100.28:6668.
2019-05-06 17:29:26.510 (Door_1) Connect directive received, action initiated successfully.
2019-05-06 17:29:26.510 (Door_1) Processing 'onDisconnectCallback' message
2019-05-06 17:29:26.510 (Door_1) Calling message handler 'onDisconnect'.
2019-05-06 17:29:26.510 (Door_1) Disconnected from: 192.168.100.28:6668

Re: [REQUEST] Plugin for Tuya

Posted: Monday 06 May 2019 18:11
by sincze
What is the outcome of getdps.py?

As stated in the readme:
A Domoticz plugin to manage Tuya Smart Plug (single and multi socket device) This is a modified plugin from the original by Tixi, The original plugin only supported an On/Off switch. Now meters for Watt, Voltage, Ampere, kWh (calculated) are also created.

The plugin was not tested with a NEO door window sensor. As it is not a powerplug. But indeed interesting enough Maybe to extend the plugin ( if not ready existing of course) :)

Re: [REQUEST] Plugin for Tuya

Posted: Monday 06 May 2019 19:00
by mirmil99
Thank you for your interest...
But indeed interesting enough Maybe to extend the plugin
would be nice;)

getdps.py...

Code: Select all

osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
.
.
.

Re: [REQUEST] Plugin for Tuya

Posted: Monday 06 May 2019 20:17
by jslegers
mirmil99 wrote: Monday 06 May 2019 19:00 Thank you for your interest...
But indeed interesting enough Maybe to extend the plugin
would be nice;)

getdps.py...

Code: Select all

osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
.
.
.
Hi I have seen this error also maybe stop domoticz or stop the App on the phone if you are using it. And then try it again.

Re: [REQUEST] Plugin for Tuya

Posted: Monday 06 May 2019 21:12
by sincze
Tnx @jslegers for the tip
Let's wait and find out what happens.

Re: [REQUEST] Plugin for Tuya

Posted: Tuesday 07 May 2019 8:59
by mirmil99
the app on the phone was already switched off...

domoticz - stop, and...

Code: Select all

osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
.
.
.

Re: [REQUEST] Plugin for Tuya

Posted: Thursday 16 May 2019 14:57
by wvries
mirmil99 wrote: Tuesday 07 May 2019 8:59 the app on the phone was already switched off...

domoticz - stop, and...

Code: Select all

osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
.
.
.
Same problem here...

Code: Select all

pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390

Plug State Information:
{'devId': '46268374840d8e953390', 'dps': {'25': 1200, '9': 0, '19': 49, '22': 638, '21': 1, '23': 30205, '20': 2304, '1': True, '24': 17250, '18': 36}}

Plug DPS List:
1
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390

Plug State Information:
{'devId': '46268374840d8e953390', 'dps': {'1': True, '19': 49, '22': 638, '23': 30205, '24': 17250, '9': 0, '20': 2304, '25': 1200, '18': 36, '21': 1}}

Plug DPS List:
1
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390

Plug State Information:
{'devId': '46268374840d8e953390', 'dps': {'24': 17250, '20': 2304, '19': 49, '18': 36, '21': 1, '22': 638, '9': 0, '1': True, '23': 30205, '25': 1200}}

Plug DPS List:
1
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
sometimes I get an answer back, most of the time not.
And, the structure seems also not constant (e.g. the True pops up in different locations sometimes)

Running DZ 4.10710

Switching on / Off works fine, no problem there.

Do get errors in the log

Code: Select all

2019-05-16 14:56:01.261 Error: (TSP 1) 'onMessage' failed 'KeyError'.
2019-05-16 14:56:01.261 Error: (TSP 1) ----> Line 531 in '/home/pi/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py', function onMessage
2019-05-16 14:56:01.261 Error: (TSP 1) ----> Line 439 in '/home/pi/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py', function onMessage
EDIT:
Solved the error - make sure the right ID's for voltage etc are in the plugin !!!!!

Re: [REQUEST] Plugin for Tuya

Posted: Thursday 16 May 2019 21:05
by sincze
wvries wrote:
mirmil99 wrote: Tuesday 07 May 2019 8:59 the app on the phone was already switched off...

domoticz - stop, and...

Code: Select all

osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
osmc@Malina:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin$ ./get_dps.py 192.168.100.28 87532803bcddc295e153
A problem occur please retry...
.
.
.
Same problem here...

Code: Select all

pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390

Plug State Information:
{'devId': '46268374840d8e953390', 'dps': {'25': 1200, '9': 0, '19': 49, '22': 638, '21': 1, '23': 30205, '20': 2304, '1': True, '24': 17250, '18': 36}}

Plug DPS List:
1
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390

Plug State Information:
{'devId': '46268374840d8e953390', 'dps': {'1': True, '19': 49, '22': 638, '23': 30205, '24': 17250, '9': 0, '20': 2304, '25': 1200, '18': 36, '21': 1}}

Plug DPS List:
1
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390

Plug State Information:
{'devId': '46268374840d8e953390', 'dps': {'24': 17250, '20': 2304, '19': 49, '18': 36, '21': 1, '22': 638, '9': 0, '1': True, '23': 30205, '25': 1200}}

Plug DPS List:
1
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
pi@Domoticz-Server:~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ sudo python3 get_dps.py 192.168.0.50 46268374840d8e953390
A problem occur please retry...
sometimes I get an answer back, most of the time not.
And, the structure seems also not constant (e.g. the True pops up in different locations sometimes)

Running DZ 4.10710

Switching on / Off works fine, no problem there.

Do get errors in the log

Code: Select all

2019-05-16 14:56:01.261 Error: (TSP 1) 'onMessage' failed 'KeyError'.
2019-05-16 14:56:01.261 Error: (TSP 1) ----> Line 531 in '/home/pi/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py', function onMessage
2019-05-16 14:56:01.261 Error: (TSP 1) ----> Line 439 in '/home/pi/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/plugin.py', function onMessage
EDIT:
Solved the error - make sure the right ID's for voltage etc are in the plugin !!!!!
Tnx for the update

Sent from my ONEPLUS A6003 using Tapatalk


Re: [REQUEST] Plugin for Tuya

Posted: Saturday 08 June 2019 17:21
by Tugado
Hi,

recently I upgraded the firmware of one of my Tuya devices (they are all the same device type) and the plugin stopped recieving data back from the device.

This one works fine:

Code: Select all

2019-06-08 17:08:55.047  Processing 'onHeartbeatCallback' message
2019-06-08 17:08:55.047  Calling message handler 'onHeartbeat'.
2019-06-08 17:08:55.050  Pushing 'WriteDirective' on to queue
2019-06-08 17:08:55.050  Processing 'WriteDirective' message
2019-06-08 17:08:55.050  Sending 86 bytes of data
2019-06-08 17:08:55.101  Processing 'ReadEvent' message
2019-06-08 17:08:55.101  Received 156 bytes of data
The plug with the firmware upgraded (before the upgrade it was working perfectly):

Code: Select all

2019-06-08 17:30:38.133  Calling message handler 'onConnect'.
2019-06-08 17:30:38.133  Connected successfully to: 192.168.1.148:6668
2019-06-08 17:30:38.135  Pushing 'WriteDirective' on to queue
2019-06-08 17:30:38.135  Processing 'WriteDirective' message
2019-06-08 17:30:38.135  Sending 86 bytes of data
2019-06-08 17:30:58.869  Pushing 'DisconnectedEvent' on to queue
2019-06-08 17:30:58.897  Processing 'DisconnectedEvent' message
2019-06-08 17:30:58.897  Disconnect event received for '192.168.1.148:6668'.
2019-06-08 17:30:58.897  Pushing 'onDisconnectCallback' on to queue
2019-06-08 17:30:58.897  Processing 'onDisconnectCallback' message
2019-06-08 17:30:58.897  Calling message handler 'onDisconnect'.
2019-06-08 17:30:58.897  Disconnected from: 192.168.1.148:6668
2019-06-08 17:30:58.869 Error: : Async Read Exception: 104, Connection reset by peer
I tried with the get_dps.py and returned connection error too.

Is there any chance of get it fixed or a firmware downgrade?

Thanks!

Re: [REQUEST] Plugin for Tuya

Posted: Sunday 09 June 2019 8:49
by sincze
Thx for reporting and warning not to update the firmware. I don't have these things so honestly don't know. Maybe flashing to Tasmota is also an option? Than it will be MQTT compatible.

Re: [REQUEST] Plugin for Tuya

Posted: Sunday 09 June 2019 10:05
by LouiS22
sincze wrote: Sunday 09 June 2019 8:49 Thx for reporting and warning not to update the firmware. I don't have these things so honestly don't know. Maybe flashing to Tasmota is also an option? Than it will be MQTT compatible.
It's not possible to flash tasmota to any of these tuya based door/PIR sensors, due to a coprocessor that essentially handles everything else besides the connection to tuya servers. There's an ongoing project to resolve this, have a look at here: https://github.com/brandond/esphome-tuya_pir/

Re: [REQUEST] Plugin for Tuya

Posted: Sunday 09 June 2019 14:55
by sincze
LouiS22 wrote: Sunday 09 June 2019 10:05
sincze wrote: Sunday 09 June 2019 8:49 Thx for reporting and warning not to update the firmware. I don't have these things so honestly don't know. Maybe flashing to Tasmota is also an option? Than it will be MQTT compatible.
It's not possible to flash tasmota to any of the tuya based sensors, due to a coprocessor that essentially handles everything else besides the connection to tuya servers. There's an ongoing project to resolve this, have a look at here: https://github.com/brandond/esphome-tuya_pir/
Tnx @LouiS22 for the correction.

Re: [REQUEST] Plugin for Tuya

Posted: Sunday 09 June 2019 15:22
by LouiS22
Shelly developers are currently planning to release a door sensor (that'll also have a coprocessor, but hopefully it'll be easier to integrate into any HA.

Re: [REQUEST] Plugin for Tuya

Posted: Friday 14 June 2019 18:31
by bwbboot
It looks like the new IOS released tuya/smartlife apps prevent DevID & Local Key extraction. Can someone confirm pls?

Re: [REQUEST] Plugin for Tuya

Posted: Sunday 16 June 2019 10:51
by merlot
Simw time later ...

I have returned the previous smart plug and I've bought a new one, a double one for 16A.

And I'm having the same problems :(

So, let's start form the begining.

Is a packet like the one below correct to get the devId and localkey?

Is this a packet that belongs to a tuya device that can be used by this plugin?

Thank you very much indeed
merlot wrote: Monday 15 April 2019 19:01 The point is that if I use packet capture with its app I can see the packets that I guess are the ones expected

Code: Select all

{
  "result": {
    "devId": "51817282840d8e5f63cd",
    "dpMaxTime": 1555161839644,
    "virtual": false,
    "productId": "0fHWRe8ULjtmnBNd",
    "dps": {
      "22": 626,
      "23": 30727,
      "1": true,
      "24": 17543,
      "25": 1190,
      "26": 0,
      "17": 5,
      "18": 0,
      "19": 0,
      "9": 0,
      "20": 0,
      "21": 1
    },
    "activeTime": 1555161828,
    "ip": "89.141.147.40",
    "lon": "",
    "moduleMap": {
      "wifi": {
        "upgradeStatus": 3,
        "bv": "5.42",
        "cdv": "1.0.0",
        "pv": "2.2",
        "verSw": "1.0.7",
        "isOnline": true,
        "id": 8256355,
        "cadv": ""
      },
      "mcu": {
        "upgradeStatus": 0,
        "cdv": "",
        "verSw": "1.0.7",
        "isOnline": true,
        "id": 8256356,
        "cadv": ""
      }
    },
    "uuid": "51817282840d8e5f63cd",
    "mac": "84:0d:8e:5f:63:cd",
    "devAttribute": 3,
    "name": "Smart Socket-10A",
    "isShare": false,
    "timezoneId": "Europe/Madrid",
    "iconUrl": "https://images.tuyaeu.com/smart/icon/15324342875tjvmpp9uw8_0.png",
    "lat": "",
    "runtimeEnv": "prod",
    "localKey": "1a9ae1ca27591e4a"
  },
  "t": 1555161843633,
  "success": true,
  "status": "ok"
}
Is this packet as expected?

Thank you again

Enviado desde mi Redmi Note 4 mediante Tapatalk