bewee / tuya-adapter Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
I got a Feit Electric bulb working with this add-on.
There is one feature of the Feit vendor app that would be nice to have in the gateway: Tuya "flash scenes", which are listed under the "Effects" tab of the Feit app.
API documentation is here
https://developer.tuya.com/en/docs/iot/dj?id=K9i5ql3v98hn3#title-14-flash_scene_1
I used the Tuya IoT Platform to set and activate the effects, so I know it can be done outside of the vendor app.
If there's anything I can do to help, I'm willing.
Thanks,
David
Hi, firstly thanks for your work - my lights work a treat no issue with this addon. I have a kknoon (Tuya Thermostat) "model": "ME81", "product_id": "gogb05wrtredz3bs", "product_name": "smart thermostats". I'd love to get this working with WebThings but there isn't a drop down for thermostats (Fireplace heater? might work). I've tried using that Fireplace heater option but the config is wrong. I'd be happy to write a config as I have access to the Tuya IoT and can get all the commands I'm just not sure how to add them in a config. Here's a dump of the json. I'd be happy to test any suggestions to get this to work.
"result": { "category": "wk", "functions": [ { "code": "switch", "desc": "switch", "name": "switch", "type": "Boolean", "values": "{}" }, { "code": "mode", "desc": "mode", "name": "mode", "type": "Enum", "values": "{\"range\":[\"auto\",\"manual\"]}" }, { "code": "frost", "desc": "frost", "name": "frost", "type": "Boolean", "values": "{}" }, { "code": "temp_set", "desc": "temp set", "name": "temp set", "type": "Integer", "values": "{\"unit\":\"℃\",\"min\":5,\"max\":90,\"scale\":0,\"step\":1}" }, { "code": "upper_temp", "desc": "upper temp", "name": "upper temp", "type": "Integer", "values": "{\"unit\":\"℃\",\"min\":30,\"max\":90,\"scale\":0,\"step\":1}" }, { "code": "lower_temp", "desc": "lower temp", "name": "lower temp", "type": "Integer", "values": "{\"unit\":\"℃\",\"min\":5,\"max\":20,\"scale\":0,\"step\":1}" }, { "code": "temp_correction", "desc": "temp correction", "name": "temp correction", "type": "Integer", "values": "{\"unit\":\"摄氏度\",\"min\":-9,\"max\":9,\"scale\":0,\"step\":1}" }, { "code": "factory_reset", "desc": "factory reset", "name": "factory reset", "type": "Boolean", "values": "{}" }, { "code": "child_lock", "desc": "child lock", "name": "child lock", "type": "Boolean", "values": "{}" }, { "code": "sensor_choose", "desc": "sensor choose", "name": "sensor choose", "type": "Enum", "values": "{\"range\":[\"in\",\"out\"]}" } ] }, "success": true, "t": 1644424869288 }
In implementing this, it appears that the Tuya Adapter Add-On only can accommodate one switch or item at a time. Adding a second appears to disable the first in the interface. If I'm missing something, great, but if not, let me know and I'll see what I can do to resolve this.
The Home Assistant project and some other smart home gateways have managed to connect to the TUYA smart doorbell API, so I'm wondering if this add-on for the WebThings Gateway could be enhanced to include it. The device includes a motion sensor, IR and light sensors, a mic, speaker, video camera, and of course a doorbell (momentary push button).
And even if I tried to initially detect it as a switch, I am not sure what to fill in for "key (aka localKey)" on the configuration page for the add-on. I did put in the device id. But I don't see anything when I scan for devices. I would also have expected to have to fill in my email/passwd to connect via the API, but that information isn't in the add-on config.
Any thoughts, tips?
Hi there,
I am a pensionado who is new to the world of Raspberry and the WebThings. I have worked my entire career in software development, but the last 25 years as project manager, so my coding experience is antique.
I have recently bought a number of Woox (Tuya compatible) smart devices and came across the Web Things Gateway. I have bought a Raspberry Pi and installed the WebThings.io gateway (1.0). I did look for an add-on for Woox, without success. So I installed the Tuya add-on (which is closest to my devices), but my devices were not recognized.
Now I would like to find a way to extend the gateway so that Woox devices are recognized. I am familiar with programming concepts, but a rooky when it comes to Python, NodeJS, etc., but I would like to learn.
I have a number of questions about my next steps:
Best regards,
Paul
I added a Lumary Dimmer Switch L-DS100. When type is set as switch it only has on/off. When set as a thing it has no function available. Set type as a lamp and used configuration below. Seems to work best with non-LED dimmable bulbs such as incandescent or halogen bulbs. Could not remove lighttemp setting in config as they returned when using switch.
{"dps":{"on":1,"brightness":2,"lighttemperature":3},"minbrightness":0,"maxbrightness":100,"minlighttemperature":0,"maxlighttemperature":1000}
I get this device to connect but does not turn on or off.
https://www.amazon.com/Treatlife-Required-Assistant-Single-Pole-Schedule/dp/B07WWYQJFR
I think it is just config. Info from tuya app
Code | Type | Values
switch_1 | Boolean | {true,false}
countdown_1 | Integer | {"unit":"s","min":0,"max":86400,"scale":0,"step":1}
https://auth.tuya.com/register is the URL for registering a new developer account, not iot as in settings docs. Thanks!!
Devices disconnect and reconnect randomly. Increasing connection timeout only helps momentarily.
I just confirmed that the Feit Electric (sold at Costco!) indoor smart plugs work perfectly with this add on. Presumably their bulbs will also work, now that I have confirmed that some devices work I will get some more.
Thank you for this add on. I'm a developer but had never heard of Tuya, now I know way, way to much about it. I used the TinyTuya library for getting the keys to the devices, https://github.com/jasonacox/tinytuya, the walkthrough there of creating a Tuya developer account was by far the easiest method I found of getting the key. If I have some time I'll look at integrating the tinytuya wizard functionality into the add on, this may make it easier for non-developers eventually to use these devices. As it stands, they are a major PITA, I can't imagine a non-dev being able to use them!
Hi.
I have a air conditioner (Columbia Vac) that uses WiFi and connects through the Smart Life app. Is there a chance to add it to your adapter?
Firstly thanks for this - it's super cool :)
I have a simple project I'm working on where I need to be able to update device properties via HTTP requests. Currently if I want to toggle the lights on and off I need to send one request to get the current state and then another to update to the opposite state. Caching a local state leads to turning it on when it's already on sometimes and vis versa (with my setup, multiple switches e.t.c, this would happen a lot). Therefore having access to a toggle action would half the execution time.
This may already be possible and I'm just missing something - let me know if that's the case.
Otherwise I've had a go here. I believe the tuya-api has support for toggling directly - but there's probably an easier way using the state cached in the raspberry pi. I've had a go at forking and implementing and having a go but I'm quite stuck and I don't have the best setup. Started by making an action to turn off which I've attached if you're curious. If you have pointers on how to continue that would be appreciated or if it's a feature you think you could add I'd be happy with that too.
For extra context I'm using this avatar controls E14 colour light: https://www.amazon.co.uk/gp/product/B07W6Z6KPG/ref=ppx_yo_dt_b_asin_title_o07_s00?ie=UTF8&psc=1 which I got working (relatively) easily so you could add it to your list. I had to configure it with: "minbrightness":25,"maxbrightness":255,"minlighttemperature":0,"maxlighttemperature":255"
Sean.
colourlight-device.js:
...
class ColourLightDevice extends TuyaDevice {
constructor(adapter, cnf, cid) {
super(adapter, cnf, cid);
this.name = cnf.name&&cnf.name!='' ? cnf.name : 'Colour Light';
this['@type'] = ['Light', 'OnOffSwitch'];
// Altered this so I can access power property below
this.powerProperty = new PowerProperty(this, {dps: this.ownconf.dps.on, default_dps: 1});
this.addProperty(powerProperty);
const modecb = ((mode) => {
switch (mode) {
case 'white':
this.setVisibility(['on', 'mode', 'brightness', 'lighttemperature']);
break;
case 'colour':
this.setVisibility(['on', 'mode', 'colour', 'hue', 'saturation', 'lightness']);
break;
}
this.adapter.handleDeviceUpdated(this);
}).bind(this);
this.addProperty(new ModeProperty(this, {dps: this.ownconf.dps.mode, default_dps: 2, modes: ['white', 'colour'], modestxt: ['White', 'Colour'], setcb: modecb, updatecb: modecb}));
this.addProperty(new BrightnessProperty(this, {dps: this.ownconf.dps.brightness, default_dps: 3}));
this.addProperty(new LighttemperatureProperty(this, {dps: this.ownconf.dps.lighttemperature, default_dps: 4}));
this.addProperty(new ColourProperty(this, {dps: this.ownconf.dps.colour, default_dps: 5}));
this.addProperty(new HueProperty(this));
this.addProperty(new SaturationProperty(this));
this.addProperty(new LightnessProperty(this));
this.addAction('toggle', {label: 'Toggle'}); // This line creates a toggle action in the UI, this works.
}
// Added this function to perform action (just turns off for now) - seems to prevent connection - probably missing something.
performAction(action) {
this.powerProperty.update(false);
}
}
Jinvoo SM-SW102-2 2 gang light switch. Must be configured as a thing to operate both switches.
Successfully created new thing Jinvoo 2 Gang
2020-04-03 13:52:06.369 INFO : tuya-adapter: Thing saved tuya-120002460019448fc35
2020-04-03 13:52:10.199 INFO : tuya-adapter: tuya-120002460019448fc35 Connected!
2020-04-03 13:52:10.303 INFO : tuya-adapter: tuya-120002460019448fc35 Data { devId: '120002460019448fc35', dps: { '1': true, '2': true } }
All my Tuya devices disconnected. disabling then enabling adapter did nothing. Rebooted Gateway, still disconnected. Here is log info:
2020-10-14 19:45:43.546 ERROR : tuya-adapter: { Error: Cannot find module 'p-queue'
2020-10-14 19:45:43.550 ERROR : tuya-adapter: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
2020-10-14 19:45:43.554 ERROR : tuya-adapter: at Function.Module._load (internal/modules/cjs/loader.js:562:25)
2020-10-14 19:45:43.558 ERROR : tuya-adapter: at Module.require (internal/modules/cjs/loader.js:692:17)
2020-10-14 19:45:43.563 ERROR : tuya-adapter: at require (internal/modules/cjs/helpers.js:25:18)
2020-10-14 19:45:43.568 ERROR : tuya-adapter: at Object. (/home/pi/.mozilla-iot/addons/tuya-adapter/node_modules/tuyapi/index.js:7:27)
2020-10-14 19:45:43.572 ERROR : tuya-adapter: at Module._compile (internal/modules/cjs/loader.js:778:30)
2020-10-14 19:45:43.582 ERROR : tuya-adapter: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
2020-10-14 19:45:43.587 ERROR : tuya-adapter: at Module.load (internal/modules/cjs/loader.js:653:32)
2020-10-14 19:45:43.592 ERROR : tuya-adapter: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2020-10-14 19:45:43.595 ERROR : tuya-adapter: at Function.Module._load (internal/modules/cjs/loader.js:585:3) code: 'MODULE_NOT_FOUND' }
Setting up a new tuya device is pretty painful right now: You need to register for a developer account at tuya in order to get an API key, which you then need to obtain the id and key value of your device using a CLI, which you then have to copy-and-paste into the add-on settings.
Ideally, the add-on should be able to search for tuya devices through the default pairing interface of the gateway. Libs for searching for tuya devices do already exist, e.g. tuya-cli or TinyTuya. This could solve the difficulty of having to use CLI, but it would still require to register for a dev account at tuya, since these tools require an API key. This could of course be solved by delivering the add-on together with an API key, but I am not so sure whether we are allowed to do this.
Any comments appreciated.
Please post your colour lights' dps layout with an explanation of the functionality of the channels here in case the default one does not work. You can change the device type to nothing (empty) to play around with the different dps channels and determine their functionality.
Added Jackyled plug with two sockets and night light. When configured as 3-gang switch, night light is on/off. When configured as thing, night light has brightness 0-255
When a device gets disconnected the only way to get it back seems to be to restart the adapter? Not even pairing manages to get them connected again.
I'm moving add-on packages back out of S3 and I figured out the tarball was missing from your release tag for some reason.
https://s3-us-west-2.amazonaws.com/mozilla-gateway-addons/tuya-adapter-0.2.1.tgz
I installed the addon and am receiving this error as a toast when leaving the addons page in the gateway webapp.
Stack track from systemctl:
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.920 ERROR : tuya-adapter: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.925 ERROR : tuya-adapter: at Function.Module._load (internal/modules/cjs/loader.js:562:25)
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.929 ERROR : tuya-adapter: at Module.require (internal/modules/cjs/loader.js:692:17)
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.932 ERROR : tuya-adapter: at require (internal/modules/cjs/helpers.js:25:18)
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.934 ERROR : tuya-adapter: at Object.<anonymous> (/home/pi/.mozilla-iot/addons/tuya-adapter/node_modules/tuyapi/index.js:7:27)
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.936 ERROR : tuya-adapter: at Module._compile (internal/modules/cjs/loader.js:778:30)
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.939 ERROR : tuya-adapter: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.941 ERROR : tuya-adapter: at Module.load (internal/modules/cjs/loader.js:653:32)
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.943 ERROR : tuya-adapter: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
Oct 17 13:16:55 gateway run-app.sh[24723]: 2020-10-17 13:16:55.946 ERROR : tuya-adapter: at Function.Module._load (internal/modules/cjs/loader.js:585:3) code: 'MODULE_NOT_FOUND' }
Addon version: 0.2.2
Gateway version (from package.json, dont know how to find it in the web app) 0.12.0
Hello there,
thank you for creating and sharing this add on. i have the following questions please:
i have many tuya compatible devices and would like to start adding those to the list..
for example a camera, vacuum robot, plug with power statistics and so on...
cheers,
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.