I have an ESP32C6 (Arudino Framework) running a zibgee project.
My ESP32C6 is connected to HA via Z2M
I created a folder called external_converters and under that a file called myproj.mjs
First question, should I be using mjs or js for this? Online docs, and online examples that I’ve found are rubbish. If .mjs isn’t the correct way (I was following the guide here → External converters | Zigbee2MQTT)
Anyway… In my ESP32C6 I have 3 switches, 1 temp, 1 numeric and 1 binary endpoints.
I’ve got the switches showing in HA no problems (and I can toggle them in H/A and get the ESP32 to react), but I can’t get the temp to display (just shows null in Z2M) and likewise can’t get the numeric value or the binary value to show in Z2M.
What am I doing wrong please???
My myproj.mjs file is below
import * as m from 'zigbee-herdsman-converters/lib/modernExtend';
import * as fz from 'zigbee-herdsman-converters/converters/fromZigbee';
import * as tz from 'zigbee-herdsman-converters/converters/toZigbee';
import * as exposes from 'zigbee-herdsman-converters/lib/exposes';
const e = exposes.presets;
export default {
zigbeeModel: ['MyProj'],
model: 'MyProj',
vendor: 'Me',
description: 'ESP32-C6 controller',
fromZigbee: [
fz.on_off,
fz.temperature
],
toZigbee: [
tz.on_off
],
exposes: [
e.switch().withEndpoint('OnBoardLight').withDescription('Onboard status LED'),
e.switch().withEndpoint('Light1').withDescription('External light 1'),
e.switch().withEndpoint('Light2').withDescription('External light 2'),
e.binary('systemInit', exposes.access.STATE, true, false)
.withEndpoint('SystemInit')
.withDescription('System Initialised'),
e.temperature()
.withEndpoint('InternalTemp')
.withProperty('internal_temp')
.withDescription('Internal Air Temp'),
e.numeric('water_level', exposes.access.STATE)
.withEndpoint('WaterLevel')
.withProperty('water_level') // 👈 consistent property name
.withUnit('cm') // optional: show units
.withDescription('Water level'),
],
meta: { multiEndpoint: true },
endpoint: (device) => ({
OnBoardLight: 10,
Light1: 9,
Light2: 8,
InternalTemp: 26,
WaterLevel: 31,
SystemInit: 99,
}),
};
For completeness this is an extract from my configuration.yaml file
homeassistant:
enabled: true
advanced:
# Other stuff here but removed for this post.
external_converters:
- test.mjs
- esp32c6-pond-controller.mjs
In H/A the binary is showing in Z2M as “SystemInit”, Description “System Initialised” value is Null, HA entities its showing as “SystemInit SystemInit”
In H/A the numeric is showing in Z2M as “Water Level”, Description “Water Level” value is Null cm, HA entities its showing as “Water Level WaterLevel”
In H/A the temperature is showing in Z2M as “Temperature”, Description “Internal Air Temp” value is Null C, HA entities its showing as “Temperature”
I know the ESP32C6 is working because for example I can see the binary report sending, see console output
[767484][D][ZigbeeBinary.cpp:70] setBinaryInput(): Setting binary input to 1
[767486][V][ZigbeeBinary.cpp:100] reportBinaryInput(): Binary Input report sent
and temp
[222118][V][ZigbeeTempSensor.cpp:79] setTemperature(): Updating temperature sensor value...
[222118][D][ZigbeeTempSensor.cpp:81] setTemperature(): Setting temperature to 138
Can anyone please help me fix my mjs file so I can get the numeric, temp and binary showing in H/A