Coder Social home page Coder Social logo

tuya-adapter's People

Contributors

bewee avatar dependabot[bot] avatar freaktechnik avatar mrstegeman avatar nilsfed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tuya-adapter's Issues

flash_scene_[1-4] support

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

Tuya Thermostat

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 }

Only one Tuya switch?

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.

Smart Video Doorbell (Wi-Fi)

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?

Woox (Tuya compatible) devices

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:

  • Should I aim at a separate add-on for Woox devices, or an extension of the Tuya add-on
  • Do you have any suggestions about the way forward

Best regards,

Paul

Lumary Dimmer Switch Configuration

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}

Tuya Devices Disconnect

Devices disconnect and reconnect randomly. Increasing connection timeout only helps momentarily.

Feit Electric Devices

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!

Air conditioner

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?

Toggle action for devices with logical on/off

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 2 gang wall switch

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 } }

Devices disconnected

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' }

Simplify setup process

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.

Colour light bulb with different dps layout

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.

Dimmer for Jackyled plug

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

Devices disconnect and never come back

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.

Error: Plugin returns the error Cannot find module 'p-queue'

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

how to add new missing properties to a device?

Hello there,
thank you for creating and sharing this add on. i have the following questions please:

  1. can you please share links to docs or article on how to write a device file?
  2. where can one learn more on how to create compatible devices with the addon?

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,

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.