zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Tuya SPI LED controller

Open Ashwoodie opened this issue 2 years ago • 86 comments

Link

https://www.iskydance.com/index.php?c=product_show&a=index&id=2433

Database entry

{"id":4,"type":"Router","ieeeAddr":"0xa4c138cf01f4c3b4","nwkAddr":21421,"manufId":4417,"manufName":"_TZE204_8fffc3kb>

Zigbee2MQTT version

1.40.1

Comments

Hi. I’ve used a few Tuya devices with zigbee2MQTT and I naively thought that this device would be compatible. As it turns out I seem to be struggling a little bit and hoped that someone would lend a hand. The device is the Tuya WZ-SPI LED controller. Anyone with any experience with this device? Many thanks in advance.

External definition

const definition = {
    zigbeeModel: ['TS0601'],
    model: 'TS0601',
    vendor: '_TZE204_8fffc3kb',
    description: 'Automatically generated definition',
    extend: [],
    meta: {},
};

module.exports = definition;

What does/doesn't work with the external definition?

The devices page still stated unsupported and its not showing on the nodered MQTT device list.

Ashwoodie avatar Sep 16 '24 19:09 Ashwoodie

Hi all. Does anyone have any suggestions (ie. 'support new tuya devices') or is it just wise waiting for it to be integrated into an update.?

Ashwoodie avatar Sep 17 '24 17:09 Ashwoodie

Is this any help?

{ "result": { "properties": [ { "code": "switch_led", "custom_name": "", "dp_id": 1, "time": 1728210802688, "type": "bool", "value": true }, { "code": "work_mode", "custom_name": "", "dp_id": 2, "time": 1728210827829, "type": "enum", "value": "white" }, { "code": "bright_value", "custom_name": "", "dp_id": 3, "time": 1728210802554, "type": "value", "value": 255 }, { "code": "temp_value", "custom_name": "", "dp_id": 4, "time": 1728210801596, "type": "value", "value": 0 }, { "code": "colour_data", "custom_name": "", "dp_id": 5, "time": 1728210801596, "type": "string", "value": "" }, { "code": "countdown", "custom_name": "", "dp_id": 7, "time": 1728210801596, "type": "value", "value": 0 }, { "code": "music_data", "custom_name": "", "dp_id": 8, "time": 1728210801596, "type": "string", "value": "" }, { "code": "light_length", "custom_name": "", "dp_id": 46, "time": 1728210802343, "type": "value", "value": 1000 }, { "code": "light_pixel", "custom_name": "", "dp_id": 47, "time": 1728210802370, "type": "value", "value": 1000 }, { "code": "dreamlight_scene_mode", "custom_name": "", "dp_id": 51, "time": 1728210801596, "type": "raw" }, { "code": "dreamlightmic_music_data", "custom_name": "", "dp_id": 52, "time": 1728210801596, "type": "raw" }, { "code": "lightpixel_number_set", "custom_name": "", "dp_id": 53, "time": 1728210824718, "type": "value", "value": 1000 }, { "code": "paint_colour_data", "custom_name": "", "dp_id": 61, "time": 1728210801596, "type": "raw" }, { "code": "chip_type_data", "custom_name": "", "dp_id": 101, "time": 1728210802754, "type": "enum", "value": "TM1809" }, { "code": "rgb_order_data", "custom_name": "", "dp_id": 102, "time": 1728210802798, "type": "enum", "value": "BRG" } ] }, "success": true, "t": 1728211934991, "tid": "0c4bdca783d111efa55d025acf19914b"

GPSPerth avatar Oct 06 '24 10:10 GPSPerth

Hi, I understand that this device is planned to be added soon. Do you know when it will be integrated? I can't find any other device to control an LED strip using the SPI protocol for WS2812B LEDs. I'm wondering if I should consider returning it and switching to using WLED home assistant based on ESP32.

chrishue avatar Oct 12 '24 20:10 chrishue

hi, We can't know the dates for the updates?

dav972 avatar Oct 23 '24 18:10 dav972

Any chance we can get an example config for this device till it's integrated?

B4Bcoin avatar Nov 03 '24 16:11 B4Bcoin

+1

diahellfire avatar Nov 17 '24 14:11 diahellfire

waiting for the full working config. Until then I can do basic actions (on/off, brightness) via a local config file. Feel free to further improve...

const fz = require('zigbee-herdsman-converters/converters/fromZigbee'); const tz = require('zigbee-herdsman-converters/converters/toZigbee'); const exposes = require('zigbee-herdsman-converters/lib/exposes'); const reporting = require('zigbee-herdsman-converters/lib/reporting'); const ota = require('zigbee-herdsman-converters/lib/ota'); const utils = require('zigbee-herdsman-converters/lib/utils'); const globalStore = require('zigbee-herdsman-converters/lib/store'); const modernExtend = require('zigbee-herdsman-converters/lib/modernExtend'); const e = exposes.presets; const ea = exposes.access; const tuya = require('zigbee-herdsman-converters/lib/tuya'); const {light} = require('zigbee-herdsman-converters/lib/modernExtend');

const definition = { fingerprint: tuya.fingerprint('TS0601', ['_TZB210_3zfp8mki', '_TZB210_gj0ccsar', '_TZE204_8fffc3kb']), model: 'TS0601', vendor: 'Tuya', description: 'Zigbee RGB+CCT light', fromZigbee: [tuya.fz.datapoints], toZigbee: [tuya.tz.datapoints], // fromZigbee: [], // toZigbee: [tz.light], onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime' configure: tuya.configureMagicPacket, whiteLabel: [ tuya.whitelabel('Skydance', 'WZ5_dim_2', 'Zigbee & RF 5 in 1 LED controller (DIM mode)', ['_TZB210_3zfp8mki']), tuya.whitelabel('Skydance', 'WZ-SPI', 'Zigbee & RF 5 in 1 LED controller (DIM mode)', ['_TZE204_8fffc3kb']), tuya.whitelabel('QA', 'QADZC5', '5 in 1 LED controller', ['_TZB210_gj0ccsar']), ],

    exposes: [e.light(),
    // Here you should put all functionality that your device exposes
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'state', tuya.valueConverter.onOff], // <- mapped the datapoint
            [3, 'brightness', tuya.valueConverter.scale0_254to0_1000], // <- mapped the datapoint
            [4, 'color_temp', tuya.valueConverter.scale250_454to0_1000], // <- mapped the datapoint
            [14, 'power_on_behavior', tuya.valueConverter.powerOnBehaviorEnum],
    ],
    },

    extend: [
        light({colorTemp: {range: [153, 500]}, color: {modes: ['hs'], applyRedFix: true, enhancedHue: false}}),
    ],
    configure: async (device, coordinatorEndpoint) => {
        device.getEndpoint(1).saveClusterAttributeKeyValue('lightingColorCtrl', {colorCapabilities: 29});
    },

// }, // meta: { // // All datapoints go in here // tuyaDatapoints: [], // }, // extend: [ // A preferred new way of extending functionality. // ], };

module.exports = definition;

blackberry2nd avatar Nov 27 '24 21:11 blackberry2nd

I'm not good at mqtt, can you give us the steps to follow to enter the code?

dav972 avatar Nov 27 '24 22:11 dav972

I created a file to put the configuration (I don't know if it's the right method) and there are still errors

dav972 avatar Nov 28 '24 01:11 dav972

waiting for the full working config. Until then I can do basic actions (on/off, brightness) via a local config file. Feel free to further improve...

const fz = require('zigbee-herdsman-converters/converters/fromZigbee'); const tz = require('zigbee-herdsman-converters/converters/toZigbee'); const exposes = require('zigbee-herdsman-converters/lib/exposes'); const reporting = require('zigbee-herdsman-converters/lib/reporting'); const ota = require('zigbee-herdsman-converters/lib/ota'); const utils = require('zigbee-herdsman-converters/lib/utils'); const globalStore = require('zigbee-herdsman-converters/lib/store'); const modernExtend = require('zigbee-herdsman-converters/lib/modernExtend'); const e = exposes.presets; const ea = exposes.access; const tuya = require('zigbee-herdsman-converters/lib/tuya'); const {light} = require('zigbee-herdsman-converters/lib/modernExtend');

const definition = { fingerprint: tuya.fingerprint('TS0601', ['_TZB210_3zfp8mki', '_TZB210_gj0ccsar', '_TZE204_8fffc3kb']), model: 'TS0601', vendor: 'Tuya', description: 'Zigbee RGB+CCT light', fromZigbee: [tuya.fz.datapoints], toZigbee: [tuya.tz.datapoints], // fromZigbee: [], // toZigbee: [tz.light], onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime' configure: tuya.configureMagicPacket, whiteLabel: [ tuya.whitelabel('Skydance', 'WZ5_dim_2', 'Zigbee & RF 5 in 1 LED controller (DIM mode)', ['_TZB210_3zfp8mki']), tuya.whitelabel('Skydance', 'WZ-SPI', 'Zigbee & RF 5 in 1 LED controller (DIM mode)', ['_TZE204_8fffc3kb']), tuya.whitelabel('QA', 'QADZC5', '5 in 1 LED controller', ['_TZB210_gj0ccsar']), ],

    exposes: [e.light(),
    // Here you should put all functionality that your device exposes
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'state', tuya.valueConverter.onOff], // <- mapped the datapoint
            [3, 'brightness', tuya.valueConverter.scale0_254to0_1000], // <- mapped the datapoint
            [4, 'color_temp', tuya.valueConverter.scale250_454to0_1000], // <- mapped the datapoint
            [14, 'power_on_behavior', tuya.valueConverter.powerOnBehaviorEnum],
    ],
    },

    extend: [
        light({colorTemp: {range: [153, 500]}, color: {modes: ['hs'], applyRedFix: true, enhancedHue: false}}),
    ],
    configure: async (device, coordinatorEndpoint) => {
        device.getEndpoint(1).saveClusterAttributeKeyValue('lightingColorCtrl', {colorCapabilities: 29});
    },

// }, // meta: { // // All datapoints go in here // tuyaDatapoints: [], // }, // extend: [ // A preferred new way of extending functionality. // ], };

module.exports = definition;

Thank you I'm not so good, where I have to put this "code" ?

abertolin avatar Nov 28 '24 08:11 abertolin

Create local file: in home assistant folder: /homeassistant/zigbee2mqtt/wz-spi.js (or whatever filename you prefer). put the line items as mentioned above in that file.

In the same folder there is a configuration.yaml file. Add to the end of the file:

external_converters:

  • wz-spi.js

Note: before wz-spi.js should be a '-' but I notice that it shows as a dot due to the markup Then restart zigbee2mqtt. Then the device should be regognized.

blackberry2nd avatar Nov 28 '24 21:11 blackberry2nd

Create local file: in home assistant folder: /homeassistant/zigbee2mqtt/wz-spi.js (or whatever filename you prefer). put the line items as mentioned above in that file.

In the same folder there is a configuration.yaml file. Add to the end of the file:

external_converters:

* wz-spi.js

Note: before wz-spi.js should be a '-' but I notice that it shows as a dot due to the markup Then restart zigbee2mqtt. Then the device should be regognized.

Thank you!

abertolin avatar Nov 29 '24 08:11 abertolin

Hi I tested your code, the on/off and brightness adjustment work very well On the other hand, the color adjustment does not work, it tells me: "'Error: No datapoint defined for 'color''"

wawan822 avatar Nov 30 '24 11:11 wawan822

Correct that does not work for me either..., thats why I mentioned basic :-) If anyone knows how to extend the code supporting more functionality that would be great. Or even better have the 'official' support from the zigbee2mqtt, so I can get rid of this local file again.

blackberry2nd avatar Nov 30 '24 11:11 blackberry2nd

dp_id: 102 rgb_order_data: RGB, RBG, GRB, GBR, BRG, BGR, RGBW, RBGW, GRBW, GBRW, BRGW, BGRW, WRGB, WRBG, WGRB, WGBR, WBRG, WBGR

dp_id: 101 chip_type_data: TM1803, TM1809, TM1829, TLS3001, GW6205, MBI6120, TM1814B, SK6812, UCS8904B, LPD6803, LPD8806, WS2801, P9813, SK9822, MBI6020, TM1914A, GS8206, UCS2904, SM16904, SM16825, SM16714, UCS5603, UCS2603, SM16714D, UCS7604, UCS7804

Values for chip select and color mode.

diahellfire avatar Nov 30 '24 13:11 diahellfire

Lightpixel Number Set (strip length) dp_id: 53 value from 1.00 to 78.70

diahellfire avatar Nov 30 '24 13:11 diahellfire

work_mode dp_id: 2 Values: colour, white, scene

diahellfire avatar Nov 30 '24 13:11 diahellfire

I can't get it to work on my side. Can you give me all the stuff to put in the new file and what to put in the configuration.yaml of ZigBee2mqtt

dav972 avatar Nov 30 '24 13:11 dav972

Put file to serve directory .../homeassistant/zigbee2mqtt/wz_spi.js

In Z2M - Open Settings page -> External Converters -> click "+", write "wz_spi.js", click Submit! Done!

2024-11-30 165550

I can't get it to work on my side. Can you give me all the stuff to put in the new file and what to put in the configuration.yaml of ZigBee2mqtt

diahellfire avatar Nov 30 '24 13:11 diahellfire

Ok thanks But I can't control the module 🤔 I did something wrong Screenshot_20241130_102304_io_homeassistant_companion_android_WebViewActivity

dav972 avatar Nov 30 '24 14:11 dav972