homebridge-tuya-colorlight

Tuya color LED light control for homebridge. Based on codetheweb's Tuya API and tuya outlet plugins.

Usage no npm install needed!

<script type="module">
  import homebridgeTuyaColorlight from 'https://cdn.skypack.dev/homebridge-tuya-colorlight';
</script>

README

Tuya LED Color Light Support for Homebridge

Example config.json for LED Color Light Controllers that support RGB or RGBWW:

"accessories": [
    {
        "accessory": "TuyaColorLight",
        "name": "Fountain Color Light",
        "ip": "192.168.104.31",
        "devId": "XXXXXXXXXX",
        "localKey": "XXXXXXXXXXXXXX",
        "gwId":"XXXXXXXXXXXXXXXX",
        "productKey":"IXXXXXXXXXW",
        "apiMinTimeout" : 100,
        "apiMaxTimeout" : 1000,
        "apiRetries": 1,
        "apiDebug" : false,
        "refreshInterval" : 120,
        "debugPrefix" : "~~~!~~~ ",
        "debug" : false,
        "deviceEnabled" : true
    }
]

Example config.json for Tuya based multiple LED Color Lights:

"accessories": [
    {
        "accessory": "TuyaColorLight",
        "name": "Fountain Color Light",
        "ip": "192.168.104.31",
        "productId":"IXXXXXXXXXW",
        "devId": "XXXXXXXXXX",
        "localKey": "XXXXXXXXXXXXXX",
        "apiMinTimeout" : 100,
        "apiMaxTimeout" : 1000,
        "apiRetries": 1,
        "apiDebug" : false,
        "refreshInterval" : 120,
        "debugPrefix" : "~~~!~~~ ",
        "debug" : false,
        "deviceEnabled" : true
    },

    {
        "accessory": "TuyaColorLight",
        "name": "Tree Color Light",
        "ip": "192.168.104.32",
        "productId":"IXXXXXXXXXW",
        "devId": "XXXXXXXXXX",
        "localKey": "XXXXXXXXXXXXXX",
        "apiMinTimeout" : 100,
        "apiMaxTimeout" : 1000,
        "apiRetries": 1,
        "apiDebug" : false,
        "refreshInterval" : 120,
        "debugPrefix" : "~~~!~~~ ",
        "debug" : false,
        "deviceEnabled" : true
    }
]

This was originally derived from the homebridge-tuya-outlet plugin and modified to utilize the 'dps' in the Tuya api for managing multiple device function points.

Carefully read and review the procedures to obtain the Tuya api device ID (hint: it has the MAC address in it) and the localKey. It's quite a procedure, but it's easy once learned: Tuya API Sniffing Procedures

This plugin requires a modified version of the tuyapi that I extended found here: homebridge-tuyapi-extended

See tuyapi for original inspiration.

Tested on the following LED lights (Non affiliated links following:)

This plugin should work with any TUYA based LED Color light that can be added to the Tuya, or Smart Life apps. A popular brand I've found is LOHAS Lights or on Amazon: LOHAS Lights on Amazon

Helpful things to note:

  1. I found it is best to assign a static IP address through DHCP on my router to each device. Add that IP address to the config file in homebridge when setting up your devices. So each unique physical device should have it's own static ip. Even though this is not required in the original tuyapi and homebridge-tuya-outlet, I found that there is a potential hang in homebridge while waiting on the IP address to be obtained. By adding it static, it reduced the wait time and lag when accessing these devices.

  2. At this time, until the homebridge-tuyapi-extended is updated, if you add a device and it is in your config file, but unplugged, this may cause your homebridge to crash or hang. This is being worked out, and a reason for the fork of the original tuyapi.