zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

[External Converter]: lumi.light.agl002 from Aqara

Open lravelo opened this issue 11 months ago • 4 comments

Link

https://www.aqara.com/en/product/led-bulb-t2/

Database entry

{"id":17,"type":"Router","ieeeAddr":"0x54ef44100119e4b1","nwkAddr":38678,"manufId":4447,"manufName":"Aqara","powerSource":"DC Source","modelId":"lumi.light.agl002","epList":[1,21],"endpoints":{"1":{"profId":260,"epId":1,"devId":258,"inClusterList":[5,4,3,0,768,8,6,2820,1794,64704],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"61441":2,"modelId":"lumi.light.agl002","appVersion":27,"zclVersion":3}},"lightingColorCtrl":{"attributes":{"245":9901780,"colorCapabilities":16,"colorTempPhysicalMin":153,"colorTempPhysicalMax":370,"colorTemperature":370,"colorMode":2}},"genOnOff":{"attributes":{"245":9901809,"onOff":0}},"manuSpecificLumi":{"attributes":{"128":{"type":"Buffer","data":[1,18,0,177,228,25,1,16,68,239,84,22,151,0,0,0,0,1,4,0]},"223":{"type":"Buffer","data":[19,33,0,0,20,33,0,0,22,33,0,0,23,33,0,0,12,33,59,0,24,33,206,14]},"229":{"type":"Buffer","data":[6,0,6,0,0,4,99,88,0,37,42,243,22,37,78,173,30,37,69,165,71,37,78,171,190,37,70]},"230":2,"247":{"type":"Buffer","data":[3,40,27,5,33,20,0,8,33,27,1,9,33,0,6,10,33,0,0,11,32,0,12,32,10,160,32,1,154,32,0,100,32,0,101,32,254,102,33,114,1,106,35,140,10,100,25,105,32,0,113,32,3]},"1301":100,"1302":100,"1320":0.800000011920929,"1324":50,"65522":{"type":"Buffer","data":[170,117,19,132,77,253,7,65,0,15,12,35,1,6,0,6,10,35,8,0,12,100,11,32,4]}}},"genLevelCtrl":{"attributes":{"245":9901611,"onTransitionTime":15,"offTransitionTime":15,"currentLevel":254}}},"binds":[],"configuredReportings":[],"meta":{}},"21":{"profId":260,"epId":21,"devId":0,"inClusterList":[12],"outClusterList":[],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":27,"stackVersion":27,"hwVersion":1,"dateCode":"20250113","zclVersion":3,"interviewCompleted":true,"interviewState":"SUCCESSFUL","meta":{"configured":332242049},"lastSeen":1765927870087}

Zigbee2MQTT version

2.7.1 (unknown)

External converter

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 e = exposes.presets;

const modernExtend = require('zigbee-herdsman-converters/lib/modernExtend');
const { lumiModernExtend, fromZigbee, manufacturerCode } = require('zigbee-herdsman-converters/lib/lumi');

const { DefinitionWithExtend } = require('zigbee-herdsman-converters/lib/types');

const lumiTransitionCurve = () => 
    modernExtend.numeric({
        name: 'transition_curve_curvature',
        label: 'Transition Curve Curvature',
        cluster: 'manuSpecificLumi',
        attribute: {ID: 0x0528, type: 0x39},
        description: 'Range 0.2>x>1: first fast then slow, 1: linear, 1>x>6: first slow then fast',
        entityCategory: 'config',
        zigbeeCommandOptions: {manufacturerCode},
        valueMin: 0.2,
        valueMax: 6,
        valueStep: 0.01,
    });

const lumiTransitionBrightness = () => 
    modernExtend.numeric({
        name: 'transition_initial_brightness',
        label: 'Initial Brightness',
        cluster: 'manuSpecificLumi',
        attribute: {ID: 0x052c, type: 0x20},
        description: 'After turning on the light, the light will brighten from the preset brightness',
        entityCategory: 'config',
        zigbeeCommandOptions: {manufacturerCode},
        unit: '%',
        valueMin: 0,
        valueMax: 50,
        valueStep: 1,
    });


const lumiLevelConfig = () => {
    let levelConfig = new exposes.Composite('level_config', 'level_config', exposes.access.ALL);
    levelConfig = levelConfig.withFeature(
        new exposes.Numeric('on_transition_time', exposes.access.ALL)
            .withLabel('ON transition time')
            .withDescription(
                'Represents the time taken to move the current level from the minimum level to the maximum level when an On command is received',
            )
            .withUnit('1/10th second')
            .withValueMax(600)
            .withValueStep(5),
    );
    levelConfig = levelConfig.withFeature(
        new exposes.Numeric('off_transition_time', exposes.access.ALL)
            .withLabel('OFF transition time')
            .withDescription(
                'Represents the time taken to move the current level from the maximum level to the minimum level when an Off command is received',
            )
            .withUnit('1/10th second')
            .withValueMax(600)
            .withValueStep(5),
    );
    levelConfig = levelConfig.withDescription('Configure genLevelCtrl');
    
    return levelConfig;
}

const lumiDimmingRangeMinimum = () => 
    modernExtend.numeric({
        name: 'dimming_range_minimum',
        label: 'Dimming Range Minimum',
        cluster: 'manuSpecificLumi',
        attribute: {ID: 0x0515, type: 0x20},
        description: 'Minimum Allowed Dimming Value (brightness is scaled between min and max',
        entityCategory: 'config',
        zigbeeCommandOptions: {manufacturerCode},
        unit: '%',
        valueMin: 0,
        valueMax: 100,
        valueStep: 1,
    });
    
const lumiDimmingRangeMaximum = () => 
    modernExtend.numeric({
        name: 'dimming_range_maximum',
        label: 'Dimming Range Maximum',
        cluster: 'manuSpecificLumi',
        attribute: {ID: 0x0516, type: 0x20},
        description: 'Maximum Allowed Dimming Value (brightness is scaled between min and max',
        entityCategory: 'config',
        zigbeeCommandOptions: {manufacturerCode},
        unit: '%',
        valueMin: 0,
        valueMax: 100,
        valueStep: 1,
    });
    
const lumiLightT2 = (rgb) => {
    const lightArgs = {
        effect: false, 
        powerOnBehavior: false, 
        powerOutageCount: true, 
        deviceTemperature: true, 
        colorTemp: {
            startup: false, 
            range: [153, 370],
        }
    };

    if (rgb) {
        lightArgs.color = true;
        lightArgs.colorTemp.range = [111, 500];
    }

    const lightT2 = modernExtend.light(lightArgs);

    lightT2.exposes.forEach((e) => e.addFeature(lumiLevelConfig()));
    lightT2.toZigbee.push(tz.level_config);

    lightT2.fromZigbee.push(
        // clusters that do not seem to be implemented
        fz.ignore_analog_report,
        fz.ignore_electrical_measurement,
        fz.ignore_metering,

        fromZigbee.lumi_specific,
    );

    lightT2.exposes.push(e.power_outage_count());
    lightT2.exposes.push(e.device_temperature());

    const powerOn = lumiModernExtend.lumiPowerOnBehavior({lookup: {off: 0, on: 1, reverse: 2, previous: 3}});
    lightT2.toZigbee.push(...powerOn.toZigbee);
    lightT2.exposes.push(...powerOn.exposes);

    const transitionCurve = lumiTransitionCurve();
    lightT2.toZigbee.push(...transitionCurve.toZigbee);
    lightT2.exposes.push(...transitionCurve.exposes);

    const transitionBrightness = lumiTransitionBrightness();
    lightT2.toZigbee.push(...transitionBrightness.toZigbee);
    lightT2.exposes.push(...transitionBrightness.exposes);

    const dimmingMin = lumiDimmingRangeMinimum();
    lightT2.toZigbee.push(...dimmingMin.toZigbee);
    lightT2.exposes.push(...dimmingMin.exposes);

    const dimmingMax = lumiDimmingRangeMaximum();
    lightT2.toZigbee.push(...dimmingMax.toZigbee);
    lightT2.exposes.push(...dimmingMax.exposes);

    return lightT2;
}

const definitions = [
    {
        zigbeeModel: ['lumi.light.agl001'],
        model: 'LED Bulb T2 (E26, CCT RGB) [NA]',
        vendor: 'Aqara',
        description: 'LED Bulb with RGB and CCT adjustment',
        extend: [ lumiLightT2(true) ],
    },
    {
        zigbeeModel: ['lumi.light.agl002'],
        model: 'LED Bulb T2 (E26, CCT) [NA]',
        vendor: 'Aqara',
        description: 'LED Bulb with CCT adjustment',
        extend: [ lumiLightT2(false) ],
    },
    {
        zigbeeModel: ['lumi.light.agl003'],
        model: 'LED Bulb T2 (E27, RGB CCT) [EU]',
        vendor: 'Aqara',
        description: 'LED Bulb with RGB and CCT adjustment',
        extend: [ lumiLightT2(true) ],
    },
    {
        zigbeeModel: ['lumi.light.agl004'],
        model: 'LED Bulb T2 (E27, CCT) [EU]',
        vendor: 'Aqara',
        description: 'LED Bulb with CCT adjustment',
        extend: [ lumiLightT2(false) ],
    },
    {
        zigbeeModel: ['lumi.light.agl005'],
        model: 'LED Bulb T2 (GU10, CCT RGB) [EU]',
        vendor: 'Aqara',
        description: 'LED Bulb with RGB and CCT adjustment',
        extend: [ lumiLightT2(true) ],
    },
    {
        zigbeeModel: ['lumi.light.agl006'],
        model: 'LED Bulb T2 (GU10, CCT) [EU]',
        vendor: 'Aqara',
        description: 'LED Bulb with and CCT adjustment',
        extend: [ lumiLightT2(false) ],
    },
    {
        zigbeeModel: ['lumi.light.agl007'],
        model: 'LED Bulb T2 (GU10, CCT RGB) [NA]',
        vendor: 'Aqara',
        description: 'LED Bulb with RGB and CCT adjustment',
        extend: [ lumiLightT2(true) ],
    },
    {
        zigbeeModel: ['lumi.light.agl008'],
        model: 'LED Bulb T2 (GU10, CCT) [NA]',
        vendor: 'Aqara',
        description: 'LED Bulb with CCT adjustment',
        extend: [ lumiLightT2(false) ],
    },
];

module.exports = definitions;

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

Works: state, brightness, color temp, transition time

Notes

software_build_id: undefined date_code: 20250113 endpoints:

{"1":{"clusters":{"input":["genScenes","genGroups","genIdentify","genBasic","lightingColorCtrl","genLevelCtrl","genOnOff","haElectricalMeasurement","seMetering","manuSpecificLumi"],"output":["genOta","genTime"]}},"21":{"clusters":{"input":["genAnalogInput"],"output":[]}}}

lravelo avatar Dec 16 '25 23:12 lravelo

@lravelo thanks, I'm currently using my own personal converter. I'll try this out and confirm if it works well.

doubleukay avatar Dec 17 '25 08:12 doubleukay

There's already support for these functions in https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/lib/lumi.ts

It'll probably just need the extra device definitions added for lumi.light.agl007 and lumi.light.agl008

absent42 avatar Dec 17 '25 11:12 absent42

@absent42 added!

Changes will be available in the dev branch in a few hours from now and in the next release which is every 1st of the month.

Koenkk avatar Dec 18 '25 21:12 Koenkk

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

github-actions[bot] avatar Feb 17 '26 00:02 github-actions[bot]