Support for Aqara LED Light Bulb - ZNLPD12LM

I am using the standard Webthings 1.0 gateway on a Raspberry Pi 4 with ConBee II (zigbee) stick and, so far, all my Aqara “things” are correctly detected - except the LED Light Bulb which is detected as a read-only “occupancy” device. The Zigbee adapter is able to detect the MAC address of the device, but not the properties.

The same device is correctly detected by HomeAssistant (on RPi) and by the DeCONZ native app on Windows 10. Reading through the postings on this forum, I can see that Aqara are renowned for not being fully Zigbee compliant, however, I have not seen an discussion on the LED Bulb.

Browsing through the .webthings\addons\zigbee-adapter\lib folder, I can see that there are several “.js” files that appear to contain configurations of some devices. In particular, “zb-xiaomi.js” appears to be a special configuration file for Aqara/LUMI devices. However, the ZNLPD12LM is not included. I am more than happy to have a go at updating this file to add this device, but would like some guidance and indication of how best to go about getting this correct. I can use the existing entries as examples, but that could be very hit and miss and there is no other example for a dimmable light bulb that I can use as a template. I have enabled basic debug on the zigbee adapter but don’t know what to look for in the logs that would help me make the correct configuration.

If I do get this working, I will be more than happy to provide the configuration for inclusion in a future update or just as a download for others who may have this device.

Happy to report that I can get the Aqara LED dimmable light bulb to turn on and off (like a switch), having added the following code to zb-xiaomi.js

'lumi.light.aqcn02': {
	// ZNLPD12LM
    name: 'Aqara LED light bulb',
    '@type': ['OnOffSwitch'],
    powerSource: zb_constants_1.POWERSOURCE.BATTERY,
    activeEndpoints: {
        1: {
            profileId: zb_constants_1.PROFILE_ID.ZHA_HEX,
            inputClusters: [
				zb_constants_1.CLUSTER_ID.GENBASIC_HEX,
				zb_constants_1.CLUSTER_ID.GENONOFF_HEX
			],
            outputClusters: [],
        },
    },
    properties: {
        switch: {
            descr: {
                '@type': 'OnOffProperty',
                label: 'On/Off',
                type: 'boolean',
            },
            profileId: zb_constants_1.PROFILE_ID.ZHA,
            endpoint: 1,
            clusterId: zb_constants_1.CLUSTER_ID.GENONOFF,
            attr: 'onOff',
            setAttrFromValue: 'setOnOffValue',
            parseValueFromAttr: 'parseOnOffAttr',
        },
},
},

Next challenge is to get the “dimmable” and “colour temperature” properties to work - so looking for another example of how to code that.

So finally got things to work as I had hoped it would happen “out of the box” - Ha!

For others coming afterwards, the specific challenges I had included:

  • realizing that not all required constants have been defined and that some values have to be set directly (e.g. the cluster and attribute Ids for “color temperature”;
  • knowing I needed to add “setAttrFromValue” to allow write back to the device, and then knowing what values to set;
  • getting the right combination of “minimum” and “maximum” values - which do not correspond to the documentation!
  • knowing what value to set for “parseValueFromAttr” - again a bit hit and miss until things worked out.

In getting this to work, the most useful tools for debugging were:

  • deCONZ Windows 10 application - that exposes all clusters & attributes and allows extensive testing;
  • turning on all debugging in the zigbee adapter - and wading through the logs to find bits and pieces - I found it useful to reboot from time to time, if only to get my bearings in the log files;
  • having a SAMBA share set up to R-Pi “gateway” folder - just to make it easier to access and update files;
  • using Firefox debugging mode to examine the data sent to and from the browser app to the gateway - the JSON packages are exposed in the “request” and “response” data;
  • Insomnia REST API app on Windows 10, to GET and PUT values to the device - test with a device that is working first to get the syntax correct, then try with your test device;
  • patience, patience, and even more patience as, between each test, you have to remove the device, make your changes, disable & re-enable the zigbee adapter, the add the device again and see if it any better, then repeat many times.

I hope this will be useful to someone else. If anyone knows where all the attributes and other constants are documented, it would be very useful to indicate this and make a reference to it in the various files.

Here is the display with the “square” theme activated.

And here is the code I inserted in zb-xiaomi.js

'lumi.light.aqcn02': {   // from deCONZ app
	// ZNLPD12LM - Aqara LED dimmable light bulb
	// www.zigbee2mqtt.io/devices/ZNLDP12LM.html
    name: 'light',
	description: 'Aqara LED light bulb',
    '@type': ['Light'],
    powerSource: zb_constants_1.POWERSOURCE.MAINS_SINGLE_PHASE,
    activeEndpoints: {
        1: {
      profileId: zb_constants_1.PROFILE_ID.ZHA,
            inputClusters: [
				zb_constants_1.CLUSTER_ID.GENBASIC_HEX,
				zb_constants_1.CLUSTER_ID.GENONOFF_HEX,
				zb_constants_1.CLUSTER_ID.GENLEVELCTRL_HEX,
				"0300",  // Color control, from deCONZ app
			],
            outputClusters: [
			],
		},
    }, 
    properties: {
        state: {
            descr: {
                '@type': 'OnOffProperty',
                label: 'On/Off',
                type: 'boolean',
            },
            profileId: zb_constants_1.PROFILE_ID.ZHA,
            endpoint: 1,
            clusterId: zb_constants_1.CLUSTER_ID.GENONOFF,
            attr: 'onOff',
            setAttrFromValue: 'setOnOffValue',
            parseValueFromAttr: 'parseOnOffAttr',
        },
        level: {
            descr: {
                '@type': 'BrightnessProperty',
                label: 'Brightness',
                type: 'number',
				minimum: 0,
				maximum: 100,
            },
            profileId: zb_constants_1.PROFILE_ID.ZHA,
            endpoint: 1,
            clusterId: zb_constants_1.CLUSTER_ID.GENLEVELCTRL,
            attr: 'currentLevel',
			value: 0,
            setAttrFromValue: 'setLevelValue',
            parseValueFromAttr: 'parseLevelAttr',
        },
        color_temp: {
            descr: {
                '@type': 'ColorTemperatureProperty',
                label: 'Color Temperature',
                type: 'number',
				minimum: 2200,		// 454 mireds
				maximum: 6500,		// 153 mireds
            },
            profileId: zb_constants_1.PROFILE_ID.ZHA,
            endpoint: 1,
            clusterId: 0x0300,      // from deCONZ app
            attr: '',
            attrId: 0x0007,       // from deCONZ app
            value: 0,
			setAttrFromValue: 'setColorTemperatureValue',  // guesswork
            parseValueFromAttr: 'parseColorTemperatureAttr',  // guesswork
        },
	},
},

enjoy!

Found some useful documentation …