Skip to content

Add Zigbee2MQTT 2.x external converter (.mjs)#11

Open
denovich wants to merge 1 commit intoStuckAtPrototype:masterfrom
denovich:z2m-2x-converter
Open

Add Zigbee2MQTT 2.x external converter (.mjs)#11
denovich wants to merge 1 commit intoStuckAtPrototype:masterfrom
denovich:z2m-2x-converter

Conversation

@denovich
Copy link
Copy Markdown

Summary

The existing Z2M external converter (z2m/aircube.js) uses CommonJS format which is incompatible with Zigbee2MQTT 2.x. Z2M 2.x silently rejects .js converters — it renames them to .invalid and the custom cluster data (eCO2, VOC, AQI) never gets processed.

This PR:

  • Adds z2m/aircube.mjs — an ES module converter that works with Z2M 2.x
  • Fixes two additional Z2M 2.x compatibility issues:
    • Custom cluster ID must be a string ('64513') not a number (0xFC01), because Z2M 2.x compares unknown cluster names as strings internally
    • Import paths must omit the .js extension
  • Updates HOME_ASSISTANT.md to document both Z2M 1.x and 2.x setup
  • Adds Z2M 2.x troubleshooting guidance
  • Marks the existing aircube.js as Z2M 1.x only

The existing aircube.js is preserved for Z2M 1.x users.

Testing

Tested with Z2M 2.9.1 (HA add-on). All five sensors report correctly:

  • Temperature and humidity via standard clusters (modernExtend)
  • eCO2, VOC, and AQI via custom cluster 0xFC01

Before the fix, Z2M would log:

No converter available for 'AirCube' with cluster '64513' and type 'attributeReport'

After:

MQTT publish: topic 'zigbee2mqtt/AirCube 1', payload '{"aqi":74,"eco2":647,"humidity":38.46,"temperature":24.86,"voc":101}'

Z2M 2.x requires ES module format (.mjs) — the existing CommonJS
converter (aircube.js) fails to load silently (renamed to .invalid).

Two additional Z2M 2.x compatibility fixes in the new converter:
- Cluster ID must be a string ('64513') not a number (0xFC01),
  because Z2M 2.x compares unknown cluster names as strings
- Import paths use no .js extension per Z2M 2.x conventions

Also updates HOME_ASSISTANT.md to document both Z2M versions and
adds Z2M 2.x troubleshooting guidance.
@StuckAtPrototype
Copy link
Copy Markdown
Owner

Awesome, thank you! I got a report of the same thing happening on the quirk. I was testing on HA 2025. Thanks! I will review and pull in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants