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.

Ok its fixed. What is the Edge version and how do you replace the default installed by HASSIO?

Hi Dave,

I use the supervised version of HA. When I go to “supervisor”, I added “Zigbee2mqtt Edge” using the Addon button. The Edge installation is the development version of Zigbee2mqtt, so has more elements than the standard installation version that I had installed previously. You can’t run both versions together, so once I installed the Edge version, went back to the original Z2MQTT and opened it from the Supervisor page. There I stopped it, then unchecked the “start on boot” toggle. In the Edge version I did the opposite- I started it and checked the “start on boot” toggle.

There wasn’t an obvious issue with having both on the system at the same time if only one is running. I had to re-pair all my zigbee devices but that went without a hitch and I have since uninstalled the original verison via the button on the supervisor page again, leaving just my “Edge” version. It’s worked flawlessly since.

Hope this helps, and have a good crimble :slight_smile:

1 Like

Thanks for the assist, but I eventually found Zigbee2MQTT Edge replacing my previous non-Edge version (I too am on HASSIO - a 3 week old installation), and all but one of my Tuya devices are now working in it.

I have a (ZGMISMART) 6-button (18 switch single/double/long press) zigbee device that isn’t supported. even the Tuya services fail to provide the switches, only Smart Life (inside the app) recognises the switches…

I’m now struggling with two Knightsbridge WiFi smart sockets, well more accurately ONE, one has gone over to LocalTuya and provides direct control but inconsistent information or even switch setting, the other (identical device on a different IP address) will NOT configure in LocalTuya and ONLY works in Tuya remote! Go figure???