Skip to content

Instantly share code, notes, and snippets.

@unwiredtech
Created August 3, 2024 15:53
Show Gist options
  • Save unwiredtech/3d318c5b9ddf64cbea0182c8e22526b2 to your computer and use it in GitHub Desktop.
Save unwiredtech/3d318c5b9ddf64cbea0182c8e22526b2 to your computer and use it in GitHub Desktop.
zbn-dj63
//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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment