Z2MQTT External converter

Hello All,

This new update of Z2MQTT gives hell of a time… It looks like its much more difficult to load external converters now.
It doesnt look like adding the
external_converters:

    • yourfile.js*

does anything.

Reading the new support page it looks like the file should be loaded via MQTT message, but I cant figure it out how it works. This is what I supposed to do:
To save a converter at runtime, send a message to zigbee2mqtt/bridge/request/converter/save with payload {"name": "my-first-converter.js", "code": <HERE COMES YOUR CONVERTER CODE>}. The code will be saved in data/external_converters/ in the file with the given name.

Whatever I try I only see this in the logs:
2025-01-04 22:35:09z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/bridge/response/converter/save', payload '{"data":{},"error":"Invalid payload","status":"error"}'

I cant even save a test message in this file, let alone my full converter…

I tried to manually find the save location to just put my already existing file there, but couldnt. Any help would be appreciated especially some of the unsupported devices are thermostats and currently they dont function.

Please check the mentioned Discussion for the “breaking changes” Upgrade, specifically the part for external converters:

External converters and extensions

    The external_converters setting is no longer used. Instead all external converters inside data/external_converters directory are now automatically loaded. Make sure to move all your external converters to this directory.
    External extensions are now loaded from data/external_extensions instead of data/extension. Make sure to rename your data/extension directory (if present) to data/external_extensions.

I’ve read this, but I assume I just dont know enough about how this work because I was unable to find this directory.

I dont have a data/external_extensions in the zigbee2mqtt folder where the configuration.yaml is

Creating it doesnt work. Tried to find it in root, but no success. I’m probably missing something really obvious or being a noob, sorry.

Tried to search online, but this has to be too basic for people to not know, but alas, here I am.

/data ist the folder, which holds the configuration of z2m, so you should create there a new folder “external_extensions” and put your converts .js file in it.

There should also be a “log” folder there with your logs and there should be a migration log.

Hope this works for you

Okay this helped a lot.
In the log file under z2m:mqtt: Received MQTT message on ‘zigbee2mqtt/bridge/info’ with data I can see:
“external_converters”:[“dvr.js”]

So it seem to be picking up the file, but the my thermostat is still unsupported and doesnt have any exposes. This was working perfectly before the update the update, so I dont think its the file that is wrong.

I dont see any error related converters or dvr.js in the logs either. Any tips how to troubleshoot this further?

No, sorry, i have none.

I suggest, you open a issue on github with all infos.

Or you downgrade your install to 1.x from the backup if you need them quick to work.

I figured it out. I’m not sure what was the issue, but my suspicion is some kind of weird folder ownership issue.
Originally I created the data/external_converters folder with the file editor addon. It was not working.
I saw a post on github that you should do it via CLI. So I deleted the folder via CLI first, then re-created it via the command line and it worked.

Weird, but thats linux if you are noob…

1 Like

Awesome :slight_smile: Good that all is running fine again.

6 hours!!
6 hours i’ve been looking to solve this problem!

So:

  • open Terminal
    • cd homeassistant/
    • cd zigbee2mqtt/
    • mkdir external_converters
    • cd external_converters
    • touch convertor.js
  • open File editor
    • paste your convertor code

:face_with_symbols_over_mouth:

5 Likes

@Arnen if this makes you feel any better, your simple instructions got it working for me. Thanks for taking the time to post them.

Ironically, Z2M has very detailed documentation but this is definitely a fail on their part. There seems to be a lot of discrepancies and missing information on how to do this.

Sorry for not adding the steps. I was super angry and annoyed by the end… I will mark yours as a solution as it gives the exact steps.

I had the same thing and your advice works 100%. Thanks

Still not working for me:

image

The TS1201.js was working fine before the upgrade.

I tried to create a converter.js as well. Still nothing

Didnt work on my side to

No errors, no logs, without this, no help is possible :confused:

A touch does not help, it creates an EMPTY file, you have to fill it with the external converter specs of course.

Then go to the log section (in the addon) and start z2mqtt new, then there should be an info for the external converts and why it failed.

Ronny

Got my ext converters up and running again, though I do not see the attributes published anymore? Anybody seen the same?

Damn there is a lot of changes… I’m NOT updating my second server until I have controll of the v2…

I found a solution for me

I used sudo before the touch command.

Same here. I’m having a lot of issues with this new upgrade.

Never upgrading it again unless I need to

Using zigbee2mqtt has ha integration “data/external_converters” is a new directory “external_converters” in the zigbee2mqtt directory.
Just create external_converters directory in the zigbee2mqtt directory and move your js files to this new directory.
Hope this help…

I’m on Synology running HA via a Virtual Machine. I don’t know how to access the directory or where to find it using console.

I tried the manual approach of creating the folder and uploading the .js file from HA control panel but it’s not working? Any other easy ways?

Here’s the error I’m getting:

[2025-01-14 22:23:07] error: z2m: Failed to call ‘ExternalConverters’ ‘start’ (node:internal/modules/cjs/loader:1252

throw err;

^

Error: Cannot find module ‘zigbee-herdsman-converters/lib/extend’

Require stack:

  • /app/dist/extension/externalJS.js

  • /app/dist/extension/externalConverters.js