SOLVED: Z2MQTT problem: Error: Cannot find module 'zigbee-herdsman-converters/lib/extend'

Hi all,

I’m trying to add a converter to HA for a bulb that isn’t automatically supported. I’ve followed the instructions for this, and used the existing converter, but can’t get past the above error.

configuration for Zigbee2MQTT:

data_path: /config/zigbee2mqtt
external_converters:
  - lidl.js
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
serial:
  port: /dev/ttyUSB0

The lidl.js file is in the same folder as the config file in the config/Zigbee2MQTT folder. It’s taken from https://github.com/Koenkk/zigbee-herdsman-converters/blob/649b52cd558c1b29dcc794d0fded71e940f21446/devices/lidl.js, but there were some syntax errors reported and after a bit of digging I edited it down to just the relevant model and changed the relevant lines to:

const exposes = require('zigbee-herdsman-converters/lib/exposes');
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const e = exposes.presets;
const ea = exposes.access;
const tuya = require('../lib/tuya');

module.exports = [
    {
        fingerprint: [
            {modelID: 'TS0501A', manufacturerName: '_TZ3000_nosnx7im'},
            {modelID: 'TS0501A', manufacturerName: '_TZ3000_nbnmw9nc'}, // UK
        ],
        model: 'HG06462B',
        vendor: 'Lidl',
        description: 'Livarno Lux E27 A60 filament bulb',
        extend: extend.light_onoff_brightness({disableEffect: true}),
        meta: {turnsOffAtBrightness1: false},
    },
];

The TS0501A and TZ3000_nosnx7im are reported after pairing which is positive, and I changed the model from “A” to reflect the “B” version of my bulb. Not sure how important that is.

But now I’m stuck. I originally had the error relating to “…/exposes”, but after adding the full pathway it shifted to “…/extend”, which I can’t work out (tried the original lidl.js and full pathway but there was no difference). Bulb still not recognised as a supported device.

the Debug log is as follows:

Error: Cannot find module 'zigbee-herdsman-converters/lib/extend'
Require stack:
- /app/lib/util/utils.js
- /app/lib/util/settings.js
- /app/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at /app/lib/util/externally-loaded.js:5:16
    at Script.runInContext (vm.js:143:18)
    at Script.runInNewContext (vm.js:148:17)
    at Object.runInNewContext (vm.js:303:38)
    at loadModuleFromText (/app/lib/util/utils.js:156:8)
    at loadModuleFromFile (/app/lib/util/utils.js:162:12)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13770) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:13770) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[20:37:23] INFO: Handing over control to Zigbee2mqtt Core ...
> [email protected] start /app
> node index.js
(node:13805) UnhandledPromiseRejectionWarning: internal/modules/cjs/loader.js:883
  throw err;

Any ideas greatly appreciated!

This was solved by using the Edge version of Z2M.