fison67 / ty-connector Goto Github PK
View Code? Open in Web Editor NEWConnector for Tuya Devices with SmartThings
License: MIT License
Connector for Tuya Devices with SmartThings
License: MIT License
Weird problem with a newly added light. I'm hoping you can help me work out the source of the problem.
I'm using the Docker instance v0.0.2.6 on a RPi, and I updated the DH and SmartApp a few hours ago. I have two lights working just fine. I added a third light, the same brand as one of the other two, and configured it much the same (different IP, ID and key, of course). However, the ty-connector logs show that strange behaviour in relation to the new light, and I have intermittent dropouts where I can't control the light from ST.
The log shows frequent dumps of the dps values, at a rate of two per second; the other lights don't show these logs (at least not at that rate). After a while the connection to the light drops out, presumably because of the excess traffic. After 5-10 minutes it sometimes comes good again. But sometimes I have to restart the ty-connector docker process.
2019-09-30 10:48:11 [info]: Enabled Custom HTTPS
2019-09-30 10:48:12 [info]: robe: Device is connected
2019-09-30 10:48:12 [info]: Day Bed Light: Device is connected
2019-09-30 10:48:12 [info]: Study Lamp: Device is connected
2019-09-30 10:48:12 [info]: robe: {"20":true,"21":"white","22":127,"23":0,"24":"002e01e6003c","25":"04464602007803e803e800000000464602007803e8000a00000000"}
2019-09-30 10:48:12 [info]: Day Bed Light: {"1":false,"2":"colour","3":27,"4":113,"5":"120e1b01037c1b","6":"00ff0000000000","7":"ffff500100ff00","8":"ffff8003ff000000ff000000ff000000000000000000","9":"ffff5001ff0000","10":"ffff0505ff000000ff00ffff00ff00ff0000ff000000"}
2019-09-30 10:48:12 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:48:12 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:48:13 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:48:13 [info]: robe is already registered to SmartThings. IP(192.168.1.89)
2019-09-30 10:48:13 [info]: Day Bed Light is already registered to SmartThings. IP(192.168.1.88)
2019-09-30 10:48:13 [info]: Study Lamp is already registered to SmartThings. IP(192.168.1.96)
2019-09-30 10:48:13 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:48:14 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:48:14 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:48:15 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:48:15 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:49:00 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:49:01 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:49:01 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:49:02 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:49:02 [info]: Study Lamp: Device is error >> Error: Error from socket
2019-09-30 10:49:02 [info]: Study Lamp: Device is disconnected
2019-09-30 10:49:32 [info]: Study Lamp: Device is connected
2019-09-30 10:49:32 [info]: Study Lamp: Device is error >> Error: Error from socket
2019-09-30 10:49:32 [info]: Study Lamp: Device is disconnected
2019-09-30 10:50:02 [info]: Study Lamp: Device is connected
2019-09-30 10:50:02 [info]: Study Lamp: Device is error >> Error: Error from socket
2019-09-30 10:50:02 [info]: Study Lamp: Device is disconnected
2019-09-30 10:50:32 [info]: Study Lamp: Device is connected
2019-09-30 10:50:32 [info]: Study Lamp: Device is error >> Error: Error from socket
2019-09-30 10:50:32 [info]: Study Lamp: Device is disconnected
2019-09-30 10:51:02 [info]: Study Lamp: Device is connected
2019-09-30 10:51:02 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:51:03 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:51:03 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
2019-09-30 10:51:04 [info]: Study Lamp: {"20":true,"21":"colour","22":255,"23":255,"24":"ffffffffffff","25":"000e0d00002e03e8000000c80000"}
At the very moment of the disconnect, the light sends a reset:
23:12:54.306384 IP 192.168.1.96.6668 > 192.168.1.91.40232: Flags [S.], seq 178277, ack 1198253578, win 4380, options [mss 1460], length 0
23:12:54.306516 IP 192.168.1.91.40232 > 192.168.1.96.6668: Flags [.], ack 1, win 29200, length 0
23:12:54.309781 IP 192.168.1.91.40232 > 192.168.1.96.6668: Flags [P.], seq 1:89, ack 1, win 29200, length 88
23:12:54.316014 IP 192.168.1.96.6668 > 192.168.1.91.40232: Flags [.], ack 89, win 4292, length 0
23:12:54.317292 IP 192.168.1.96.6668 > 192.168.1.91.40232: Flags [R.], seq 1, ack 89, win 4380, length 0
23:13:02.779678 IP 192.168.1.91.37646 > 192.168.1.89.6668: Flags [P.], seq 550:605, ack 281, win 30016, length 55
At each retry, the connection is established but another reset is sent:
23:15:24.664854 IP 192.168.1.91.40262 > 192.168.1.96.6668: Flags [S], seq 2947561079, win 29200, options [mss 1460,sackOK,TS val 1134209477 ecr 0,nop,wscale 7], length 0
23:15:24.674006 IP 192.168.1.96.6668 > 192.168.1.91.40262: Flags [S.], seq 215533, ack 2947561080, win 4380, options [mss 1460], length 0
23:15:24.674104 IP 192.168.1.91.40262 > 192.168.1.96.6668: Flags [.], ack 1, win 29200, length 0
23:15:24.677200 IP 192.168.1.91.40262 > 192.168.1.96.6668: Flags [P.], seq 1:89, ack 1, win 29200, length 88
23:15:24.694053 IP 192.168.1.96.6668 > 192.168.1.91.40262: Flags [.], ack 89, win 4292, length 0
23:15:24.694516 IP 192.168.1.96.6668 > 192.168.1.91.40262: Flags [R.], seq 1, ack 89, win 4380, length 0
While it's working, I can turn the light off and on using the ST app, and even from Google Assistant. But when the connection drops out, both of these stop working - but I can control using tuya-cli.
I've installed the ty-connector docker container on a raspberry pi and have got it running in smartthings. It seems to be communicating with the device as the trigger from smartthings is briefly powering off the outlet however it instantly powers it back on automatically. I used smart life to connect the device and extract the localkey and deviceid and then uninstalled it from my phone.
Any suggestions?
how to setup on mac
One Bulb Works Perfectly while the other 14 don’t and they’re all the same brand and firmware. Any ideas?
I'm obviously missing something...I have te device set up with the key, etc. I have the Smarttings API App ID and token entered. Not sure about the Smartthings API, though. An example of the configuration page that works would be helpful!
In the log it shows error from socket, disconnected and device destroyed.
Any help would be appreciated! Thanks
Hi. I'm running v0.0.2 docker on a RPi and it works well for two light bulbs I have. I recently acquired a smart kettle that uses Smart Life app and Tuya network. I'd like to add support for this, but I'm not sure how. I can write code (new to JS though) so I should be able to do something. I've started writing a script using tuya-api.
I'd be grateful for any help you could give me.
My problems are:
Is there a git repository I can use to get the code, maybe submit PRs? Is there a device type that I can use so that SmartThings recognises the device as a kettle?
I can read the current water temperature, and I can turn on and off the kettle. I'd like to be able to use all of the other features. See the app interface here:
and tapping on "keep warm":
I don't expect to be able to control the schedule, but other features would be nice.
Apart from turning on and off, the kettle supports "keep at temp X" where X is a number in "range":["40","50","60","80","90","currenttemp"]. I posted the schema to https://github.com/clach04/python-tuya/wiki/DeviceSchemas.
There are four dps IDs. I'm still trying to work out what they do.
id=1 is power status, initially undefined but set to true if kettle is turned on and false if it's turned off
id=5 is water temp
id=101 and 102 always return undefined. I can set the value of id=102 to any of the strings in the range listed above, but it doesn't seem to change it.
Any help you can give would be gratefully appreciated.
Got permission denied while trying to connect to the Docker daemon socket.. error?
How to setup TY-Connector?
I have the Docker running on a Raspberry Pi can open the web page for the Tuya Connector.
But smartthings is not seeing Tuya plug.
Hello. I got the following log error from the TY-Connector portal Log:
Date Type Content
2019-06-21 10:59:16 error Error: Not Found at /usr/src/app/app.js:137:13 at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13) at /usr/src/app/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12) at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10) at /usr/src/app/node_modules/express/lib/router/index.js:635:15 at next (/usr/src/app/node_modules/express/lib/router/index.js:260:14) at Function.handle (/usr/src/app/node_modules/express/lib/router/index.js:174:3) at router (/usr/src/app/node_modules/express/lib/router/index.js:47:12)
I have no idea what this means. The device registers to smartthings, but it does not respond to commands from the smartthings app even though I configured it as instructed. What do I need to do? Also, in smartthings IDE, the device says ACTIVE but does not say ONLINE.
Thanks.
I keep receiving this error message in the system log:
2019-07-13 09:01:27 | error | Error: Not Found at /usr/src/app/app.js:137:13 at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/usr/src/app/node_modules/express/lib/router/index.js:317:13) at /usr/src/app/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:335:12) at next (/usr/src/app/node_modules/express/lib/router/index.js:275:10) at /usr/src/app/node_modules/express/lib/router/index.js:635:15 at next (/usr/src/app/node_modules/express/lib/router/index.js:260:14) at Function.handle (/usr/src/app/node_modules/express/lib/router/index.js:174:3) at router (/usr/src/app/node_modules/express/lib/router/index.js:47:12) |
---|
And device does not respond to controller inside SmartThings app although it does appear.
So… I’ve tried EVERYTHING aside from flashing firmware including erocm1231’s smart life smart apps and device handlers and fison67’s TY-Connector among other work arounds and here’s the only thing I’ve found that works for getting your Tuya Devices into the STs app. Run home-assistant on a local machine and then integrate tuya into home-assistant which is a simple three line edit in the home-assistant config.yml file and boom automatic instantaneous home-assistant tuya integration. Then run fison67’s HA-Connector and boom the tuya devices from Home Assistant show up in smart-things app and they are controllable. I only got one light to work temporarily with fison67’s TY-connector and to hell with openhab on a raspberry pi. Apt package install no longer works and running openhab on docker on raspberry pi is fraught with configuration issues due to mounting local directories and volumes which require docker compose and inevitably you will incur an internal server error 500 on openhab even stable release 2.4. I’ve been at this for 7 months and trust me, the only thing that works besides flashing which is risky, appears not to work with my particular version of wifi color led which is Lohas and Ambycora and a pain in the ass, is integrating Tuya with Home Assistant and then using fison67’s HA-Connector which itself is difficult, but not impossible to configure. Fison67 promised he’d put up instructions on HA-Connector soon.
How do I get app id and access token?
Hi
I'm trying to control a Tuya color bulb with ty-connector beta. Firmware is version 1.0.5 so created using v3.3. I copied IP, key and id from packet capture.
Ty-connector in the raspberry pi docker image is failing to start and looping with the following in the log file. I have tried blowing away and re-installing with no luck,
[email protected] start /usr/src/app
node ./bin/www
2019-04-28 08:40:02 [info]: WebSocket init
/usr/src/app/service/tuya.js:22
for(var i=0; i<list.length; i++){
^
TypeError: Cannot read property 'length' of undefined
at TuyaService._init (/usr/src/app/service/tuya.js:22:25)
at Timeout.TuyaService.setTimeout [as _onTimeout] (/usr/src/app/service/tuya.js:16:12)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
pi@magicmirror:~ $ docker version
Client:
Version: 17.09.0-ce
API version: 1.32
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:58:36 2017
OS/Arch: linux/arm
Server:
Version: 17.09.0-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:52:15 2017
OS/Arch: linux/arm
Experimental: false
pi@magicmirror:~ $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
fison67/ty-connector-rasp 0.0.1 60faa000f1ae 2 months ago 520MB
pi@magicmirror:~ $ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
68ac2d39c6ce fison67/ty-connector-rasp:0.0.1 "/usr/bin/entry.sh..." 19 minutes ago Up 15 seconds ty-connector-rasp
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.