Adding new devices to Zigbee2MQTT

What if you have a Zigbee device which is not listed on supported devices?

The pairing process for the IKEA and Xiaomi devices went well. It was also easy with the Zemismart Zigbee RGB Downlight (review soon), but I was not able to read the state or control the device as the Zemismart Zigbee RGB Downlight was not on the list of the supported devices. I thought I would cover the procedure in case you get stuck on how to add new devices to Zigbee2MQTT.

Pairing new devices to Zigbee2MQTT

The pairing depends on the manufacturer’s instructions, so please refer to that to learn how to enter the correct pairing state via reset. While pairing IKEA and Aqara remotes lights and sensors is described well in the guide already, you don’t get many clues for other devices. Make sure your configuration.yaml file has permit_join: true.

Just hold the device close in the pairing mode until you see the following lines:

zigbee2mqtt:warn 6/7/2019, 12:26:07 PM Message without device!
 zigbee2mqtt:info 6/7/2019, 12:26:16 PM New device 'undefined' with address 0x00124b001c889570 connected!
 zigbee2mqtt:info 6/7/2019, 12:26:16 PM MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"device_connected","message":"0x00124b001c889570","meta":{}}'
 zigbee2mqtt:warn 6/7/2019, 12:26:16 PM Device with modelID 'undefined' is not supported.
 zigbee2mqtt:warn 6/7/2019, 12:26:16 PM Please see: https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html

This means your device is paired and you can open the configuration.yaml and name it. It will be listed as the last device on the list:

'0x00124b001c889570':
     friendly_name: ' 0x00124b001c889570'
     retain: false

change to:

 '0x00124b001c889570':
     friendly_name: 'spotlight'
     retain: false 

Save the file and restart your Zigbee2MQTT service or reboot the Raspberry Pi. At this point, you are ready to add the new device to the list.

Zigbee 3.0 Smart RGBW Downlight
Support NotEnoughTech
Buy Zigbee 3.0 Smart RGBW Downlight
Very bright RGB LED light with strong colours!

At this point, do yourself a favour and keep the device close to the cc2531. I got frustrated and I wanted to continue my work downstairs and I took the device outside of the Zigbee network without realising.

To control the new device I had to modify the node_modules/zigbee-shepherd-converters/devices.js file. Without this, I would not be able to send any commands. Open:

sudo nano /node_modules/zigbee-shepherd-converters/devices.js 

Then add the new device according to the template:

{
    zigbeeModel: ['lumi.sens'], // The model ID from: Device with modelID 'lumi.sens' is not supported.
    model: 'WSDCGQ01LM', // Vendor model number, look on the device for a model number
    vendor: 'Xiaomi', // Vendor of the device (only used for documentation and startup logging)
    description: 'MiJia temperature & humidity sensor ', // Description of the device, copy from vendor site. (only used for documentation and startup logging)
    supports: 'temperature and humidity', // Actions this device supports (only used for documentation)
    fromZigbee: [], // We will add this later
    toZigbee: [], // Should be empty, unless device can be controlled (e.g. lights, switches).
},

Pay closer attention to the: fromZigbee: [] & toZigbee: [] as these can be replaced with:

extend: generic.light_onoff_brightness_colortemp,

If you look at the top of the template file (at the top), you will see a couple of control templates stored under generic.xxxxx hue.xxxx and gledopto.xxxx. Check what control/and report capabilities your device comes with and add a single extend line instead.

 extend: generic.light_onoff_brightness_colortemp, 

is equal to:

fromZigbee: generic.light_onoff_brightness_colortemp.fromZigbee,
toZigbee: [tz.gledopto_light_onoff_brightness, tz.gledopto_light_colortemp, tz.ignore_transition, tz.light_alert,],

Since I know that my device supports toggle, dimming, and colour controls I have added the following config

{
    zigbeeModel: ['NUET56-DL27LX1.1'], 
    model: 'LXZB-12A', 
    vendor: 'Zemismart', 
    description: 'RGB LED Downlight', 
    supports: 'RGB, Dimming',
    extend: gledopto.light_onoff_brightness_colortemp_colorxy
},

I didn’t have to recalculate any values, but your case might be different. Zigbee2MQTT page mentioned that you might need to do this if your Zigbee protocol isn’t compatible. Since I had no device to test it on, I won’t be able to help you there.

Zigbee2MQTT control basics

Once your device is configured, we can add the MQTT nodes to control it. To read the status of your device add MQTT in node and debug with:

zigbee2mqtt/devicename

swap the appropriate values if you edited the Zigbee2MQTT topic and enter your device name. If you issue the following JSON:

{
     "state": ""
 }

To the zigbee2mqtt/devicename/getMQTT out node – you will receive status update looking like this:

 {"topic":"zigbee2mqtt/spotlight1","payload":"{\"state\":\"ON\",\"linkquality\":78,\"brightness\":254,\"color\":{\"x\":0.6173,\"y\":0.3694},\"color_temp\":155}","qos":0,"retain":false,"_msgid":"9de88d8c.894a5"}

If you want to control the Zigbee device, just send the JSON message:

{
     "state": "ON",
     "brightness": 255,
     "color_temp": 155,
     "color": {
         "hex": "#ea770b"
     }
 }

To zigbee2mqtt/devicename/set with the changes you want to make. You don’t have to pass all the data, only the JSON values you want to set.

Conclusion

The process isn’t as beginner-friendly as adding Xiaomi or IKEA devices, but with time, the list of supported devices will get bigger. Now you should know how to add and use new devices in Zigbee2MQTT. Soon I will show you cool control scenarios using various remote controllers. If you have any questions, feel free to ask it in this Reddit thread.

Support NotEnoughTech
A lot of time and effort goes into keeping NotEnoughTech alive! If my work helped you out, consider buying me a coffee or check out exclusive rewards available to Patreon supporters.
SHARE