Giter VIP home page Giter VIP logo

domoticz-tuyacloud-plugin's People

Contributors

jcwlim avatar tizzen33 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jcwlim remimase

domoticz-tuyacloud-plugin's Issues

Dim Light Bulbs

Dear developer,

Great work. Plugin works like a charm. I used it with a few Wall Outlets.

Question: Is it possible to dim a light bulb with this Plugin? I want to buy suchs bulbs, but I want to be sure it works?

Sorry. Just read the description in Domoticz that only power plugs can be discovered and used.
Can you make a change to these plugin so that dimming and on/off bulbs is possible?

Thanks in advantage.

Error in log after setup

HI,

I just setup Tuya and the log says this:

2020-07-25 16:35:00.411 Status: (Tuya) Started.
2020-07-25 16:35:03.183 Status: (Tuya) Entering work loop.
2020-07-25 16:35:03.183 Status: (Tuya) Initialized version 0.1, author 'tizzen33'
2020-07-25 16:35:03.563 Error: (Tuya) 'onStart' failed 'AttributeError':''NoneType' object has no attribute 'get''.
2020-07-25 16:35:03.563 Error: (Tuya) ----> Line 192 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onStart
2020-07-25 16:35:03.563 Error: (Tuya) ----> Line 65 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onStart
2020-07-25 16:35:03.563 Error: (Tuya) ----> Line 89 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function syncDevices
2020-07-25 16:35:13.187 Error: (Tuya) 'onHeartbeat' failed 'AttributeError':''NoneType' object has no attribute 'get''.
2020-07-25 16:35:13.187 Error: (Tuya) ----> Line 223 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onHeartbeat
2020-07-25 16:35:13.187 Error: (Tuya) ----> Line 182 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onHeartbeat
2020-07-25 16:35:13.187 Error: (Tuya) ----> Line 115 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function checkAccessToken

Did I do something wrong? I'm new to Domoticz so probably me

Possible error in Tuyacloud together with Domoticz, Node-Red or may be not.

First thank you for your application. It works great when used in only Domoticz.
I have used it several times to add more Tuya like smart plug bought from Aliexpress and to "sync" changed names between the "Smart life" Android phone app and Domoticz. When I switch on/off a plug on the phone the icon changes in Domoticz, when I switch in Domoticz the changed status is visible in the phone app. Great.

I want to use these smart plugs in Domoticz and Node-Red, and I also like to see the powerconsumption measured by a plug.
I run Domoticz V4.10726, Mosquitto MQTT broker 1.4.10 and Node-Red V1.0.6 on a Raspberry PI 3B 4.19.66-v7+

As you probaly know Domoticz sends a copy of the row of the Device table to topic domoticz/out when I change the status of the plug to on/off. I defined in Node-Red a simple switch node and I filter incomming messages from domoticz/out on the relevant "idx". I also generate a small message with only the status of the switch topic domoticz/in when I change the switch in Node-Red.

When I change on/off in Domoticz, I see the switch in Node-Red/ui change as well. Great.
When I change the switch in Node-Red, I see the icon change in Domoticz, but the switching in the smart plug does not occur. So the power stays on/off as the status was.

Possibly this is an error in the Tuyacloud application, possibly it is an error in Domoticz, possibly I need to install something else.
Do you have any idea what causes this problem? Could you please give me a hint how to solve this?

I have extracted the following logs

//Converted message from domoticz/out to switch
16-7-2020 20:39:37node: 95d6a158.34616msg.payload : boolean
true
//outgoing message from switch to domoticz/in
16-7-2020 20:39:39node: 95d6a158.34616msg.payload : string[22]
"{"idx":64, "nvalue":1}"

16-7-2020 20:39:40node: 95d6a158.34616msg.payload : boolean
true
//Incomming device row message from domoticz/out, switch is set on
16-7-2020 20:39:41node: 95d6a158.34616domoticz/out : msg.payload : string[261]
"{? "Battery" : 255,? "RSSI" : 12,? "description" : "",? "dtype" : "Light/Switch",? "id" : "bf6eca135b7f20cde13vjh",
? "idx" : 64,? "name" : "Tuya - Smart Plug 64",? "nvalue" : 1,? "stype" : "Switch",? "switchType" : "On/Off",? "unit" : 4?}?"

16-7-2020 20:39:42node: 95d6a158.34616msg.payload : boolean
false
//Incomming device row message from domoticz/out, switch was set to off
16-7-2020 20:39:43node: 95d6a158.34616domoticz/out : msg.payload : string[281]
"{? "Battery" : 255,? "RSSI" : 12,? "description" : "",? "dtype" : "Light/Switch",? "id" : "bf6eca135b7f20cde13vjh",
? "idx" : 64,? "name" : "Tuya - Smart Plug 64",? "nvalue" : 0,? "stype" : "Switch",? "svalue1" : "0",? "switchType" : "On/Off",
? "unit" : 4?}?"

16-7-2020 20:39:44node: 95d6a158.34616msg.payload : string[22]
"{"idx":64, "nvalue":0}"

16-7-2020 20:39:45node: 95d6a158.34616msg.payload : boolean
false

16-7-2020 20:39:45node: 95d6a158.34616
domoticz/out : msg.payload : string[261]
"{? "Battery" : 255,? "RSSI" : 12,? "description" : "",? "dtype" : "Light/Switch",? "id" : "bf6eca135b7f20cde13vjh",? "idx" : 64,? "name" : "Tuya - Smart Plug 64",? "nvalue" : 0,? "stype" : "Switch",? "switchType" : "On/Off",? "unit" : 4?}?"

From Domoticz Log:
2020-07-16 20:39:32.490 Status: S0 Meter:ID:99001:I:10:M1:0:9847:M2:0:3234:M3:0:980:M4:0:6708:M5:0:0:M6:0:1397:M7:0:1:M8:0:1134:M9:0:0:M10:0:2705:M11:0:3452:M12:0:0
2020-07-16 20:39:33.763 (Tuya) onCommand: On, level (1) Color:
2020-07-16 20:39:33.763 (Tuya - Smart Plug 64) Updating device from 0:'' to have values 1:'1'.
2020-07-16 20:39:33.867 MQTT: Topic: domoticz/in, Message: {"idx":64, "nvalue":1}
2020-07-16 20:39:33.479 Status: User: Admin initiated a switch command (64/Tuya - Smart Plug 64/On)
2020-07-16 20:39:37.776 (Tuya) onCommand: Off, level (1) Color:
2020-07-16 20:39:37.776 (Tuya - Smart Plug 64) Updating device from 1:'' to have values 0:'0'.
2020-07-16 20:39:37.880 MQTT: Topic: domoticz/in, Message: {"idx":64, "nvalue":0}
2020-07-16 20:39:37.483 Status: User: Admin initiated a switch command (64/Tuya - Smart Plug 64/Off)

If you need more/other debug info, please tell me how to generate this. Thank you for your help

PIR / Temp / Humidity sensor support

Hello,

I have 2 sensors from Neo Coolcam connected via Wifi to the Tuya Cloud (Neo Coolcam NAS-PD07W)
These sensors deliver data if there is motion (PIR), temperature and humidity.

I would like to have that data available in Domoticz.

This is the startup of the script:

2020-08-30 20:20:05.445 (Tuya HA) Debug logging mask set to: PYTHON
2020-08-30 20:20:05.445 (Tuya HA) onStart called
2020-08-30 20:20:05.445 (Tuya HA) Starting connection to Tuya Cloud
2020-08-30 20:20:05.576 (Tuya HA) Connection established.
2020-08-30 20:20:05.576 (Tuya HA) Getting devices ...
2020-08-30 20:20:05.735 (Tuya HA) Devices found:[]
2020-08-30 20:20:05.735 (Tuya HA) Tuya Cloud devices initialized.
2020-08-30 20:20:05.237 Status: (Tuya HA) Started.
2020-08-30 20:20:05.444 Status: (Tuya HA) Initialized version 0.1, author 'tizzen33'
2020-08-30 20:20:05.444 Status: (Tuya HA) Entering work loop.

As you can see no devices.

How can I help to get these devices supported?

Air Conditioning

Hello I have some infrared devices that I use thru the smartlife app but It would be nice if I can integrate them in python.
Starting the plugin in verbose mode gives me this log:

2020-08-27 17:20:10.554 (Tuya Smart Life) Connection established.
2020-08-27 17:20:10.554 (Tuya Smart Life) Getting devices ...
2020-08-27 17:20:11.096 (Tuya Smart Life) Devices found:[{"data": {}, "name": "2xcdz off", "id": "J61c0W1vszaBT5Ot", "dev_type": "scene", "ha_type": "scene"}, {"data": {}, "name": "2xcdz dry 24c", "id": "hJTSCFlGUE1ywtaf", "dev_type": "scene", "ha_type": "scene"}]
2020-08-27 17:20:11.096 (Tuya Smart Life) Looping through tuya devices
2020-08-27 17:20:11.096 (Tuya Smart Life) Looping through tuya devices
2020-08-27 17:20:11.097 (Tuya Smart Life) Tuya Cloud devices initialized.
2020-08-27 17:20:11.097 (Tuya Smart Life) Heartbeat interval set to: 30.

As you can see there is no device, but only the scenes that I have 2xcdz off and 2xcdz dry 24c

I will check thru your code and try to find out if I can contribute to it (I'm quite basic with python...)

Can you give me some hints?

Ciao Gianluca

I modified a little bit the code for lights

on line 109 I addes
if (createDomoticzDevice and tuya_device["ha_type"] == "light"): Domoticz.Device(Name=tuya_device["name"],Unit=maxUnit+1,TypeName='Switch',DeviceID=tuya_device["id"]).Create() Domoticz.Debug('Creating a {type} device with identifier {id}'.format(type=tuya_device["ha_type"],id=tuya_device["id"]))

on the line 141 I remove caps on True and False
states = {'true': 1, 'false': 0}

Now I wolud like to dim the light but I do not know how I will do yet

Requires python3-dev

Hi,

I followed the instructions, but the "Tuya Cloud" entry was not showing up.
After looking at the "Log" section in Domoticz, I found that python3-dev was missing.

I installed it (sudo apt-get install python3-dev) then restarted domoticz (systemctl restart domoticz) and the entry is now OK.

I don't know if it's relevant to add it in the prerequisites, just wanted to share :)

Wrong width in field Password and Mode1

Hi @tizzen33,
Thanks for the nice plugin! Works just fine.
A small error in de xml part. The sizes of the field Password and Mode1 (countryCode) are mixed up:
Currently:
<param field="Password" label="Password" width="30px" required="true" default="" password="true"/> <param field="Mode1" label="countryCode" width="150px" required="true"/>
Should be:
<param field="Password" label="Password" width="150px" required="true" default="" password="true"/> <param field="Mode1" label="countryCode" width="30px" required="true"/>
I'm not a Python programmer, so I will probably not contribute anything meaningful :-(
But I'm looking forward to extension of the plugin to incorporate the kWh usage that is recorded by the SmartLife plugs.

BTW: I use it on Windows 10 machine
Domoticz Version: 2020.2 (build 12280)
Build Hash: f8711e9c1
Compile Date: 2020-08-28 11:52:32
dzVents Version: 3.0.11
Python Version: 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)]
(Python-Dev seems to be included on the Windows version of Python)

Smart Life connection

Hi, I am trying this wonderful plugin now.
May I know does it work only with "Tuya"? Can it work with "Smart Life" which is another clone directly and mange by the Tuya company.
I have a switch (power plug) in the "Smart Life" app but it never pick up by the plugin.
I try to change the code under "params" - "from": "smart_life" still no go....

Current version possibly not working on Raspberry PI 4B

Hello,
I am trying to get tuyacloud working on a RPI4. Previously I have installed this sw on a RPI3B and with your help I got it working perfectly. On the RPI4 I have installed the os and all software from scratch. After that I copied domoticz.db from the RPI3. Just before the following errorlog I have deleted the map domoticz-tuyacloud-plugin from domoticz/plugins and after that downloaded a fresh copy. I deleted the "old" row of Tuya cloud in Setup/Hardware, created a new row, filled in my credentials and restarted domoticz. Resulting in the following Log from domoticz:
2020-08-20 14:20:31.282 (Tuya) onStop called 2020-08-20 14:20:31.279 Status: (Tuya) Stop directive received. 2020-08-20 14:20:31.279 Status: (Tuya) Exiting work loop. 2020-08-20 14:20:31.379 Status: (Tuya) Stopping threads. 2020-08-20 14:20:31.380 Status: (Tuya) Stopped. 2020-08-20 14:20:31.455 Status: Incoming connection from: 192.168.2.7 2020-08-20 14:20:43.630 Error: S0 hardware (5) thread seems to have ended unexpectedly 2020-08-20 14:20:57.632 Error: S0 hardware (5) thread seems to have ended unexpectedly 22020-08-20 14:24:01.645 Status: (tuya new) Started. 2020-08-20 14:24:02.009 Status: (tuya new) Entering work loop. 2020-08-20 14:24:02.009 Status: (tuya new) Initialized version 0.1, author 'tizzen33' 2020-08-20 14:24:02.148 Error: (tuya new) 'onStart' failed 'AttributeError':''NoneType' object has no attribute 'get''. 2020-08-20 14:24:02.148 Error: (tuya new) ----> Line 197 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onStart 2020-08-20 14:24:02.148 Error: (tuya new) ----> Line 65 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onStart 2020-08-20 14:24:02.148 Error: (tuya new) ----> Line 89 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function syncDevices 2020-08-20 14:24:12.016 Error: (tuya new) 'onHeartbeat' failed 'AttributeError':''NoneType' object has no attribute 'get''. 2020-08-20 14:24:12.016 Error: (tuya new) ----> Line 228 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onHeartbeat 2020-08-20 14:24:12.016 Error: (tuya new) ----> Line 187 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onHeartbeat 2020-08-20 14:24:12.016 Error: (tuya new) ----> Line 118 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function checkAccessToken
Linux rp4 5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020 armv7l GNU/Linux
$PATH -bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:
Python 2.7.16 and Python 3.7.3
Domoticz : Version: 2020.2

I asume something is missing from the new installation or have you any idea what I am doing wrong?
Thanks in advance
Heinohein

New device and Errors

Hi,
Great the finally someone is trying to make a plugin that works with Tuya itself and not with all kinds of tricks using firmware and ID sniffing. Thanks for that!!

I have installed the plugin but I don't have any power sockets currently in my installation. I only have a vaporizer (small device to spread scented oil and water vapor) for our bedroom as my wife has a lung condition and this helps a lot. This device has a off/low/high switch for the vaporizer and a color led switch for the light (on/of/color/white/dim).

When starting the plugin everything looks fine, but I cannot see the device:

2020-06-04 08:37:08.465 (Tuya) Debug logging mask set to: PYTHON PLUGIN DEVICE CONNECTION MESSAGE 2020-06-04 08:37:08.465 (Tuya) onStart called 2020-06-04 08:37:08.465 (Tuya) Starting connection to Tuya Cloud 2020-06-04 08:37:08.692 (Tuya) Connection established. 2020-06-04 08:37:08.692 (Tuya) Getting devices ... 2020-06-04 08:37:08.906 (Tuya) Devices found:[] 2020-06-04 08:37:08.906 (Tuya) Tuya Cloud devices initialized. 2020-06-04 08:37:08.906 (Tuya) Heartbeat interval set to: 30. 2020-06-04 08:37:08.463 Status: (Tuya) Entering work loop. 2020-06-04 08:37:08.463 Status: (Tuya) Initialized version 0.1, author 'tizzen33'

Also while the plugin is running I receive these errors sometimes:

2020-06-03 08:54:19.319 Error: (Tuya) 'onStart' failed 'AttributeError':''NoneType' object has no attribute 'get''. 2020-06-03 08:54:19.319 Error: (Tuya) ----> Line 194 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onStart 2020-06-03 08:54:19.319 Error: (Tuya) ----> Line 65 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onStart 2020-06-03 08:54:19.319 Error: (Tuya) ----> Line 89 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function syncDevices 2020-06-03 08:54:29.136 Error: (Tuya) 'onHeartbeat' failed 'AttributeError':''NoneType' object has no attribute 'get''. 2020-06-03 08:54:29.137 Error: (Tuya) ----> Line 225 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onHeartbeat 2020-06-03 08:54:29.137 Error: (Tuya) ----> Line 184 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function onHeartbeat 2020-06-03 08:54:29.137 Error: (Tuya) ----> Line 115 in '/home/pi/domoticz/plugins/domoticz-tuyacloud-plugin/plugin.py', function checkAccessToken

Any ideas?

Regards,
John

RGBWW support

Hi tizzen33,

I notice the update on tuya plugin for dimming, great job! is it possible to add RGBWW support?

Log Domoticz:

2020-08-19 14:18:59.995 Status: (Tuya Cloud) Started.
2020-08-19 14:19:02.154 (Tuya Cloud) Debug logging mask set to: PYTHON PLUGIN DEVICE CONNECTION MESSAGE
2020-08-19 14:19:02.154 (Tuya Cloud) onStart called
2020-08-19 14:19:02.154 (Tuya Cloud) Starting connection to Tuya Cloud
2020-08-19 14:19:02.390 (Tuya Cloud) Connection established.
2020-08-19 14:19:02.390 (Tuya Cloud) Getting devices ...
2020-08-19 14:19:02.618 (Tuya Cloud) Devices found:[{"data": {"brightness": "255", "color_mode": "white", "online": true, "state": "false", "color_temp": 10000}, "name": "LED SMART", "icon": "https://images.tuyaeu.com/smart/icon/ay1541056239985fDGjj/15620318474c719f1c5cf.png", "id": "bfa81b880e00ff2253o66a", "dev_type": "light", "ha_type": "light"}]
2020-08-19 14:19:02.618 (Tuya Cloud) Looping through tuya devices
2020-08-19 14:19:02.618 (Tuya Cloud) Creating device 'LED SMART'.
2020-08-19 14:19:02.619 (Tuya Cloud) Creating a light device with identifier bfa81b880e00ff2253o66a
2020-08-19 14:19:02.851 (Tuya Cloud) Tuya Cloud devices initialized.
2020-08-19 14:19:02.852 (Tuya Cloud) Heartbeat interval set to: 30.
2020-08-19 14:19:02.150 Status: (Tuya Cloud) Entering work loop.
2020-08-19 14:19:02.151 Status: (Tuya Cloud) Initialized version 0.1, author 'tizzen33'

Greetings Xenomes

Can not find curtain switch

Hi,

I just installed the plugin and from the Domoticz logfile it looks like my curtain switch "Sunscreen" in tuya is correctly found.
However I don't see any device in Domoticz. Is this type of switch currently supported by your plugin?

Thanks,

Andreas

2020-08-15 17:27:48.417 Status: (Tuya) Stop directive received.
2020-08-15 17:27:48.417 Status: (Tuya) Exiting work loop.
2020-08-15 17:27:48.618 Status: (Tuya) Stopping threads.
2020-08-15 17:27:48.618 Status: (Tuya) Stopped.
2020-08-15 17:27:48.618 Status: (Tuya) Started.
2020-08-15 17:27:49.657 (Tuya) Debug logging mask set to: PYTHON
2020-08-15 17:27:49.657 (Tuya) onStart called
2020-08-15 17:27:49.658 (Tuya) Starting connection to Tuya Cloud
2020-08-15 17:27:49.904 (Tuya) Connection established.
2020-08-15 17:27:49.904 (Tuya) Getting devices ...
2020-08-15 17:27:49.655 Status: (Tuya) Entering work loop.
2020-08-15 17:27:49.655 Status: (Tuya) Initialized version 0.1, author 'tizzen33'
2020-08-15 17:27:50.156 (Tuya) Devices found:[{"data": {"support_stop": true, "online": true, "state": 2}, "name": "Sunscreen", "icon": "https://images.tuyaeu.com/smart/icon/1533128826suy28xwbr0h_0.png", "id": "06270507fcf5c4840bae", "dev_type": "cover", "ha_type": "cover"}]
2020-08-15 17:27:50.156 (Tuya) Looping through tuya devices
2020-08-15 17:27:50.157 (Tuya) Tuya Cloud devices initialized.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.