[REQUEST] Plugin for Tuya

Python and python framework

Moderator: leecollings

User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: [REQUEST] Plugin for Tuya

Post by gielie »

FearNaBoinne wrote: Friday 21 February 2020 21:45 1) Download Tuya-Cli latest version
2) Create account on iot.tuya.com
3) Request API Access
4) Create Application API profile
5) Wait for API Access approval
6) Record API ID and key provided by Tuya
7) Put device in pairing mode (quick flash)
8) Run tuya-cli:

Code: Select all

tuya-cli link --api-key [your API ID] --api-secret [your API key] --schema [name of App API profile] --ssid [your WiFi name] --password [your WiFi Pass] -t [your timezone in linux format] -r [your region]
where timezone is in the format 'Europe/Berlin'
where region is EU/AZ/US

After a while the device should stop blinking, and less then a minute after that the app should spit out the type, id, key and name of the device

Make sure the device you're running tuya-cli on is on a 2.4Ghz WLAN, and if it has multiple network devices, disable all but the WiFi you're using!
ok i tried this with an rapberry pi connected to my wifi, the plug stops blinking once i start the tuya-cli but after that i gives an time out.
btw; The -r for region is not recognized.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
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 »

gielie wrote: Monday 24 February 2020 15:59 btw; The -r for region is not recognized.
Then you probably don't have the latest version of tuya-cli...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
javalin
Posts: 71
Joined: Tuesday 30 April 2019 16:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Portugal
Contact:

Re: [REQUEST] Plugin for Tuya

Post by javalin »

southmind wrote: Wednesday 22 January 2020 10:36 Hello all. New here and new to Domoticz... I installed this plugin : https://github.com/iasmanis/Domoticz-Tu ... tat-Plugin. My Domoticz (on RPI4) works well with Hue lamps, some other zigbee devices, Netatmo meteo station ... I own a thermostat MOES 16A-002BB-WiFi and try to use it with Domoticz. The plugin works well with Domoticz, I see connexion in Logs , but the temperatures values are always to 0...

Here the log (I removed data containing devID and Local key values)
2020-01-22 10:30:57.232 (Thermostat Chambre) Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE ALL
2020-01-22 10:30:57.232 (Thermostat Chambre) onStart called
2020-01-22 10:30:57.232 (Thermostat Chambre) Pushing 'ConnectDirective' on to queue
2020-01-22 10:30:57.232 (Thermostat Chambre) Processing 'ConnectDirective' message
2020-01-22 10:30:57.232 (Thermostat Chambre) Protocol for 'Tuya' not specified, 'None' assumed.
2020-01-22 10:30:57.232 (Thermostat Chambre) Transport set to: 'TCP/IP', 192.168.1.51:6668.
2020-01-22 10:30:57.232 (Thermostat Chambre) Connect directive received, action initiated successfully.
2020-01-22 10:30:57.297 (Thermostat Chambre) Pushing 'onConnectCallback' on to queue
2020-01-22 10:30:57.333 (Thermostat Chambre) Processing 'onConnectCallback' message
2020-01-22 10:30:57.333 (Thermostat Chambre) Calling message handler 'onConnect'.
2020-01-22 10:30:57.333 (Thermostat Chambre) Connected successfully to: 192.168.1.51:6668
2020-01-22 10:30:57.333 (Thermostat Chambre) Pushing 'WriteDirective' on to queue
2020-01-22 10:30:57.333 (Thermostat Chambre) Processing 'WriteDirective' message
2020-01-22 10:30:57.333 (Thermostat Chambre) Sending 86 bytes of data

2020-01-22 10:30:57.099 Status: (Thermostat Chambre) Started.
2020-01-22 10:30:57.230 Status: (Thermostat Chambre) Entering work loop.
2020-01-22 10:30:57.230 Status: (Thermostat Chambre) Initialized version 3.0.0, author 'iasmanis'

Any idea ?
Hello, I had same issue and resolve with a new command line
pi@raspberrypi:~ $ tuya-cli link --api-key XXXXXXXXX --api-secret XXXXXXXXX --schema XXXXXXXXX --ssid XXXXXXXXX --password XXXXXXXXX --region eu
I got it a new localKey to set in Domoticz (Tuya Thermostat Hardware values) with Protocol version:3.3.

Now I can change the setpoint value with domoticz and shut on/off the thermostat but, the value of the sensors showed in Domoticz dashboard are wrong (5 times greater):

Thermo.___Domoticz
T(ºC)______ values
16---------------80
17---------------85
18---------------90
19---------------95
20--------------100
21--------------105
21.5-----------107.5
22--------------110

Thermostat (Floureon HY08WE) value:
1.JPG
1.JPG (46.45 KiB) Viewed 3634 times

Domoticz value:
2.JPG
2.JPG (47.6 KiB) Viewed 3634 times
At least I can modify temp values :)
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
I'm using an oxaone plug which works perfectly with the plugin.

This device has 2 plugs. Every 20 seconds I receive new informations about Volt, Amp, WH.
And I receive also an updated about the status of one plug (only one).

The log is huge with this update. I'd like to know if you have the same issue.
Here is some logs

Thanks a lot

2020-03-11 18:53:18.683 (Tuya) Pushing 'onMessageCallback' on to queue
2020-03-11 18:53:18.683 (Tuya) Processing 'onMessageCallback' message
2020-03-11 18:53:18.683 (Tuya) Calling message handler 'onMessage'.
2020-03-11 18:53:18.683 (Tuya) onMessage called: 192.168.1.8: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'
2020-03-11 18:53:18.684 (Tuya - Gauche) Updating device from 0:'Off' to have values 0:'0.0'.
2020-03-11 18:53:18.688 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'0.0' to have values 0:'0.0;0'.
2020-03-11 18:53:18.691 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'0.0;74851.7' to have values 0:'227.8'.
2020-03-11 18:53:18.694 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'227.8' to have values 0:'0.0'.
2020-03-11 18:53:18.696 (Tuya) Updated: 0.0 Ampere Key is:2
2020-03-11 18:53:18.696 (Tuya) Updated: 0.0 Watt Key is:13
2020-03-11 18:53:18.697 (Tuya) Updated: 227.8 Voltage Key is:14
2020-03-11 18:53:18.697 (Tuya - Gauche) Updating device from 0:'0.0' to have values 0:'Off'.
2020-03-11 18:53:18.702 (Tuya) Update Tuya - Gauche: 0 - 'Off'
2020-03-11 18:53:18.702 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'0.0;0' to have values 0:'0.0'.
2020-03-11 18:53:18.704 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'227.8;74851.7' to have values 0:'0.0;0'.
2020-03-11 18:53:18.707 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'0.0' to have values 0:'227.8'.
2020-03-11 18:53:18.709 (Tuya - Tuya SmartPlug (W)) Updating device from 0:'0.0' to have values 0:'0.0'.
2020-03-11 18:53:18.712 (Tuya) Updated: 0.0 Ampere Key is:3
2020-03-11 18:53:18.712 (Tuya) Updated: 0.0 Watt Key is:14
2020-03-11 18:53:18.712 (Tuya) Updated: 227.8 Voltage Key is:15
2020-03-11 18:53:28.440 (Tuya) Pushing 'onHeartbeatCallback' on to queue
2020-03-11 18:53:28.478 (Tuya) Processing 'onHeartbeatCallback' message
2020-03-11 18:53:28.478 (Tuya) Calling message handler 'onHeartbeat'.
2020-03-11 18:53:38.443 (Tuya) Pushing 'onHeartbeatCallback' on to queue
2020-03-11 18:53:38.444 (Tuya) Processing 'onHeartbeatCallback' message
2020-03-11 18:53:38.444 (Tuya) Calling message handler 'onHeartbeat'.
2020-03-11 18:53:38.446 (Tuya) Pushing 'WriteDirective' on to queue
2020-03-11 18:53:38.446 (Tuya) Processing 'WriteDirective' message
2020-03-11 18:53:38.446 (Tuya) Sending 86 bytes of data
2020-03-11 18:53:38.446 (Tuya) 00 00 55 aa 00 00 00 00 00 00 00 0a 00 00 00 46 7b 22 64 65 ..U�...........F{"de
2020-03-11 18:53:38.446 (Tuya) 76 49 64 22 3a 22 35 35 31 34 32 37 30 37 62 63 64 64 63 32 vId":"55142707bcddc2
2020-03-11 18:53:38.447 (Tuya) 39 35 66 39 36 61 22 2c 22 67 77 49 64 22 3a 22 35 35 31 34 95f96a","gwId":"5514
2020-03-11 18:53:38.447 (Tuya) 32 37 30 37 62 63 64 64 63 32 39 35 66 39 36 61 22 7d 49 51 2707bcddc295f96a"}IQ
2020-03-11 18:53:38.447 (Tuya) d9 16 00 00 aa 55 .. .. .. .. .. .. .. .. .. .. .. .. .. .. �...�U
2020-03-11 18:53:38.524 (Tuya) Pushing 'ReadEvent' on to queue
2020-03-11 18:53:38.547 (Tuya) Processing 'ReadEvent' message
2020-03-11 18:53:38.547 (Tuya) Received 173 bytes of data
2020-03-11 18:53:38.547 (Tuya) 00 00 55 aa 00 00 00 00 00 00 00 0a 00 00 00 9d 00 00 00 00 ..U�...........�....
2020-03-11 18:53:38.547 (Tuya) 7b 22 64 65 76 49 64 22 3a 22 35 35 31 34 32 37 30 37 62 63 {"devId":"55142707bc
2020-03-11 18:53:38.547 (Tuya) 64 64 63 32 39 35 66 39 36 61 22 2c 22 64 70 73 22 3a 7b 22 ddc295f96a","dps":{"
2020-03-11 18:53:38.547 (Tuya) 31 22 3a 66 61 6c 73 65 2c 22 32 22 3a 66 61 6c 73 65 2c 22 1":false,"2":false,"
2020-03-11 18:53:38.547 (Tuya) 39 22 3a 30 2c 22 31 30 22 3a 30 2c 22 31 38 22 3a 30 2c 22 9":0,"10":0,"18":0,"
2020-03-11 18:53:38.548 (Tuya) 31 39 22 3a 30 2c 22 32 30 22 3a 32 32 37 38 2c 22 32 31 22 19":0,"20":2278,"21"
2020-03-11 18:53:38.548 (Tuya) 3a 31 2c 22 32 32 22 3a 36 30 39 2c 22 32 33 22 3a 32 37 32 :1,"22":609,"23":272
2020-03-11 18:53:38.548 (Tuya) 39 37 2c 22 32 34 22 3a 31 35 35 31 39 2c 22 32 35 22 3a 31 97,"24":15519,"25":1
2020-03-11 18:53:38.548 (Tuya) 33 34 30 7d 7d c5 5f ed aa 00 00 aa 55 .. .. .. .. .. .. .. 340}}�_��..�U
2020-03-11 18:53:38.548 (Tuya) Pushing 'onMessageCallback' on to queue
2020-03-11 18:53:38.548 (Tuya) Processing 'onMessageCallback' message
2020-03-11 18:53:38.548 (Tuya) Calling message handler 'onMessage'.
2020-03-11 18:53:38.548 (Tuya) onMessage called: 192.168.1.8: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'
2020-03-11 18:53:38.549 (Tuya - Gauche) Updating device from 0:'Off' to have values 0:'0.0'.
2020-03-11 18:53:38.553 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'0.0' to have values 0:'0.0;0'.
2020-03-11 18:53:38.555 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'0.0;74851.7' to have values 0:'227.8'.
2020-03-11 18:53:38.558 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'227.8' to have values 0:'0.0'.
2020-03-11 18:53:38.560 (Tuya) Updated: 0.0 Ampere Key is:2
2020-03-11 18:53:38.561 (Tuya) Updated: 0.0 Watt Key is:13
2020-03-11 18:53:38.561 (Tuya) Updated: 227.8 Voltage Key is:14
2020-03-11 18:53:38.561 (Tuya - Gauche) Updating device from 0:'0.0' to have values 0:'Off'.
2020-03-11 18:53:38.565 (Tuya) Update Tuya - Gauche: 0 - 'Off'
2020-03-11 18:53:38.565 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'0.0;0' to have values 0:'0.0'.
2020-03-11 18:53:38.568 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'227.8;74851.7' to have values 0:'0.0;0'.
2020-03-11 18:53:38.570 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'0.0' to have values 0:'227.8'.
2020-03-11 18:53:38.572 (Tuya - Tuya SmartPlug (W)) Updating device from 0:'0.0' to have values 0:'0.0'.
2020-03-11 18:53:38.575 (Tuya) Updated: 0.0 Ampere Key is:3
2020-03-11 18:53:38.575 (Tuya) Updated: 0.0 Watt Key is:14
2020-03-11 18:53:38.575 (Tuya) Updated: 227.8 Voltage Key is:15
2020-03-11 18:53:48.448 (Tuya) Pushing 'onHeartbeatCallback' on to queue
2020-03-11 18:53:48.490 (Tuya) Processing 'onHeartbeatCallback' message
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 »

No one?
User avatar
jjnh
Posts: 33
Joined: Sunday 09 December 2018 14:06
Target OS: Linux
Domoticz version: 2023.1
Location: Netherlands
Contact:

Re: [REQUEST] Plugin for Tuya

Post by jjnh »

Hi,

I requested the API access and now I see that Tuya is going to change the cloud API with a SAAS option. My ID's are no longer shown on the website. Missed it :(

Any ideas?

Kr.
John
Odroid N2+ 4GB, with an RfxTrx433E, Zigbee with Slaesh's CC2652RB, Z-Wave, BroadLink IR using RM mini 3 and P1 connected.
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: Friday 13 March 2020 17:08 Hello
I'm using an oxaone plug which works perfectly with the plugin.

This device has 2 plugs. Every 20 seconds I receive new informations about Volt, Amp, WH.
And I receive also an updated about the status of one plug (only one).

The log is huge with this update. I'd like to know if you have the same issue.
Here is some logs
Do you have DEBUG enabled on the plugin?
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 »

Yes I do

This is what you can read in my previous message
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: Thursday 02 April 2020 20:09 Yes I do

This is what you can read in my previous message
Nope, your previous message did not mention DEBUG at all... But when you enable debug, you get huge logs...
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 am very sorry but I don't know how to set DEBUG mode.
What I did is to setup debug in the pluggin
image1.gif
image1.gif (217.54 KiB) Viewed 3472 times
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 »

That means DEBUG is enabled... If you do not want all the detailed logging, turn it back down to 0.
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 »

Thanks for you time and sorry again I try to explain again my issue.

As you can see in the log the device is updated every 20 seconds. And the log also
Attachments
image1.gif
image1.gif (233 KiB) Viewed 3469 times
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 »

Now I understand the problem...

You say "this update"... What exactly did you update, just to be certain and prevent any further misunderstandings...
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'm using an oxaone plug which works perfectly with the plugin.
oxaone.jpg
oxaone.jpg (40.01 KiB) Viewed 3463 times
This device has 2 plugs. Every 20 seconds I receive new informations about Volt, Amp, WH.
And I receive also an updated about the status of one plug (only one).

Here is some logs

2020-03-11 18:53:18.683 (Tuya) Pushing 'onMessageCallback' on to queue
2020-03-11 18:53:18.683 (Tuya) Processing 'onMessageCallback' message
2020-03-11 18:53:18.683 (Tuya) Calling message handler 'onMessage'.
2020-03-11 18:53:18.683 (Tuya) onMessage called: 192.168.1.8: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'
2020-03-11 18:53:18.684 (Tuya - Gauche) Updating device from 0:'Off' to have values 0:'0.0'.
2020-03-11 18:53:18.688 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'0.0' to have values 0:'0.0;0'.
2020-03-11 18:53:18.691 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'0.0;74851.7' to have values 0:'227.8'.
2020-03-11 18:53:18.694 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'227.8' to have values 0:'0.0'.
2020-03-11 18:53:18.696 (Tuya) Updated: 0.0 Ampere Key is:2
2020-03-11 18:53:18.696 (Tuya) Updated: 0.0 Watt Key is:13
2020-03-11 18:53:18.697 (Tuya) Updated: 227.8 Voltage Key is:14
2020-03-11 18:53:18.697 (Tuya - Gauche) Updating device from 0:'0.0' to have values 0:'Off'.
2020-03-11 18:53:18.702 (Tuya) Update Tuya - Gauche: 0 - 'Off'
2020-03-11 18:53:18.702 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'0.0;0' to have values 0:'0.0'.
2020-03-11 18:53:18.704 (Tuya - Tuya SmartPlug (kWh)) Updating device from 0:'227.8;74851.7' to have values 0:'0.0;0'.
2020-03-11 18:53:18.707 (Tuya - Tuya SmartPlug (V)) Updating device from 0:'0.0' to have values 0:'227.8'.
2020-03-11 18:53:18.709 (Tuya - Tuya SmartPlug (W)) Updating device from 0:'0.0' to have values 0:'0.0'.
2020-03-11 18:53:18.712 (Tuya) Updated: 0.0 Ampere Key is:3
2020-03-11 18:53:18.712 (Tuya) Updated: 0.0 Watt Key is:14
2020-03-11 18:53:18.712 (Tuya) Updated: 227.8 Voltage Key is:15
2020-03-11 18:53:28.440 (Tuya) Pushing 'onHeartbeatCallback' on to queue
2020-03-11 18:53:28.478 (Tuya) Processing 'onHeartbeatCallback' message
2020-03-11 18:53:28.478 (Tuya) Calling message handler 'onHeartbeat'.
2020-03-11 18:53:38.443 (Tuya) Pushing 'onHeartbeatCallback' on to queue
2020-03-11 18:53:38.444 (Tuya) Processing 'onHeartbeatCallback' message
2020-03-11 18:53:38.444 (Tuya) Calling message handler 'onHeartbeat'.
2020-03-11 18:53:38.446 (Tuya) Pushing 'WriteDirective' on to queue
2020-03-11 18:53:38.446 (Tuya) Processing 'WriteDirective' message
2020-03-11 18:53:38.446 (Tuya) Sending 86 bytes of data
2020-03-11 18:53:38.446 (Tuya) 00 00 55 aa 00 00 00 00 00 00 00 0a 00 00 00 46 7b 22 64 65 ..U�...........F{"de
2020-03-11 18:53:38.446 (Tuya) 76 49 64 22 3a 22 35 35 31 34 32 37 30 37 62 63 64 64 63 32 vId":"55142707bcddc2
2020-03-11 18:53:38.447 (Tuya) 39 35 66 39 36 61 22 2c 22 67 77 49 64 22 3a 22 35 35 31 34 95f96a","gwId":"5514
2020-03-11 18:53:38.447 (Tuya) 32 37 30 37 62 63 64 64 63 32 39 35 66 39 36 61 22 7d 49 51 2707bcddc295f96a"}IQ
2020-03-11 18:53:38.447 (Tuya) d9 16 00 00 aa 55 .. .. .. .. .. .. .. .. .. .. .. .. .. .. �...�U
2020-03-11 18:53:38.524 (Tuya) Pushing 'ReadEvent' on to queue
2020-03-11 18:53:38.547 (Tuya) Processing 'ReadEvent' message
2020-03-11 18:53:38.547 (Tuya) Received 173 bytes of data
2020-03-11 18:53:38.547 (Tuya) 00 00 55 aa 00 00 00 00 00 00 00 0a 00 00 00 9d 00 00 00 00 ..U�...........�....
2020-03-11 18:53:38.547 (Tuya) 7b 22 64 65 76 49 64 22 3a 22 35 35 31 34 32 37 30 37 62 63 {"devId":"55142707bc
2020-03-11 18:53:38.547 (Tuya) 64 64 63 32 39 35 66 39 36 61 22 2c 22 64 70 73 22 3a 7b 22 ddc295f96a","dps":{"
2020-03-11 18:53:38.547 (Tuya) 31 22 3a 66 61 6c 73 65 2c 22 32 22 3a 66 61 6c 73 65 2c 22 1":false,"2":false,"
2020-03-11 18:53:38.547 (Tuya) 39 22 3a 30 2c 22 31 30 22 3a 30 2c 22 31 38 22 3a 30 2c 22 9":0,"10":0,"18":0,"
2020-03-11 18:53:38.548 (Tuya) 31 39 22 3a 30 2c 22 32 30 22 3a 32 32 37 38 2c 22 32 31 22 19":0,"20":2278,"21"
2020-03-11 18:53:38.548 (Tuya) 3a 31 2c 22 32 32 22 3a 36 30 39 2c 22 32 33 22 3a 32 37 32 :1,"22":609,"23":272
2020-03-11 18:53:38.548 (Tuya) 39 37 2c 22 32 34 22 3a 31 35 35 31 39 2c 22 32 35 22 3a 31 97,"24":15519,"25":1
2020-03-11 18:53:38.548 (Tuya) 33 34 30 7d 7d c5 5f ed aa 00 00 aa 55 .. .. .. .. .. .. .. 340}}�_��..�U
2020-03-11 18:53:38.548 (Tuya) Pushing 'onMessageCallback' on to queue
2020-03-11 18:53:38.548 (Tuya) Processing 'onMessageCallback' message
2020-03-11 18:53:38.548 (Tuya) Calling message handler 'onMessage'.
2020-03-11 18:53:38.548 (Tuya) onMessage called: 192.168.1.8: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'
2020-03-11 18:53:38.549 (Tuya - Gauche) Updating device from 0:'Off' to have values 0:'0.0'.
2020-03-11 18:53:38.553 (Tuya - Tuya SmartPlug (A)) Updating device from 0:'0.0' to have values 0:'0.0;0'.



Thanks a lot
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 »

That's a repeat of the original question.

Let's try to get some more details clarified...

Is this new, or did this work before?
Can you control both switches correctly through Domoticz?
If so, does anything change in the output for 1/2?

Do you intend to use both sockets as a single combined switch, or do you want to control them separately? In the latter case, you will need to remove the "DPS group" entry. In the former case, you should actually only see one switch update, because 1 & 2 are combined in to a group, and thus a single logical switch in Domoticz.

The frequency of updating seems to be determined by the plug sending updates every 20 seconds, and I do not know whether there is anything you can do about that...

If someone wants to go in to modify the code so it doesn't update it when it hasn't changed, that would definitely clean up the logs, but otherwise I do not think there is much we can do...
RasPi, Raspbian , Domoticz v2021.1, Z-Wave Stick, RFLink, RFXtrx433e, Hue, Tuya (Tasmota/Mosquitto with Discovery), ESP(easy), MySensors.org, OTGW
stin22
Posts: 2
Joined: Saturday 04 April 2020 23:20
Target OS: -
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by stin22 »

- installed domoticz,
- installed the "Tuya SmartPlug Config" plugin. Got access to tuya application, did run

Code: Select all

tuya-cli link --api-key CHANGE--api-secret CHANGE--schema CHANGE--ssid CHANGE--password CHANGE--region eu
and got responce from my device via terminal/api,

Code: Select all

[ { id: 'bf9202937a83995a0afauo',
    ip: 'NETIP',
    localKey: 'c4e548c7ee0294b9',
    name: 'something' } ]
put my "id" into DevId in my domoticz setup (is that correct, can i do that?)
put my localkey into localkey in domoticz setup
put my localip instead of netip (can i do that?)

did run

Code: Select all

~/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin $ ./get_dps.py 192.168.1.129 bf9202937a83995a0afauo
Unexpected status() payload=b'@\xb0\x98\xfb\xca\x96u\x90\x8d\x83\xc8\xc0\xe7\xf54jg\x19\xefV\x9f\xb9\x1a\x0c0\xa7L@\xf9\xe2\xdcF'

Plug State Information:
b'@\xb0\x98\xfb\xca\x96u\x90\x8d\x83\xc8\xc0\xe7\xf54jg\x19\xefV\x9f\xb9\x1a\x0c0\xa7L@\xf9\xe2\xdcF'

Plug DPS List:
Traceback (most recent call last):
  File "./get_dps.py", line 58, in <module>
    for key in data['dps'].keys():
not sure what i can get out of that... im not really sure what fork i should use or what could work with tuya ms104 module (controlls one socket via relay). Any suggestions?

Image
stin22
Posts: 2
Joined: Saturday 04 April 2020 23:20
Target OS: -
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by stin22 »

this is how i solved it..
rtfm about tuya-cli.... use

Code: Select all

tuya-cli link --api-key PROVIDED-BY-TUYA --api-secret PROVIDED-BY-TUYA --schema YOUR-APP-NAME --ssid YOURWIFI --password YOURWIFIPASSWORD --region CLOSEST-TUYA-SERVER-TO-YOU
if succeed. you will get id(DevID),ip(netip), localkey(KEY) and some strange namestuff...login to your router and check what the LANIP it got, make a note.

test your stuff using (ON/OFF)...

Code: Select all

tuya-cli set --id DevID--key KEY--dps 1 --set true

Code: Select all

tuya-cli set --id DevID--key KEY--dps 1 --set false
it might be slow but... if its working... its good. (device is good)
Download latest version of "Domoticz-Tuya-SmartPlug-Plugin" however, for me, i can turn on the plug but domoticz does not get the response from the tuya-device, so domoticz will send "on" command until it response, it seems to send response but it might be that it just wont understand tuya-device are really on.. To bypass this issue to get stuff to work but its not a good solution.. create a "dummy device" in hardware, and the "create virtual sensors" edit the virtual device to switch,
change ON action to..

Code: Select all

script:///SERVER/NAME/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/turnON.py LANIP DevID KEY 1 
change OFF action to..

Code: Select all

script:///SERVER/NAME/domoticz/plugins/Domoticz-Tuya-SmartPlug-Plugin/turnOFF.py LANIP DevID KEY 1 
this works for me today but its slower than running python-command via terminal (not sure if its any diffrent running it via domoticz gui) only issue i have is if got power failure on mains, all the tuya-devices will go "on" until i send "off" command, so i need to send on/off command to each one..
User avatar
jjnh
Posts: 33
Joined: Sunday 09 December 2018 14:06
Target OS: Linux
Domoticz version: 2023.1
Location: Netherlands
Contact:

Re: [REQUEST] Plugin for Tuya

Post by jjnh »

jjnh wrote: Tuesday 31 March 2020 16:45 Hi,

I requested the API access and now I see that Tuya is going to change the cloud API with a SAAS option. My ID's are no longer shown on the website. Missed it :(

Any ideas?

Kr.
John
Tuya support kindly explained how I can find the keys in the SaaS environment.

- Go to iot.tuya.com
- Click on your profile menu (litte person symbol right top)
- Go to Cloud API Authorization
- Then you get message about the new SaaS platform
- under that messagoeclick the GO button which takes you to the SaaS screen
- Click now in the middle of the screen on "SaaS (Default SaaS)"
- then the website show your keys

Hope this helps!
Odroid N2+ 4GB, with an RfxTrx433E, Zigbee with Slaesh's CC2652RB, Z-Wave, BroadLink IR using RM mini 3 and P1 connected.
User avatar
pgielen
Posts: 91
Joined: Monday 18 February 2019 14:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Boxmeer
Contact:

Re: [REQUEST] Plugin for Tuya

Post by pgielen »

Tuya is closing it's doors for software developers looking to integrate their products. If you want API access, you will have to apply for Enterprise certification online and this is only available for product manufacturers. I just tried that and did not get through: "If you are only developing software, we cannot provide API alone" was their answer.

Tuya is also revoking IFTTT access to it's devices in May this year. I got the following notification today:

Image

See also my blog at https://robothuis.nl/2020/04/28/tuya-st ... ing-ifttt/ (in Dutch, but with a Google translate button).

It seems we should better be putting our energy in flashing new firmware for their devices...
https://robothuis.nl, RPi4B, RFXCOM XL, Aeotec Z-Stick, ESP Easy, Weatherstation, several switches and sensors, Ikea Trädfri, Philips Hue, Foscam, Reolink, Lyric T6, Ring
jforum
Posts: 3
Joined: Monday 01 July 2019 8:48
Target OS: -
Domoticz version:
Contact:

Re: [REQUEST] Plugin for Tuya

Post by jforum »

Recently, I found a plugin that don’t require you to flash the Tuya firmware. It works similar to the Homeassistant Tuya Plugin.
Created a video to show you how to integrate it and make it work with Tuya Smart Life App. As of today, this plugin need a little code to make it work with the Smart Life App else it will just work with Tuya App.

https://youtu.be/pBJZcwIDOUY

Hope this help. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest