zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

[New device support] ZBN-DJ63 - Smart Breaker with Energy Monitoring

Open unwiredtech opened this issue 2 years ago • 28 comments

Link

https://www.amazon.com.au/Intelligent-Photovoltaic-Bidirectional-Automatic-Compatible/dp/B0CYPQHVYR

Database entry

{"id":3,"type":"Router","ieeeAddr":"0xa4c138fa6becd2bf","nwkAddr":22993,"manufId":4417,"manufName":"_TZE204_lb0fsvba","powerSource":"Mains (single phase)","modelId":"TS0601","epList":[1,242],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[4,5,61184,0],"outClusterList":[>

Comments

I tested this external definition but for some reason the Z2M Frontend could not see the Exposed sensors.

External definition

//Device type Router
//Zigbee Model - TS0601
//Zigbee Manufacturer - _TZE204_lb0fsvba

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

const definition = {
    // Identifies the device using fingerprint instead of zigbeeModel for Tuya devices
    fingerprint: [
        {
            modelID: 'TS0601',
            manufacturerName: '_TZE204_lb0fsvba',
        },
    ],
    model: 'ZBN-DJ-63',
    vendor: 'Tuya',
    description: 'Tuya Zigbee Smart Circuit Breaker with energy monitoring and protection settings',
    fromZigbee: [fz.on_off, fz.electrical_measurement, fz.metering, tuya.fz.datapoints],
    toZigbee: [tz.on_off, tz.electrical_measurement, tz.metering, tuya.tz.datapoints],
    exposes: [
        e.switch().setAccess('state', ea.ALL).withDescription('Switch the circuit breaker on/off'),
        e.energy().withAccess(ea.STATE).withDescription('Energy usage in kWh'),
        e.power().withAccess(ea.STATE).withDescription('Power usage in W'),
        e.voltage().withAccess(ea.STATE).withDescription('Voltage in V'),
        e.current().withAccess(ea.STATE).withDescription('Current in A'),

        exposes.enum('fault', ea.STATE, ['clear', 'over_current', 'over_power', 'over_voltage', 'under_voltage', 'leakage'])
            .withDescription('Fault status (clear = no faults)'),

        exposes.numeric('temperature_threshold', ea.ALL)
            .withUnit('°C')
            .withDescription('Temperature threshold for triggering protection')
            .withValueMin(10)
            .withValueMax(85),

        exposes.numeric('power_threshold', ea.ALL)
            .withUnit('W')
            .withDescription('Power threshold for triggering protection')
            .withValueMin(0)
            .withValueMax(9999),

        exposes.numeric('over_voltage_threshold', ea.ALL)
            .withUnit('V')
            .withDescription('Over voltage threshold for protection')
            .withValueMin(120)
            .withValueMax(300),

        exposes.numeric('under_voltage_threshold', ea.ALL)
            .withUnit('V')
            .withDescription('Under voltage threshold for protection')
            .withValueMin(80)
            .withValueMax(210),

        exposes.numeric('over_current_threshold', ea.ALL)
            .withUnit('A')
            .withDescription('Over current threshold for protection')
            .withValueMin(1)
            .withValueMax(63),

        exposes.numeric('leakage_current_threshold', ea.ALL)
            .withUnit('mA')
            .withDescription('Leakage current threshold for protection')
            .withValueMin(10)
            .withValueMax(99),

        exposes.binary('power_outage_memory', ea.ALL, 'ON', 'OFF')
            .withDescription('Retain state after power outage (ON - remembers last state)'),

        exposes.enum('indicator_mode', ea.ALL, ['off', 'normal', 'inverse'])
            .withDescription('LED indicator mode'),
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'energy', tuya.valueConverter.divideBy100],
            [6, null, tuya.valueConverter.phaseVariant2], // Handles voltage, current, power
            [10, 'fault', tuya.valueConverterBasic.lookup({
                'clear': 0,
                'over_current': 1,
                'over_power': 2,
                'over_voltage': 4,
                'under_voltage': 9,
                'leakage': 10,
            })],
            [17, 'temperature_threshold', tuya.valueConverter.raw],
            [18, 'meter_id', tuya.valueConverter.raw],
            [19, 'power_threshold', tuya.valueConverter.divideBy10],
            [20, 'clear_fault', tuya.valueConverter.onOff],
            [21, 'leakage_current_threshold', tuya.valueConverter.divideBy100],
            [22, 'indicator_mode', tuya.valueConverterBasic.lookup({
                'off': 0,
                'normal': 1,
                'inverse': 2,
            })],
            [23, 'power_outage_memory', tuya.valueConverter.onOff],
        ],
    },
};

module.exports = definition;

unwiredtech avatar Aug 03 '24 16:08 unwiredtech

Black-Smart-Meter Product Image

unwiredtech avatar Aug 03 '24 16:08 unwiredtech

Product Spec:

  • Name: Circuit Breaker
  • Material: PC
  • Rated vottage: 230VAC
  • Operation voltage: AC80V-400V(single phase)
  • Rated frequency: 50/60Hz
  • Electric current: (>A) 1-63A

Setting Ranges:

  • Under voltage protecting: 80V-210V adjustable
  • Overvoltage protecting: 120-300V adjustable
  • Overcurrent protecting:1.0A-63A adjustable
  • Reconnection time (delay time): 10s-99s adjustable
  • Overcurrent and leakage: 1-30 off adjustable
  • Leakage protecting: 10-99mA adjustable
  • Over temperature: 10-85 adjustable
  • Over current delay time: 1s-15s adjustable
  • Loss of current delay time: 1s-15s adjustable

unwiredtech avatar Aug 03 '24 16:08 unwiredtech

This is what I sketched. partially working

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

const definition = {

    fingerprint: tuya.fingerprint('TS0601', ['_TZE204_lb0fsvba']),
    model: 'TS0601_din_2',
    vendor: 'TuYa',
    description: 'Zigbee DIN energy meter',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],
    configure: tuya.configureMagicPacket,
    whiteLabel: [{vendor: 'XOCA', model: 'DAC2161C'}],
    exposes: [tuya.exposes.switch(), e.energy(), e.power(), e.voltage(), e.current(),
        exposes.enum('fault', ea.STATE, ['clear', 'over_current_threshold', 'over_power_threshold',
            'over_voltage threshold', 'wrong_frequency_threshold']).withDescription('Fault status of the device (clear = nothing)'),
        exposes.enum('threshold_1', ea.STATE, ['not_set', 'over_current_threshold', 'over_voltage_threshold'])
            .withDescription('State of threshold_1'),
        exposes.binary('threshold_1_protection', ea.STATE_SET, 'ON', 'OFF')
            .withDescription('OFF - alarm only, ON - relay will be off when threshold reached'),
        exposes.numeric('threshold_1_value', ea.STATE_SET)
            .withDescription('Can be in Volt or Ampere depending on threshold setting. Setup the value on the device'),
        exposes.enum('threshold_2', ea.STATE, ['not_set', 'over_current_threshold', 'over_voltage_threshold'])
            .withDescription('State of threshold_2'),
        exposes.binary('threshold_2_protection', ea.STATE, 'ON', 'OFF')
            .withDescription('OFF - alarm only, ON - relay will be off when threshold reached'),
        exposes.numeric('threshold_2_value', ea.STATE)
            .withDescription('Setup value on the device'),
		exposes.numeric('reverse_energy', ea.STATE).withUnit('kWh')
            .withDescription('Reverse Energy Total'),
		exposes.numeric('temperature', ea.STATE).withUnit('°C')
            .withDescription('Temperature'),
        exposes.binary('clear_fault', ea.STATE_SET, 'ON', 'OFF')
            .withDescription('Turn ON to clear last the fault'),
        exposes.text('meter_id', ea.STATE).withDescription('Meter ID (ID of device)'),
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'energy', tuya.valueConverter.divideBy100],
            [3, null, null], // Monthly, but sends data only after request
            [4, null, null], // Dayly, but sends data only after request
            [6, null, tuya.valueConverter.phaseVariant2], // voltage and current
            [9, 'fault', tuya.valueConverterBasic.lookup({'clear': 0, 'over_current_threshold': 1,
                'over_power_threshold': 2, 'over_voltage_threshold': 4, 'wrong_frequency_threshold': 8})],
            [11, null, null], // Frozen - strange function, in native app - nothing is clear
            [16, 'state', tuya.valueConverter.onOff],
            [17, null, tuya.valueConverter.threshold], // It's settable, but can't write converter
            [103, 'temperature', tuya.valueConverter.raw],
            [20, 'clear_fault', tuya.valueConverter.onOff], // Clear fault
            [13, null, null], // Balance energy
            [110, 'reverse_energy', tuya.valueConverter.divideBy100], // Reverse Energy Total
            [23, null, null], // Forward Energy T3 - don't know what this
            [24, null, null], // Forward Energy T4 - don't know what this
        ],
    },

};

module.exports = definition;

droserHA avatar Aug 06 '24 07:08 droserHA

Apologies for late reply.

I tested the definition and seems to work, but as you said some features are not working but this is better than before.

Thanks! Uploading zbn-dj-63.png…

unwiredtech avatar Aug 13 '24 16:08 unwiredtech

Hey, thanks for sketch, I have the same device

I've tried it, but my circuit breaker fails with wrong_frequency_threshold error (power is off), and I don't know how to change this threshold (or even is it real wrong_frequency_threshold error, because multimeter says frequency in socket is 50.00 Hz)

image

image

slayer avatar Aug 14 '24 21:08 slayer

Hi, i'm interested in tring this device to get "negative" apparent power injected to the grid from my solar setup. Is it working well / stable enough for this purpose ? thanks !

git-greatguy avatar Aug 15 '24 08:08 git-greatguy

@git-greatguy do you want to measure DC or AC? I believe this module is able to measure AC only. for DC there are other devices

slayer avatar Aug 15 '24 10:08 slayer

Sure, it's for measurin AC flow between grid and my inverter. 👍 my current zigbee module (TO-Q-SY1-JZT), send accurate values but values are not "signed". It's a bit annoying to know if i inject or pull from the grid ! This device looks promising to clear this issue.

git-greatguy avatar Aug 15 '24 10:08 git-greatguy

@git-greatguy I would recommend for this another device, it works good with in/out measurement

slayer avatar Aug 15 '24 11:08 slayer

Any ideas how to fix

I've tried it, but my circuit breaker fails with wrong_frequency_threshold

?

slayer avatar Aug 23 '24 13:08 slayer

Link

https://www.amazon.com.au/Intelligent-Photovoltaic-Bidirectional-Automatic-Compatible/dp/B0CYPQHVYR

Database entry

{"id":3,"type":"Router","ieeeAddr":"0xa4c138fa6becd2bf","nwkAddr":22993,"manufId":4417,"manufName":"_TZE204_lb0fsvba","powerSource":"Mains (single phase)","modelId":"TS0601","epList":[1,242],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[4,5,61184,0],"outClusterList":[>

Comments

I tested this external definition but for some reason the Z2M Frontend could not see the Exposed sensors.

External definition

//Device type Router
//Zigbee Model - TS0601
//Zigbee Manufacturer - _TZE204_lb0fsvba

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

const definition = {
    // Identifies the device using fingerprint instead of zigbeeModel for Tuya devices
    fingerprint: [
        {
            modelID: 'TS0601',
            manufacturerName: '_TZE204_lb0fsvba',
        },
    ],
    model: 'ZBN-DJ-63',
    vendor: 'Tuya',
    description: 'Tuya Zigbee Smart Circuit Breaker with energy monitoring and protection settings',
    fromZigbee: [fz.on_off, fz.electrical_measurement, fz.metering, tuya.fz.datapoints],
    toZigbee: [tz.on_off, tz.electrical_measurement, tz.metering, tuya.tz.datapoints],
    exposes: [
        e.switch().setAccess('state', ea.ALL).withDescription('Switch the circuit breaker on/off'),
        e.energy().withAccess(ea.STATE).withDescription('Energy usage in kWh'),
        e.power().withAccess(ea.STATE).withDescription('Power usage in W'),
        e.voltage().withAccess(ea.STATE).withDescription('Voltage in V'),
        e.current().withAccess(ea.STATE).withDescription('Current in A'),

        exposes.enum('fault', ea.STATE, ['clear', 'over_current', 'over_power', 'over_voltage', 'under_voltage', 'leakage'])
            .withDescription('Fault status (clear = no faults)'),

        exposes.numeric('temperature_threshold', ea.ALL)
            .withUnit('°C')
            .withDescription('Temperature threshold for triggering protection')
            .withValueMin(10)
            .withValueMax(85),

        exposes.numeric('power_threshold', ea.ALL)
            .withUnit('W')
            .withDescription('Power threshold for triggering protection')
            .withValueMin(0)
            .withValueMax(9999),

        exposes.numeric('over_voltage_threshold', ea.ALL)
            .withUnit('V')
            .withDescription('Over voltage threshold for protection')
            .withValueMin(120)
            .withValueMax(300),

        exposes.numeric('under_voltage_threshold', ea.ALL)
            .withUnit('V')
            .withDescription('Under voltage threshold for protection')
            .withValueMin(80)
            .withValueMax(210),

        exposes.numeric('over_current_threshold', ea.ALL)
            .withUnit('A')
            .withDescription('Over current threshold for protection')
            .withValueMin(1)
            .withValueMax(63),

        exposes.numeric('leakage_current_threshold', ea.ALL)
            .withUnit('mA')
            .withDescription('Leakage current threshold for protection')
            .withValueMin(10)
            .withValueMax(99),

        exposes.binary('power_outage_memory', ea.ALL, 'ON', 'OFF')
            .withDescription('Retain state after power outage (ON - remembers last state)'),

        exposes.enum('indicator_mode', ea.ALL, ['off', 'normal', 'inverse'])
            .withDescription('LED indicator mode'),
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'energy', tuya.valueConverter.divideBy100],
            [6, null, tuya.valueConverter.phaseVariant2], // Handles voltage, current, power
            [10, 'fault', tuya.valueConverterBasic.lookup({
                'clear': 0,
                'over_current': 1,
                'over_power': 2,
                'over_voltage': 4,
                'under_voltage': 9,
                'leakage': 10,
            })],
            [17, 'temperature_threshold', tuya.valueConverter.raw],
            [18, 'meter_id', tuya.valueConverter.raw],
            [19, 'power_threshold', tuya.valueConverter.divideBy10],
            [20, 'clear_fault', tuya.valueConverter.onOff],
            [21, 'leakage_current_threshold', tuya.valueConverter.divideBy100],
            [22, 'indicator_mode', tuya.valueConverterBasic.lookup({
                'off': 0,
                'normal': 1,
                'inverse': 2,
            })],
            [23, 'power_outage_memory', tuya.valueConverter.onOff],
        ],
    },
};

module.exports = definition;

there are 2 syntax mistake in this file I guest No comma after value: 10 in this datapoint ('leakage;: 10) and similar for datapoint 22: no ',' after 'inverse': 2

 [10, 'fault', tuya.valueConverterBasic.lookup({
            'clear': 0,
            'over_current': 1,
            'over_power': 2,
            'over_voltage': 4,
            'under_voltage': 9,
            'leakage': 10,
        })],

pana800 avatar Dec 09 '24 06:12 pana800

I managed to add my ZBN-J-63 using

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

// Check if getDataValue function exists, if not define it
if (typeof tuya.getDataValue !== 'function') {
    tuya.getDataValue = (dpValue) => {
        // Extract data value from dpValue
        return parseInt(JSON.parse(JSON.stringify(dpValue.data)).data);
    };
}

const tzLocal = {
    state: {
        key: ['state'],
        convertSet: async (entity, key, value, meta) => {
            await tuya.sendDataPointBool(entity, 16, value === 'ON');
            return { state: value.toUpperCase() };
        },
    },
};

const fzLocal = {
    state: {
        cluster: 'manuSpecificTuya',
        type: ['commandDataResponse', 'commandDataReport'],
        convert: (model, msg, publish, options, meta) => {
            for (const dpValue of msg.data.dpValues) {
                const dp = dpValue.dp;
                if (dp == 16) {
                    const value = tuya.getDataValue(dpValue);
                    // meta.logger.info(`RECEIVED DP #${dp} -- VALUE = ${value}`);
                    const state = value ? 'ON' : 'OFF';
                    // meta.logger.info(`Setting state to ${state}`);
                    return { state };
                }
            }
        },
    },
};

const definition = {
    fingerprint: [{ modelID: 'TS0601', manufacturerName: '_TZE204_xxxxxxxx' }],
    model: 'ZBN-J-63',
    vendor: 'Tuya',
    description: 'Tuya Zigbee Smart Circuit Breaker with energy monitoring and protection settings',
    fromZigbee: [fzLocal.state, fz.electrical_measurement, fz.metering, tuya.fz.datapoints],
    toZigbee: [tzLocal.state, tuya.tz.datapoints],
    configure: async (device, coordinatorEndpoint, logger) => {
        const endpoint = device.getEndpoint(1);
        await reporting.bind(endpoint, coordinatorEndpoint, ['genBasic']);
    },
    exposes: [
        e.switch().setAccess('state', ea.STATE_SET).withDescription('Switch the circuit breaker on/off'),
        e.energy().withAccess(ea.STATE).withDescription('Energy usage in kWh'),
        e.power().withAccess(ea.STATE).withDescription('Power usage in W'),
        e.voltage().withAccess(ea.STATE).withDescription('Voltage in V'),
        e.current().withAccess(ea.STATE).withDescription('Current in A'),
        exposes.enum('fault', ea.STATE, ['clear', 'over_current', 'over_power', 'over_voltage', 'under_voltage', 'leakage'])
            .withDescription('Fault status (clear = no faults)'),
        exposes.numeric('temperature_threshold', ea.ALL)
            .withUnit('°C')
            .withDescription('Temperature threshold for triggering protection')
            .withValueMin(10)
            .withValueMax(85),
        exposes.numeric('power_threshold', ea.ALL)
            .withUnit('W')
            .withDescription('Power threshold for triggering protection')
            .withValueMin(0)
            .withValueMax(9999),
        exposes.numeric('over_voltage_threshold', ea.ALL)
            .withUnit('V')
            .withDescription('Over voltage threshold for protection')
            .withValueMin(120)
            .withValueMax(300),
        exposes.numeric('under_voltage_threshold', ea.ALL)
            .withUnit('V')
            .withDescription('Under voltage threshold for protection')
            .withValueMin(80)
            .withValueMax(210),
        exposes.numeric('over_current_threshold', ea.ALL)
            .withUnit('A')
            .withDescription('Over current threshold for protection')
            .withValueMin(1)
            .withValueMax(63),
        exposes.numeric('leakage_current_threshold', ea.ALL)
            .withUnit('mA')
            .withDescription('Leakage current threshold for protection')
            .withValueMin(10)
            .withValueMax(99),
        exposes.binary('power_outage_memory', ea.ALL, 'ON', 'OFF')
            .withDescription('Retain state after power outage (ON - remembers last state)'),
        exposes.enum('indicator_mode', ea.ALL, ['off', 'normal', 'inverse'])
            .withDescription('LED indicator mode'),
    ],
    meta: {
        tuyaDatapoints: [
            [1, 'energy', tuya.valueConverter.divideBy100],
            [6, null, tuya.valueConverter.phaseVariant2],
            [10, 'fault', tuya.valueConverterBasic.lookup({
                'clear': 0,
                'over_current': 1,
                'over_power': 2,
                'over_voltage': 4,
                'under_voltage': 9,
                'leakage': 10
            })],
            [17, 'temperature_threshold', tuya.valueConverter.raw],
            [18, 'meter_id', tuya.valueConverter.raw],
            [19, 'power_threshold', tuya.valueConverter.divideBy10],
            [20, 'clear_fault', tuya.valueConverter.onOff],
            [21, 'leakage_current_threshold', tuya.valueConverter.divideBy100],
            [22, 'indicator_mode', tuya.valueConverterBasic.lookup({
                'off': 0,
                'normal': 1,
                'inverse': 2
            })],
            [23, 'power_outage_memory', tuya.valueConverter.onOff],
        ],
    },
};

module.exports = definition;

sudipta26889 avatar Dec 28 '24 18:12 sudipta26889

Your converter didn't work for me. Here's the updated code, but the datapoints still need to be tested. Again, this converter works for me, but not all the functionality is implemented.

const fz = require('zigbee-herdsman-converters/converters/fromZigbee');

const tz = require('zigbee-herdsman-converters/converters/toZigbee');

const exposes = require('zigbee-herdsman-converters/lib/exposes');

const reporting = require('zigbee-herdsman-converters/lib/reporting');

const e = exposes.presets;

const ea = exposes.access;

const tuya = require('zigbee-herdsman-converters/lib/tuya');

const { Buffer } = require('buffer'); // Ensure Buffer is available

// Check if getDataValue function exists, if not define it

if (typeof tuya.getDataValue !== 'function') {

tuya.getDataValue = (dpValue) => {

    // Extract data value from dpValue

    return dpValue.data;

};

}

const tzLocal = {

state: {

    key: ['state'],

    convertSet: async (entity, key, value, meta) => {

        await tuya.sendDataPointBool(entity, 16, value === 'ON');

    },

},

};

const definition = {

fingerprint: tuya.fingerprint('TS0601', ['_TZE204_lb0fsvba']), // Используем рабочий fingerprint

model: 'ZBN-DJ-63',

vendor: 'TuYa',

description: 'Tuya Zigbee Smart Circuit Breaker with energy monitoring and protection settings',

fromZigbee: [fz.on_off, fz.electrical_measurement, fz.metering, tuya.fz.datapoints],

toZigbee: [tzLocal.state, tuya.tz.datapoints],

configure: tuya.configureMagicPacket, // Используем рабочий метод конфигурации

whiteLabel: [{ vendor: 'XOCA', model: 'DAC2161C' }],

exposes: [

    e.switch().setAccess('state', ea.STATE_SET).withDescription('Switch the circuit breaker on/off'),

    e.energy().withAccess(ea.STATE).withDescription('Energy usage in kWh'),

    e.power().withAccess(ea.STATE).withDescription('Power usage in W'),

    e.voltage().withAccess(ea.STATE).withDescription('Voltage in V'),

    e.current().withAccess(ea.STATE).withDescription('Current in A'),

    exposes.enum('fault', ea.STATE, ['clear', 'over_current', 'over_power', 'over_voltage', 'under_voltage', 'leakage'])

        .withDescription('Fault status (clear = no faults)'),

    exposes.numeric('temperature_threshold', ea.ALL)

        .withUnit('°C')

        .withDescription('Temperature threshold for triggering protection')

        .withValueMin(10)

        .withValueMax(85),

    exposes.numeric('power_threshold', ea.ALL)

        .withUnit('W')

        .withDescription('Power threshold for triggering protection')

        .withValueMin(0)

        .withValueMax(9999),

    exposes.numeric('over_voltage_threshold', ea.ALL)

        .withUnit('V')

        .withDescription('Over voltage threshold for protection')

        .withValueMin(120)

        .withValueMax(300),

    exposes.numeric('under_voltage_threshold', ea.ALL)

        .withUnit('V')

        .withDescription('Under voltage threshold for protection')

        .withValueMin(80)

        .withValueMax(210),

    exposes.numeric('over_current_threshold', ea.ALL)

        .withUnit('A')

        .withDescription('Over current threshold for protection')

        .withValueMin(1)

        .withValueMax(63),

    exposes.numeric('leakage_current_threshold', ea.ALL)

        .withUnit('mA')

        .withDescription('Leakage current threshold for protection')

        .withValueMin(10)

        .withValueMax(99),

    exposes.binary('power_outage_memory', ea.ALL, 'ON', 'OFF')

        .withDescription('Retain state after power outage (ON - remembers last state)'),

    exposes.enum('indicator_mode', ea.ALL, ['off', 'normal', 'inverse'])

        .withDescription('LED indicator mode'),

    exposes.numeric('reverse_energy', ea.STATE).withUnit('kWh')

        .withDescription('Reverse Energy Total'),

    exposes.numeric('temperature', ea.STATE).withUnit('°C')

        .withDescription('Temperature'),

    exposes.binary('clear_fault', ea.STATE_SET, 'ON', 'OFF')

        .withDescription('Turn ON to clear last the fault'),

    exposes.text('meter_id', ea.STATE).withDescription('Meter ID (ID of device)'),

],

meta: {

    tuyaDatapoints: [

        [1, 'energy', tuya.valueConverter.divideBy100],

        [3, null, null], // Monthly, but sends data only after request

        [4, null, null], // Daily, but sends data only after request

        [6, null, tuya.valueConverter.phaseVariant2], // voltage and current

        [9, 'fault', tuya.valueConverterBasic.lookup({

            'clear': 0,

            'over_current': 1,

            'over_power': 2,

            'over_voltage': 4,

            'wrong_frequency_threshold': 8

        })],

        [11, null, null], // Frozen - strange function, in native app - nothing is clear

        [16, 'state', tuya.valueConverter.onOff],

        [17, 'temperature_threshold', tuya.valueConverter.raw],

        [103, 'temperature', tuya.valueConverter.raw],

        [20, 'clear_fault', tuya.valueConverter.onOff], // Clear fault

        [13, null, null], // Balance energy

        [110, 'reverse_energy', tuya.valueConverter.divideBy100], // Reverse Energy Total

        [23, null, null], // Forward Energy T3 - don't know what this

        [24, null, null], // Forward Energy T4 - don't know what this

        [18, 'meter_id', tuya.valueConverter.raw],

        [19, 'power_threshold', tuya.valueConverter.divideBy10],

        [21, 'leakage_current_threshold', tuya.valueConverter.divideBy100],

        [22, 'indicator_mode', tuya.valueConverterBasic.lookup({

            'off': 0,

            'normal': 1,

            'inverse': 2

        })],

        [23, 'power_outage_memory', tuya.valueConverter.onOff],

    ],

},

};

module.exports = definition;

From: Sudipta Dhara @.> Sent: Saturday, December 28, 2024 8:20 PM To: Koenkk/zigbee2mqtt @.> Cc: droserHA @.>; Comment @.> Subject: Re: [Koenkk/zigbee2mqtt] [New device support] ZBN-DJ63 - Smart Breaker with Energy Monitoring (Issue #23502)

I managed to add my ZBN-J-63 using

const fz = require('zigbee-herdsman-converters/converters/fromZigbee'); const tz = require('zigbee-herdsman-converters/converters/toZigbee'); const exposes = require('zigbee-herdsman-converters/lib/exposes'); const reporting = require('zigbee-herdsman-converters/lib/reporting'); const e = exposes.presets; const ea = exposes.access; const tuya = require('zigbee-herdsman-converters/lib/tuya'); const { Buffer } = require('buffer'); // Ensure Buffer is available

// Check if getDataValue function exists, if not define it if (typeof tuya.getDataValue !== 'function') { tuya.getDataValue = (dpValue) => { // Extract data value from dpValue return dpValue.data; }; }

const tzLocal = { state: { key: ['state'], convertSet: async (entity, key, value, meta) => { await tuya.sendDataPointBool(entity, 16, value === 'ON'); }, }, };

const definition = { fingerprint: [{ modelID: 'TS0601', manufacturerName: '_TZE204_xxxxxxxx' }], model: 'ZBN-J-63', vendor: 'Tuya', description: 'Tuya Zigbee Smart Circuit Breaker with energy monitoring and protection settings', fromZigbee: [fz.on_off, fz.electrical_measurement, fz.metering, tuya.fz.datapoints], toZigbee: [tzLocal.state, tuya.tz.datapoints], configure: async (device, coordinatorEndpoint, logger) => { const endpoint = device.getEndpoint(1); await reporting.bind(endpoint, coordinatorEndpoint, ['genBasic']); }, exposes: [ e.switch().setAccess('state', ea.STATE_SET).withDescription('Switch the circuit breaker on/off'), e.energy().withAccess(ea.STATE).withDescription('Energy usage in kWh'), e.power().withAccess(ea.STATE).withDescription('Power usage in W'), e.voltage().withAccess(ea.STATE).withDescription('Voltage in V'), e.current().withAccess(ea.STATE).withDescription('Current in A'), exposes.enum('fault', ea.STATE, ['clear', 'over_current', 'over_power', 'over_voltage', 'under_voltage', 'leakage']) .withDescription('Fault status (clear = no faults)'), exposes.numeric('temperature_threshold', ea.ALL) .withUnit('°C') .withDescription('Temperature threshold for triggering protection') .withValueMin(10) .withValueMax(85), exposes.numeric('power_threshold', ea.ALL) .withUnit('W') .withDescription('Power threshold for triggering protection') .withValueMin(0) .withValueMax(9999), exposes.numeric('over_voltage_threshold', ea.ALL) .withUnit('V') .withDescription('Over voltage threshold for protection') .withValueMin(120) .withValueMax(300), exposes.numeric('under_voltage_threshold', ea.ALL) .withUnit('V') .withDescription('Under voltage threshold for protection') .withValueMin(80) .withValueMax(210), exposes.numeric('over_current_threshold', ea.ALL) .withUnit('A') .withDescription('Over current threshold for protection') .withValueMin(1) .withValueMax(63), exposes.numeric('leakage_current_threshold', ea.ALL) .withUnit('mA') .withDescription('Leakage current threshold for protection') .withValueMin(10) .withValueMax(99), exposes.binary('power_outage_memory', ea.ALL, 'ON', 'OFF') .withDescription('Retain state after power outage (ON - remembers last state)'), exposes.enum('indicator_mode', ea.ALL, ['off', 'normal', 'inverse']) .withDescription('LED indicator mode'), ], meta: { tuyaDatapoints: [ [1, 'energy', tuya.valueConverter.divideBy100], [6, null, tuya.valueConverter.phaseVariant2], [10, 'fault', tuya.valueConverterBasic.lookup({ 'clear': 0, 'over_current': 1, 'over_power': 2, 'over_voltage': 4, 'under_voltage': 9, 'leakage': 10 })], [17, 'temperature_threshold', tuya.valueConverter.raw], [18, 'meter_id', tuya.valueConverter.raw], [19, 'power_threshold', tuya.valueConverter.divideBy10], [20, 'clear_fault', tuya.valueConverter.onOff], [21, 'leakage_current_threshold', tuya.valueConverter.divideBy100], [22, 'indicator_mode', tuya.valueConverterBasic.lookup({ 'off': 0, 'normal': 1, 'inverse': 2 })], [23, 'power_outage_memory', tuya.valueConverter.onOff], ], }, };

module.exports = definition;

— Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/23502#issuecomment-2564395598 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ATKGMY6GSATIXH3VOJCAQ3L2H3TUZAVCNFSM6AAAAABL6BQOK2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRUGM4TKNJZHA . You are receiving this because you commented.Message ID: @.***>

droserHA avatar Dec 29 '24 11:12 droserHA

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Feb 28 '25 00:02 github-actions[bot]

I'm looking into using the ZBN-DJ-63 smart circuit breaker, which supports Zigbee and claims to offer bidirectional metering for photovoltaic (PV) setups (i.e., both grid import and solar export monitoring).

Before proceeding, I’d like to ask:

  • Is this model currently supported by Zigbee2MQTT?
  • If supported, does Zigbee2MQTT expose both import and export energy values through MQTT?

LightMoon avatar May 05 '25 12:05 LightMoon

The short answer is that the device isn't supported. Better purchase something else.

M66B avatar May 05 '25 12:05 M66B

The short answer is that the device isn't supported. Better purchase something else.

Thanks for the quick reply. It seems there has been some attempt here. By the way, I couldn’t find any circuit breakers that come with a built-in bi-directional metering feature—it seems to be quite unique on its own. I was wondering if you happen to know of any options? I’d prefer not to use a CT clamp for this purpose.

LightMoon avatar May 05 '25 12:05 LightMoon

It's the same reason why I bought this device. If you can live without the over/under voltage/current options, you can define an external converter:

// https://github.com/Koenkk/zigbee2mqtt/issues/23502

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

const definition = {
    fingerprint: [
        {
            modelID: 'TS0601',
            manufacturerName: '_TZE204_lb0fsvba', // ZBN-DJ-63
        },
        {
            modelID: 'TS0601',
            manufacturerName: '_TZE204_kpg9hpb0', // ZBN-JLS-63
        },
    ],
    model: 'ZBN-DJ/JLS-63',
    vendor: 'NoName',
    description: 'Bidirectional energy meter',
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],
    configure: tuya.configureMagicPacket,
    exposes: [
            tuya.exposes.switch(),
            e.energy(),
            e.voltage(),
            e.power(),
            e.current(),
            e.produced_energy(),
            exposes.numeric('temperature', ea.STATE)
                .withUnit('°C')
                .withDescription('Temperature'),
            exposes.enum('indicator_mode', ea.ALL, ['off', 'normal', 'inverse'])
                .withDescription('LED indicator mode'),
            exposes.binary('power_outage_memory', ea.ALL, 'ON', 'OFF')
                .withDescription('Retain state after power outage (ON - remembers last state)'),
    ],
    meta: {
            tuyaDatapoints: [
                [1, 'energy', tuya.valueConverter.divideBy100], // Forward energy total
                [6, null, tuya.valueConverter.phaseVariant2], // Handles voltage, current, power
                [16, 'state', tuya.valueConverter.onOff],
                [22, 'indicator_mode', tuya.valueConverterBasic.lookup({'off': 0, 'normal': 1, 'inverse': 2})],
                [23, 'power_outage_memory', tuya.valueConverter.onOff],
                [103, 'temperature', tuya.valueConverter.raw],
                [110, 'produced_energy', tuya.valueConverter.divideBy100], // Reverse Energy Total
            ],
    },
    extend: [
    ],
};

module.exports = definition;

M66B avatar May 05 '25 12:05 M66B

@M66B, just wondering—any particular reason we couldn’t get it to work? @Sudipta26889, how’s everything going with your converter?

LightMoon avatar May 05 '25 13:05 LightMoon

For me, voltage, current, power, forward and reverse energy are enough, and I didn't put effort into other options.

M66B avatar May 05 '25 13:05 M66B