zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

[New device support]: TuYa RGBW dimmer recognized as RGBCCT bulb

Open zagi988 opened this issue 8 months ago • 5 comments

Link

https://www.aliexpress.com/item/1005004630523125.html

Database entry

{"id":27,"type":"Router","ieeeAddr":"0xa4c138fe3dbb3d59","nwkAddr":6738,"manufId":4107,"manufName":"eWeLight","powerSource":"Mains (single phase)","modelId":"ZB-CL01","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":269,"inClusterList":[0,3,4,5,6,8,768,4096],"outClusterList":[],"clusters":{"genBasic":{"attributes":{"hwVersion":0,"zclVersion":3}},"lightingColorCtrl":{"attributes":{"colorCapabilities":25,"colorTempPhysicalMin":250,"colorTempPhysicalMax":454,"colorMode":2,"currentX":11272,"currentY":48955,"colorTemperature":454,"options":0}},"genOnOff":{"attributes":{"onOff":1}},"genLevelCtrl":{"attributes":{"currentLevel":254}}},"binds":[{"cluster":8,"type":"endpoint","deviceIeeeAddress":"0x00124b0024c7c695","endpointID":1},{"cluster":768,"type":"endpoint","deviceIeeeAddress":"0x00124b0024c7c695","endpointID":1}],"configuredReportings":[],"meta":{"onLevelSupported":false}}},"appVersion":3,"stackVersion":2,"hwVersion":0,"dateCode":"20211229","swBuildId":"2.0.1","zclVersion":3,"interviewCompleted":true,"meta":{"configured":2},"lastSeen":1698529121041,"defaultSendRequestWhen":"immediate"}

Comments

Tried to write a custom controller for it to not expose "color_temp" but to just have white as second option to RGB but failed because of lack of knowledge. The model that I have is "5 pin RGBW", so it doesn't have color temperature (2000-6000K) but only has RGB channels and a single white channel.

External converter

const extend = require('zigbee-herdsman-converters/lib/extend');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const types = require('zigbee-herdsman-converters/lib/types');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const libColor = require('zigbee-herdsman-converters/lib/color');
const utils = require('zigbee-herdsman-converters/lib/utils');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
    model: 'ZB-RGBW',
    fingerprint: [
        {
            modelID: 'ZB-CL01',
            manufacturerName: 'eWeLight'
        },
    ],
    vendor: 'Lonsonho',
    description: 'ZB RGBW dimmer (converted)',
    extend: tuya.extend.light_onoff_brightness_color(),
    exposes: [
        e.light_brightness_color(false)
         .setAccess('color_xy', ea.STATE_SET)
    ],
    toZigbee: utils.replaceInArray(
        tuya.extend.light_onoff_brightness_color().toZigbee,
        [tz.light_color],
        [{
            key: ['color'],
            convertSet: async (entity, key, value, meta) => {
                const color = libColor.Color.fromConverterArg(value);
                const enableWhite =
                    // Zigbee2MQTT frontend white value
                    (color.isXY() && (color.xy.x === 0.3125 || color.xy.y === 0.32894736842105265)) ||
                    // Home Assistant white color picker value
                    (color.isXY() && (color.xy.x === 0.323 || color.xy.y === 0.329));
    
                if (enableWhite) {
                    await entity.command('lightingColorCtrl', 'tuyaRgbMode', {enable: false});
                    const newState = {color_mode: 'color_temp'};
                    if (color.isXY()) {
                        newState.color = color.xy;
                    } else {
                        newState.color = color.rgb.gammaCorrected().toXY().rounded(4);
                    }
                    return {
                        state: libColor.syncColorState(newState, meta.state, entity, meta.options, meta.logger)
                    };
                } else {
                    return await tz.light_color.convertSet(entity, key, value, meta);
                }
            },
        }]
    ),
    meta: {applyRedFix: true},
};

module.exports = definition;

Supported color modes

color (rgb), white

Color temperature range

No response

zagi988 avatar Oct 28 '23 22:10 zagi988

It's more of a problem than new device support as more as I think of it. Had to emulate over Node-Red and template light to get it to have sense.

zagi988 avatar Oct 31 '23 18:10 zagi988

I have the bulbs for testing purposes if needed. The fingerprint is the same but the bulbs have firmware version 1.0.13/20201216. The fingerprint is otherwise identical unfortunately.

stonegray avatar Nov 02 '23 19:11 stonegray

Can anyone at least help me write a custom controller since the fingerprint is the same?

zagi988 avatar Nov 10 '23 13:11 zagi988

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days

github-actions[bot] avatar May 09 '24 00:05 github-actions[bot]

Can anyone at least help me write a custom controller since the fingerprint is the same?

See my workaround fix here: https://github.com/Koenkk/zigbee2mqtt/issues/21361#issuecomment-2105394183

dotWee avatar May 12 '24 16:05 dotWee