[REQUEST] Plugin for Tuya

Python and python framework

Moderator: leecollings

User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: [REQUEST] Plugin for Tuya

Post by FearNaBoinne »

tete wrote: Monday 23 September 2019 15:12
FearNaBoinne wrote: Sunday 22 September 2019 22:27 # MIT License #
# #
# Copyright (c) 2018 tixi #

I've made these changes and now I can get the plugin working.

Plug State Information:
{'devId': '60417563840d8e68fe98', 'dps': {'22': 626, '19': 1334, '23': 34433, '9': 0, '20': 2358, '18': 634, '1': True, '24': 19774, '21': 1, '25': 1045}}

Plug DPS List:
1

However, when I add the device to domoticz, the values ​​are 0 and neither does work the on / off function.
But it works the on / off by command line (turnON.py, turnOFF.py).

What could be wrong?
The plugin isn't modified, just the test scripts... So the plugin still uses 3.1 and is probably also not correctly parsing the responses...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
xavierlp
Posts: 70
Joined: Tuesday 01 November 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by xavierlp »

FearNaBoinne wrote: Monday 23 September 2019 16:00 It's not key and devID, it's devID and gwID... They key is different, but not shown in the debug info...
Ok got it

In __init__.py

Code: Select all

# This is intended to match requests.json payload at https://github.com/codetheweb/tuyapi
payload_dict = {
  "device": {
    "status": {
      "hexByte": "0a",
      "command": {"gwId": "", "devId": ""}
    },
    "set": {
      "hexByte": "07",
      "command": {"devId": "", "uid": "", "t": ""}
    },
    "prefix": "000055aa00000000000000",    # Next byte is command byte ("hexByte") some zero padding, then length of remaining payload, i.e. command + suffix (unclear if multiple bytes used for length, zero padding implies could be more than one byte)
    "suffix": "000000000000aa55"
  }
}
gwId is before devId ! So what's happen
xavierlp
Posts: 70
Joined: Tuesday 01 November 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by xavierlp »

If I run
sudo python3.5 get_dps.py 192.168.1.23 "55142707bcddc295" "c6e4fd6a1f14fe20"
INFO:pytuya:pytuya version 7.0.4
INFO:pytuya:Python 3.5.7 (default, Aug 17 2019, 22:31:31)
[GCC 4.9.2] on linux
INFO:pytuya:Using PyCrypto (2, 6, 1, 'final', 0)
INFO:pytuya:Using PyCrypto from '/usr/local/lib/python3.5/site-packages/Crypto/__init__.py'
test
DEBUG:pytuya:status() entry
DEBUG:pytuya:json_payload=b'{"gwId":"55142707bcddc295","devId":"55142707bcddc295"}'
A problem occur please retry...

gwId is BEFORE devId

If I run
sudo python3.5 get_dps.py 192.168.1.23 55142707bcddc295f96a c6e4fd6a1f14fe20
INFO:pytuya:pytuya version 7.0.4
INFO:pytuya:Python 3.5.7 (default, Aug 17 2019, 22:31:31)
[GCC 4.9.2] on linux
INFO:pytuya:Using PyCrypto (2, 6, 1, 'final', 0)
INFO:pytuya:Using PyCrypto from '/usr/local/lib/python3.5/site-packages/Crypto/__init__.py'

DEBUG:pytuya:status() entry
DEBUG:pytuya:json_payload=b'{"devId":"55142707bcddc295f96a","gwId":"55142707bcddc295f96a"}'
A problem occur please retry...

gwId is AFTER devId
xavierlp
Posts: 70
Joined: Tuesday 01 November 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by xavierlp »

I removed then add the device to check the key value.

And Now I've got an second value !!!

But always the same message
User avatar
Xenomes
Posts: 396
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: [REQUEST] Plugin for Tuya

Post by Xenomes »

I have two Tuya devices LEDBulb and an LEDStrip with the new modifications the LEDStrip reacts on TurnON and TurnOff scripts the LEDBulb give a error : DEBUG:pytuya:decrypted result='json obj data unvalid'

I had the "A problem occur please retry..." error too when I closed the app on my phone the error gone.

I change the one of the scripts to run commands on one dps value. colour/white or 1 to 1000

turnCommand.py

Code: Select all

#!/usr/bin/python3

########################################################################################
#       Domoticz Tuya Smart Plug Python Plugin                                             #
#                                                                                      #
#       MIT License                                                                        #
#                                                                                      #
#       Copyright (c) 2018 tixi                                                            #
#                                                                                      #
#       Permission is hereby granted, free of charge, to any person obtaining a copy       #
#       of this software and associated documentation files (the "Software"), to deal      #
#       in the Software without restriction, including without limitation the rights       #
#       to use, copy, modify, merge, publish, distribute, sublicense, and/or sell          #
#       copies of the Software, and to permit persons to whom the Software is              #
#       furnished to do so, subject to the following conditions:                           #
#                                                                                      #
#       The above copyright notice and this permission notice shall be included in all     #
#       copies or substantial portions of the Software.                                    #
#                                                                                      #
#       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR         #
#       IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,           #
#       FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE        #
#       AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER             #
#       LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,      #
#       OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE      #
#       SOFTWARE.                                                                          #
#                                                                                      #
########################################################################################

import sys
import pytuya
import socket #needed for socket.timeout exception


if(len(sys.argv)!=6):
        print("usage: " + sys.argv[0] + " <IP> <DevID> <Local key> <DPS value> <DPS command>")
        exit(1)

ip        = sys.argv[1]
devid     = sys.argv[2]
localkey  = sys.argv[3]
dps_value = sys.argv[4]
dps_command = sys.argv[5]

device    = pytuya.OutletDevice(devid,ip,localkey)
device.set_version(3.3)

try:

        payload = device.generate_payload('set', {str(dps_value):(dps_command)})
        device._send_receive(payload)

except (ConnectionResetError, socket.timeout, OSError)  as e:
        print("A problem occur please retry...")
        exit(1)
When I do for example "./turnCcommand.py 192.168.1.34 361636752cf43206c777 3ab976c45h0275ce 21 colour" the LEDstrip is changing to colour mode
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: [REQUEST] Plugin for Tuya

Post by FearNaBoinne »

Xenomes wrote: Monday 23 September 2019 19:59 I had the "A problem occur please retry..." error too when I closed the app on my phone the error gone.
Yes, the app seems to sometimes grab the socket and not let go...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: [REQUEST] Plugin for Tuya

Post by FearNaBoinne »

Xenomes wrote: Monday 23 September 2019 19:59 I have two Tuya devices LEDBulb and an LEDStrip with the new modifications the LEDStrip reacts on TurnON and TurnOff scripts the LEDBulb give a error : DEBUG:pytuya:decrypted result='json obj data unvalid'
There's also a smartbulb plugin, perhaps that'd work better with the color strip?...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
xavierlp
Posts: 70
Joined: Tuesday 01 November 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by xavierlp »

FearNaBoinne wrote: Monday 23 September 2019 15:04 My output shows the devID and gwID in reversed order compared to yours:

Code: Select all

INFO:pytuya:pytuya version 7.0.4
INFO:pytuya:Python 3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.2.0] on linux
INFO:pytuya:Using PyCrypto (2, 6, 1, 'final', 0)
INFO:pytuya:Using PyCrypto from '/usr/lib/python3/dist-packages/Crypto/__init__.py'
DEBUG:pytuya:status() entry
DEBUG:pytuya:json_payload=b'{"gwId":"70116356840d8e5c3382","devId":"70116356840d8e5c3382"}'
DEBUG:pytuya:status received data=b'\x00\x00U\xaa\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00L\x00\x00\x00\x00#H7\x00\x03\xe9\xb5p\x18\xdf`?\xa5+\x9f \x7f#\xf4\xe14)\x0f_5\xa1\x93\xb92f\xf1\xecp(\xff\xda\x9dT\xbeZ\xc4\xca\xbaSi@\x892\x14\xc3\x89\xbb2\xe6\x82\x02\xabI\xe0\x9c\xf9\x18\x7fQ`\x02\xba-\x00\x00\xaaU'
DEBUG:pytuya:result=b'#H7\x00\x03\xe9\xb5p\x18\xdf`?\xa5+\x9f \x7f#\xf4\xe14)\x0f_5\xa1\x93\xb92f\xf1\xecp(\xff\xda\x9dT\xbeZ\xc4\xca\xbaSi@\x892\x14\xc3\x89\xbb2\xe6\x82\x02\xabI\xe0\x9c\xf9\x18\x7fQ'
DEBUG:pytuya:decrypted result='{"devId":"70116356840d8e5c3382","dps":{"1":false,"9":0}}'

Plug State Information:
{'devId': '70116356840d8e5c3382', 'dps': {'1': False, '9': 0}}

Plug DPS List:
1
Not sure whether that is the 'data format error' referenced in your output...
So Ican't find to run the get_dps but the plugin is working.

The only issu is that my device is a doucle plug and I can only manage the fist one !

As I can't find the list of dps I'm reading the log of the plugin and I can find that :

Code: Select all

2019-09-23 23:17:12.086 (Tuya) onMessage called: 192.168.1.23:6668 b'\x00\x00U\xaa\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00\x9c\x00\x00\x00\x00{"devId":"55142707bcddc295f96a","dps":{"1":true,"2":false,"9":0,"10":0,"18":0,"19":0,"20":2278,"21":1,"22":609,"23":27297,"24":15519,"25":1340}}1\xb3Yx\x00\x00\xaaU'
2019-09-23 23:17:12.086 (Tuya - Tuya SmartPlug (Switch)) Updating device from 0:'' to have values 1:'On'.
2019-09-23 23:17:12.089 (Tuya) Update Tuya - Tuya SmartPlug (Switch): 1 - 'On'
2019-09-23 23:17:12.089 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'' to have values 0:'27.297'.
2019-09-23 23:17:12.090 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'0; 0.0' to have values 0:'1551.9;0'.
2019-09-23 23:17:12.092 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'' to have values 0:'134.0'.
2019-09-23 23:17:12.093 (Tuya - Tuya SmartPlug (W)) Updating device from 0:'' to have values 0:'1551.9'.
xavierlp
Posts: 70
Joined: Tuesday 01 November 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by xavierlp »

I can't find a way to run the get_dps but the plugin is working.

The only issue is that my device is a double plug and I can only manage the fist one !

As I can't find the list of dps I'm reading the log of the plugin and I can read that :

<code>
2019-09-23 23:17:43.090 (Tuya) onMessage called: 192.168.1.23:6668 b'\x00\x00U\xaa\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00\x9d\x00\x00\x00\x00{"devId":"55142707bcddc295f96a","dps":{"1":false,"2":false,"9":0,"10":0,"18":0,"19":0,"20":2278,"21":1,"22":609,"23":27297,"24":15519,"25":1340}}\xc5_\xed\xaa\x00\x00\xaaU'
2019-09-23 23:17:43.090 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'27.297' to have values 0:'27.297'.
2019-09-23 23:17:43.092 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'1551.9;0' to have values 0:'1551.9;0'.
2019-09-23 23:17:43.094 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'134.0' to have values 0:'134.0'.
2019-09-23 23:17:43.096 (Tuya - Tuya SmartPlug (W)) Updating device from 0:'1551.9' to have values 0:'1551.9'.
2019-09-23 23:17:43.098 (Tuya) Updated: 27.297 Ampere Key is:2
2019-09-23 23:17:43.098 (Tuya) Updated: 1551.9 Watt Key is:13
2019-09-23 23:17:43.098 (Tuya) Updated: 134.0 Voltage Key is:14
2019-09-23 23:17:43.113 (Tuya) Pushing 'ReadEvent' on to queue
</code>

So I need some help to enter values in
DPS
DPS GROUP
ID AMP WATT VOLT

For AMP,WATT, VOLT I think is 2,13,14 I'm right ?
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: [REQUEST] Plugin for Tuya

Post by FearNaBoinne »

xavierlp wrote: Monday 23 September 2019 23:27 I can't find a way to run the get_dps but the plugin is working.

The only issue is that my device is a double plug and I can only manage the fist one !
Create a second copy of the device, same IP, ID and Key (those all rhyme!) and change the DPS field from 1 to 2...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
xavierlp
Posts: 70
Joined: Tuesday 01 November 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by xavierlp »

FearNaBoinne wrote: Monday 23 September 2019 23:32
xavierlp wrote: Monday 23 September 2019 23:27 I can't find a way to run the get_dps but the plugin is working.

The only issue is that my device is a double plug and I can only manage the fist one !
Create a second copy of the device, same IP, ID and Key (those all rhyme!) and change the DPS field from 1 to 2...
Thanks for your feedback
I've got this error
2019-09-23 23:38:02.104 Error: (Tuya 2): Async Read Exception (192.168.1.23:6668): 104, Connection reset by peer
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: [REQUEST] Plugin for Tuya

Post by FearNaBoinne »

Well, it was worth a try... :D
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
User avatar
FearNaBoinne
Posts: 144
Joined: Tuesday 30 April 2019 10:08
Target OS: Linux
Domoticz version: 2021.1
Location: Sector 0
Contact:

Re: [REQUEST] Plugin for Tuya

Post by FearNaBoinne »

Just checking, did you initially try DPS 1;2? (Because that is the official way it should work...)
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
xavierlp
Posts: 70
Joined: Tuesday 01 November 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by xavierlp »

I found the solution
DPS 1;2
DPS Group 1:2

All is OK now :D
User avatar
Xenomes
Posts: 396
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: [REQUEST] Plugin for Tuya

Post by Xenomes »

FearNaBoinne wrote: Monday 23 September 2019 22:57 There's also a smartbulb plugin, perhaps that'd work better with the color strip?...
Yes I am aware of the SmartBulb plugin, but is not working with it and uses the same pytuya. so by updating pytuya to version 3.3 and learning how it work (with the test scrips) the SmartBulb can maybe modified.
HP T630 (256GB SSD/8GB Mem) - Ubuntu 24.04.2 LTS (64Bit) - Domoticz 2024.7 (Docker) Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
xavierlp
Posts: 70
Joined: Tuesday 01 November 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by xavierlp »

Hello all

the plugin is working good with my OXAOXE devices WiFi Smart Plug 2 in 1 for EU
https://oxaoxe.com/product/wifi-smart-p ... or-eu.html

I can easily switch on and switch off each.

I've got a question regarding options for consumption.
In the log I can read that

(Tuya) Calling message handler 'onMessage'.
2019-09-24 13:09:57.944 (Tuya) onMessage called: 192.168.1.23:6668
b'\x00\x00U\xaa\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00\x9d\x00\x00\x00\x00

{"devId":"55142707bcddc295f96a","dps":{"1":false,"2":false,"9":0,"10":0,"18":0,"19":0,"20":2274,"21":1,"22":609,"23":27297,"24":15519,"25":1340}}

\xbc\x04\xac\xb9\x00\x00\xaaU'


2019-09-24 13:09:57.945 (Tuya - Gauche) Updating device from 0:'Off' to have values 0:'27.297'.
2019-09-24 13:09:57.950 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'27.297' to have values 0:'1551.9;0'.
2019-09-24 13:09:57.953 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'1551.9;0' to have values 0:'134.0'.
2019-09-24 13:09:57.955 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'134.0' to have values 0:'1551.9'.
2019-09-24 13:09:57.957 (Tuya) Updated: 27.297 Ampere Key is:2
2019-09-24 13:09:57.957 (Tuya) Updated: 1551.9 Watt Key is:13
2019-09-24 13:09:57.958 (Tuya) Updated: 134.0 Voltage Key is:14
2019-09-24 13:09:57.958 (Tuya - Gauche) Updating device from 0:'27.297' to have values 0:'Off'.
2019-09-24 13:09:57.963 (Tuya) Update Tuya - Gauche: 0 - 'Off'
2019-09-24 13:09:57.963 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'1551.9;0' to have values 0:'27.297'.
2019-09-24 13:09:57.966 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'134.0' to have values 0:'1551.9;0'.
2019-09-24 13:09:57.969 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'1551.9' to have values 0:'134.0'.
2019-09-24 13:09:57.972 (Tuya - Tuya SmartPlug (W)) Updating device from 0:'1551.9' to have values 0:'1551.9'.
2019-09-24 13:09:57.974 (Tuya) Updated: 27.297 Ampere Key is:3
2019-09-24 13:09:57.975 (Tuya) Updated: 1551.9 Watt Key is:14
2019-09-24 13:09:57.975 (Tuya) Updated: 134.0 Voltage Key is:15

When I receive the log the 2 plugs are OFF (1:False and 2: False)

I'd like to know which values I had to enter in the option ID Amp;Watt;Volt:

Currently I entered 23;24;25.

what is mean in the log theses lines
Updated: 27.297 Ampere Key is:2
Updated: 1551.9 Watt Key is:13
Updated: 134.0 Voltage Key is:14

And Last point as the plus are OFF the consumption could be 0 ?

I can't understand how to read theses information.

Thanks
xavierlp
Posts: 70
Joined: Tuesday 01 November 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by xavierlp »

xavierlp wrote: Tuesday 24 September 2019 13:21 Hello all

the plugin is working good with my OXAOXE devices WiFi Smart Plug 2 in 1 for EU
https://oxaoxe.com/product/wifi-smart-p ... or-eu.html

I can easily switch on and switch off each.

I've got a question regarding options for consumption.
In the log I can read that

(Tuya) Calling message handler 'onMessage'.
2019-09-24 13:09:57.944 (Tuya) onMessage called: 192.168.1.23:6668
b'\x00\x00U\xaa\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00\x9d\x00\x00\x00\x00

{"devId":"55142707bcddc295f96a","dps":{"1":false,"2":false,"9":0,"10":0,"18":0,"19":0,"20":2274,"21":1,"22":609,"23":27297,"24":15519,"25":1340}}

\xbc\x04\xac\xb9\x00\x00\xaaU'


2019-09-24 13:09:57.945 (Tuya - Gauche) Updating device from 0:'Off' to have values 0:'27.297'.
2019-09-24 13:09:57.950 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'27.297' to have values 0:'1551.9;0'.
2019-09-24 13:09:57.953 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'1551.9;0' to have values 0:'134.0'.
2019-09-24 13:09:57.955 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'134.0' to have values 0:'1551.9'.
2019-09-24 13:09:57.957 (Tuya) Updated: 27.297 Ampere Key is:2
2019-09-24 13:09:57.957 (Tuya) Updated: 1551.9 Watt Key is:13
2019-09-24 13:09:57.958 (Tuya) Updated: 134.0 Voltage Key is:14
2019-09-24 13:09:57.958 (Tuya - Gauche) Updating device from 0:'27.297' to have values 0:'Off'.
2019-09-24 13:09:57.963 (Tuya) Update Tuya - Gauche: 0 - 'Off'
2019-09-24 13:09:57.963 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'1551.9;0' to have values 0:'27.297'.
2019-09-24 13:09:57.966 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'134.0' to have values 0:'1551.9;0'.
2019-09-24 13:09:57.969 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'1551.9' to have values 0:'134.0'.
2019-09-24 13:09:57.972 (Tuya - Tuya SmartPlug (W)) Updating device from 0:'1551.9' to have values 0:'1551.9'.
2019-09-24 13:09:57.974 (Tuya) Updated: 27.297 Ampere Key is:3
2019-09-24 13:09:57.975 (Tuya) Updated: 1551.9 Watt Key is:14
2019-09-24 13:09:57.975 (Tuya) Updated: 134.0 Voltage Key is:15

When I receive the log the 2 plugs are OFF (1:False and 2: False)

I'd like to know which values I had to enter in the option ID Amp;Watt;Volt:

Currently I entered 23;24;25.

what is mean in the log theses lines
Updated: 27.297 Ampere Key is:2
Updated: 1551.9 Watt Key is:13
Updated: 134.0 Voltage Key is:14

And Last point as the plus are OFF the consumption could be 0 ?

I can't understand how to read theses information.

Thanks
I finally set up 18;19;20 . It's seem ok
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: [REQUEST] Plugin for Tuya

Post by deennoo »

xavierlp wrote:Hello @deennoo

I am using OxaOxe
https://www.amazon.fr/gp/product/B07G2J ... le_o02_s00

I could red your post on github. For my side I don't know how to check the version of tuya.

thanks
You Can get it on Update Check

According to some issue on Tuya-CLI GitHub
FW using >1.1.x use tuya 3.3Image

Envoyé de mon MI 9 en utilisant Tapatalk

Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
tobydeteckel
Posts: 12
Joined: Wednesday 25 September 2019 14:27
Target OS: Raspberry Pi / ODroid
Domoticz version: V12461
Location: The Netherlands -Hilversum
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tobydeteckel »

I got the "Action" Tuya switches with 3.3 HTTPS working with node-red. 2 way MQTT communication.

I wil post the FLOW tonight here, including the used software.

Friendly greetings,
Thijs
tobydeteckel
Posts: 12
Joined: Wednesday 25 September 2019 14:27
Target OS: Raspberry Pi / ODroid
Domoticz version: V12461
Location: The Netherlands -Hilversum
Contact:

Re: [REQUEST] Plugin for Tuya

Post by tobydeteckel »

Cant wait 8-)

It is for the single socket switches without power readings

The Node-red flow:

Code: Select all

[{"id":"72059e25.d0bc8","type":"tab","label":"Powerplug Monitor","disabled":false,"info":""},{"id":"40e9230e.47f2bc","type":"tuya-local","z":"72059e25.d0bc8","devName":"socket1","devIp":"192.168.0.13","devId":"70116356840d8e5c","devKey":"d89c9a46c82c","protocolVer":"3.3","renameSchema":"","filterCB":"","x":540,"y":380,"wires":[["c2f44da8.5bff1","c1117431.dc1ee8","17a73342.cca49d"]]},{"id":"65260fd2.0df5b","type":"mqtt out","z":"72059e25.d0bc8","name":"","topic":"domoticz/in","qos":"2","retain":"","broker":"45e510fc.ec136","x":1330,"y":380,"wires":[]},{"id":"8cd37074.96bd5","type":"template","z":"72059e25.d0bc8","name":"Switch on","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"command\": \"switchlight\", \"idx\": 272, \"switchcmd\": \"On\" }","output":"str","x":1140,"y":300,"wires":[["65260fd2.0df5b"]]},{"id":"bb387b2c.3fa1b8","type":"template","z":"72059e25.d0bc8","name":"Switch Off","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"command\": \"switchlight\", \"idx\": 272, \"switchcmd\": \"Off\" }","output":"str","x":1130,"y":460,"wires":[["65260fd2.0df5b"]]},{"id":"37ddec6.91e9314","type":"mqtt in","z":"72059e25.d0bc8","name":"","topic":"domoticz/out","qos":"2","datatype":"auto","broker":"45e510fc.ec136","x":90,"y":380,"wires":[["2564e2dc.ae170e","3f31cc83.02a464"]]},{"id":"2564e2dc.ae170e","type":"switch","z":"72059e25.d0bc8","name":"IDX","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"idx\" : 272,","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":250,"y":300,"wires":[["33fa47de.f8f908"]]},{"id":"ed5e5819.23c408","type":"change","z":"72059e25.d0bc8","name":"On","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":300,"wires":[["40e9230e.47f2bc"]]},{"id":"3f31cc83.02a464","type":"switch","z":"72059e25.d0bc8","name":"IDX","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"idx\" : 272,","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":460,"wires":[["f3b3f4a1.206778"]]},{"id":"65e72386.bddc1c","type":"change","z":"72059e25.d0bc8","name":"Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":460,"wires":[["40e9230e.47f2bc"]]},{"id":"17a73342.cca49d","type":"switch","z":"72059e25.d0bc8","name":"false","property":"payload.dps[\"1\"]","propertyType":"msg","rules":[{"t":"cont","v":"false","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":690,"y":380,"wires":[["f9573301.de463"]]},{"id":"33fa47de.f8f908","type":"switch","z":"72059e25.d0bc8","name":"state","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"nvalue\" : 1,","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":370,"y":300,"wires":[["ed5e5819.23c408"]]},{"id":"f3b3f4a1.206778","type":"switch","z":"72059e25.d0bc8","name":"state","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"nvalue\" : 0,","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":370,"y":460,"wires":[["65e72386.bddc1c"]]},{"id":"56a59c77.4a3e94","type":"http request","z":"72059e25.d0bc8","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"http://192.168.0.101:8080/json.htm?type=devices&rid=272","tls":"","proxy":"","authType":"","x":830,"y":300,"wires":[["742a43b9.a5cf0c"]]},{"id":"742a43b9.a5cf0c","type":"switch","z":"72059e25.d0bc8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"Status\" : \"Off\",","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":970,"y":300,"wires":[["8cd37074.96bd5"]]},{"id":"c1117431.dc1ee8","type":"switch","z":"72059e25.d0bc8","name":"true","property":"payload.dps[\"1\"]","propertyType":"msg","rules":[{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":690,"y":300,"wires":[["56a59c77.4a3e94"]]},{"id":"f9573301.de463","type":"http request","z":"72059e25.d0bc8","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"http://192.168.0.101:8080/json.htm?type=devices&rid=272","tls":"","proxy":"","authType":"","x":830,"y":380,"wires":[["587097d0.84f748"]]},{"id":"587097d0.84f748","type":"switch","z":"72059e25.d0bc8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"Status\" : \"On\",","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":970,"y":380,"wires":[["bb387b2c.3fa1b8"]]},{"id":"c2f44da8.5bff1","type":"switch","z":"72059e25.d0bc8","name":"If offline switch off","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"undefined","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":460,"wires":[["bb387b2c.3fa1b8"]]},{"id":"deca8f10.6b47","type":"comment","z":"72059e25.d0bc8","name":"If plug =On and switch =Off","info":"","x":828,"y":268,"wires":[]},{"id":"98791087.6a4a7","type":"comment","z":"72059e25.d0bc8","name":"If plug =Off and switch =On","info":"","x":830,"y":412,"wires":[]},{"id":"9bdccb66.88a618","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":290,"y":428,"wires":[]},{"id":"e4ec1f53.602ea","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":850,"y":326,"wires":[]},{"id":"f1951bec.707e48","type":"comment","z":"72059e25.d0bc8","name":"Search state switch and turn Off Plug","info":"","x":390,"y":491,"wires":[]},{"id":"14ce4ac6.bcbda5","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":290,"y":331,"wires":[]},{"id":"a8f6899a.73f3d8","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":850,"y":354,"wires":[]},{"id":"195c6fa4.207bc","type":"comment","z":"72059e25.d0bc8","name":"Search state switch and turn On Plug","info":"","x":392.6666564941406,"y":268.6666564941406,"wires":[]},{"id":"27d701e7.d6333e","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":1170,"y":270,"wires":[]},{"id":"f387f745.07cc48","type":"comment","z":"72059e25.d0bc8","name":"EDIT IDX SWITCH","info":"Edit the value to the IDX of the vitual dummy switch","x":1152,"y":491,"wires":[]},{"id":"b09785c8.055198","type":"inject","z":"72059e25.d0bc8","name":"connect","topic":"connect","payload":"connect","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":365,"wires":[["40e9230e.47f2bc"]]},{"id":"c5aea957.053908","type":"inject","z":"72059e25.d0bc8","name":"disconnect","topic":"disconnect","payload":"disconnect","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":394,"wires":[["40e9230e.47f2bc"]]},{"id":"45e510fc.ec136","type":"mqtt-broker","z":"","name":"","broker":"","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Made use of the "node-red-contrib-tuya-local" package/node

Hopefully somebody can use it, feel free to ask questions or improve the code.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest