zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

New device EARU din smart relay TS0601 TZE204_davzgqq0. Add support or converter.

Open VladimirTuzovGitHub opened this issue 2 years ago • 152 comments

Link

https://aliexpress.com/item/1005004894566311.html

Database entry

{"id":45,"type":"Router","ieeeAddr":"0x84b4dbfffec08548","nwkAddr":18204,"manufId":4098,"manufName":"_TZE204_davzgqq0","powerSource":"Mains (single phase)","modelId":"TS0601","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[0,4,5,61184],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65503":"��\u0010+i��\u0010+\u0013�l\u000f+\u0013�l\u000f+i�l\u000f+i��\u0010+i�l\u000f+i��\u0010+i","65506":31,"65508":0,"modelId":"TS0601","manufacturerName":"_TZE204_davzgqq0","powerSource":1,"zclVersion":3,"appVersion":70,"stackVersion":0,"hwVersion":1,"dateCode":""}}},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":70,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1673517086744,"defaultSendRequestWhen":"immediate"}

Comments

Hello! Please help me to make a converter for EARU din smart relay TS0601 TZE204_davzgqq0, works with TuYa. Its functions are similar to TuYa TS011F_din_smart_relay. It is not currently supported in z2m.

External converter

No response

Supported color modes

No response

Color temperature range

No response

VladimirTuzovGitHub avatar Jan 12 '23 12:01 VladimirTuzovGitHub

Hello. I took as a basis the converter from DAC2161C. Not everything works.

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 extend = require('zigbee-herdsman-converters/lib/extend'); const e = exposes.presets; const ea = exposes.access; const tuya = require("zigbee-herdsman-converters/lib/tuya");

const fzLocal = { tuya_xocadinrail_switch: { cluster: 'manuSpecificTuya', type: ['commandDataResponse', 'commandDataReport'], convert: (model, msg, publish, options, meta) => { for (const dpValue of msg.data.dpValues) { const value = tuya.getDataValue(dpValue); const dp = dpValue.dp;

            switch (dp) {
                case 16: // DPID that we added to common
                   return {   state: value ? 'ON' : 'OFF'};
                   
                  
                case 1:
                    return {
                        energy: value / 100
                    };
                case 6:   
                 return {
                        current: ((value[4] | value[3] << 8) / 1000), voltage: ((value[1] | value[0] << 8) / 10), power: ((value[7] | value[6] << 8))
                    };
                    
                case 17:
                  const lookup = {
                   0: 'not set',
                   1: 'Over current threshold',
                   3: 'Over voltage threshold',
                                  };
                    return {
                        threshold_1: lookup[value[0]],
                        threshold1_value : (value[3] | value[2] << 8),
                        threshold_2: lookup[value[4]],
                        threshold2_value : (value[7] | value[6] << 8),                            
                };    
                    
                  case 10:{
                      const lookup = {
                      0: 'clear',
                      1: 'over current threshold',
                      2: 'over power threshold',
                      4: 'over voltage threshold',
                      8: 'wrong frequency threshold',
                       };
                       return { alarm : lookup[value]} ;
                }
            }
        }
    },
},

};

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_davzgqq0' }], model: 'EAYCBM-Z_2P', vendor: 'Tuya', extend: extend.switch(), description: 'DIN Rail Smart Energy Meter', fromZigbee: [fzLocal.tuya_xocadinrail_switch, ], toZigbee: [tzLocal.state], configure: async (device, coordinatorEndpoint, logger) => { const endpoint = device.getEndpoint(1); await reporting.bind(endpoint, coordinatorEndpoint, ['genBasic']); }, exposes: [e.switch().setAccess('state', ea.STATE_SET), e.voltage(), e.power(), e.current(), e.energy(), exposes.text('threshold_1', ea.STATE), exposes.text('threshold1_value', ea.STATE), exposes.text('threshold_2', ea.STATE), exposes.text('threshold2_value', ea.STATE), exposes.text('alarm', ea.STATE), ] };

module.exports = definition;

Avdeich avatar Jan 13 '23 07:01 Avdeich

@Avdeich please attach here your external_converter file, I'll test it on my device.

DNX avatar Jan 13 '23 11:01 DNX

Good afternoon. not everything works for me either . I took DAC2161C as a basis. avtomat.txt

Igos439 avatar Jan 14 '23 14:01 Igos439

I also have a circuit breaker with this ID. I just tried the latest converter from @Avdeich and it seems to work. However I'm still getting some log messages about unknown messages. E.g.

Zigbee2MQTT:warn  2023-02-06 20:03:59: zigbee-herdsman-converters:: NOT RECOGNIZED DP #18 with data {"seq":22016,"dpValues":[{"dp":18,"datatype":0,"data":{"type":"Buffer","data":[1,1,0,35,3,1,1,9,4,1,0,180]}}]} VALUE = #	�
Zigbee2MQTT:warn  2023-02-06 20:03:59: zigbee-herdsman-converters:: NOT RECOGNIZED DP #19 with data {"seq":22272,"dpValues":[{"dp":19,"datatype":3,"data":{"type":"Buffer","data":[89,75,76,68,45,90,67,72,32,86,49,46,48]}}]} VALUE = YKLD-ZCH V1.0

Do you also have this Problem? Is there any way to ignore these messages? Because they keep popping up in the web-ui.

Also I have a question about the parameters. My circuit breaker is labeled as a 230V 16A 1p. Now there are these two parameters: threshold_1 and threshold_2. Do they mean, when the circuit will break? If so, then it seems to be wrong for mine, because mine is set to:

{
    "current": 0,
    "energy": 0,
    "last_seen": "2023-02-06T20:07:00+01:00",
    "linkquality": 123,
    "power": 0,
    "state": "OFF",
    "threshold1_value": 30,
    "threshold2_value": 0,
    "voltage": 232.3
}

Which would mean 30A...? Or what does this threshold mean?

thomas-schwieters avatar Feb 06 '23 19:02 thomas-schwieters

{
    "current": 0,
    "energy": 0,
    "last_seen": "2023-02-06T20:07:00+01:00",
    "linkquality": 123,
    "power": 0,
    "state": "OFF",
    "threshold1_value": 30,
    "threshold2_value": 0,
    "voltage": 232.3
}

Which would mean 30A...? Or what does this threshold mean?

hello, wouldn't the 30 be rather the 30mA protection?

image

I also have this module, I can't wait for it to be available to control my hot water tank

skillix avatar Mar 02 '23 08:03 skillix

Не появилось решение? у меня так же эта ошибка.

ZHNovell avatar Mar 03 '23 20:03 ZHNovell

hello i've the same circuit breaker. using avtomat.txt seems to works fine but i've a lot of "info" logs MQTT publish: topic 'zigbee2mqtt/Prese Allarme', payload '{"clear_fault":null,"current":0.09,"device":{"applicationVersion":70,"dateCode":"","friendlyName":"Prese Allarme","hardwareVersion":1,"ieeeAddr":"0x84b4dbfffec09000","manufacturerID":4098,"manufacturerName":"_TZE204_davzgqq0","model":"TS0601_din_2","networkAddress":38706,"powerSource":"Mains (single phase)","stackVersion":0,"type":"Router","zclVersion":3},"energy":0.99,"fault":null,"linkquality":168,"meter_id":

what does it means?

timewolf avatar Mar 05 '23 23:03 timewolf

Hello, I also have this device (EARU EAYCBM-Z-2P) , I can test your solution if necessary)

kva4991 avatar Mar 07 '23 11:03 kva4991

I have the same relay. They helped me, they wrote a converter, but they settled on voltage and current values ​​\u200b\u200bthat cannot be recorded. Here is my converter, maybe it will help to complete the work. Снимок экрана 2023-03-13 120002 Снимок экрана 2023-03-13 120014 const exposes = require('zigbee-herdsman-converters/lib/exposes'); const fz = {...require('zigbee-herdsman-converters/converters/fromZigbee'), legacy: require('zigbee-herdsman-converters/lib/legacy').fromZigbee}; const tz = require('zigbee-herdsman-converters/converters/toZigbee'); const ota = require('zigbee-herdsman-converters/lib/ota'); const tuya = require('zigbee-herdsman-converters/lib/tuya'); const reporting = require('zigbee-herdsman-converters/lib/reporting'); const extend = require('zigbee-herdsman-converters/lib/extend'); const e = exposes.presets; const ea = exposes.access; const libColor = require('zigbee-herdsman-converters/lib/color'); const utils = require('zigbee-herdsman-converters/lib/utils'); const zosung = require('zigbee-herdsman-converters/lib/zosung'); const fzZosung = zosung.fzZosung; const tzZosung = zosung.tzZosung; const ez = zosung.presetsZosung; const globalStore = require('zigbee-herdsman-converters/lib/store'); const {Buffer} = require('buffer');

//function thresholdParser(v, statusLookup, stateLookup) { // const buffer = Buffer.from(v, 'base64'); // return { // status: tuya.valueConverterBasic.lookup(statusLookup).from(buffer[0]), // state: tuya.valueConverterBasic.lookup(stateLookup).from(buffer[1]), // value: (buffer[3] | buffer[2] << 8), // }; //}

const valueConverter = { ...tuya.valueConverter, thresholdVariant1: (statusLookup, stateLookup) => { return { from: (v, meta) => { const buffer = Buffer.from(v, 'base64'); meta.logger.debug(TEST2: ${JSON.stringify(buffer)}); return { status: buffer[0],//tuya.valueConverterBasic.lookup(statusLookup).from(buffer[0]), state: buffer[1],//tuya.valueConverterBasic.lookup(stateLookup).from(buffer[1]), value: (buffer[3] | buffer[2] << 8), }; }, to: (v) => { const payload = []; payload.push(/tuya.valueConverterBasic.lookup(statusLookup).to(v.status)/v.status); payload.push(/tuya.valueConverterBasic.lookup(stateLookup).to(v.state)/v.state); payload.push(...tuya.convertDecimalValueTo2ByteHexArray(v.value)); return payload; }, }; }, thresholdVariant2: (names, statusLookup, stateLookup) => { return { from: (v, meta) => { const thresholds = {}; const chunkSize = 4; meta.logger.debug(TEST0: ${JSON.stringify(v)}); for (const [i, name] of Object.entries(names)) { const idx = i * chunkSize; const thresholdPayload = v.slice(idx, idx + chunkSize); meta.logger.debug(TEST1: name: ${name}, idx: ${idx}, payload: ${JSON.stringify(thresholdPayload)}); thresholds[${name}_threshold] = valueConverter.thresholdVariant1(statusLookup, stateLookup).from(thresholdPayload, meta); } return thresholds; }, to: (v) => { const payload = []; for (const threshold of Object.values(v)) payload.push(...valueConverter.thresholdVariant1(statusLookup, stateLookup).to(threshold)); return payload; } }; }, };

const tzDataPoints = { ...tuya.tz.datapoints, key: [ 'state', 'energy', 'breaker_id', 'voltage', 'current', 'power', 'status', 'value', 'thresholds', 'leakage_threshold', 'overcurrent_threshold', 'overvoltage_threshold', 'undervoltage_threshold', ], };

const definition = { fingerprint: tuya.fingerprint('TS0601', ['_TZE204_davzgqq0']), model: 'TS0601_din_1', vendor: 'TuYa', description: 'Zigbee DIN relay', fromZigbee: [tuya.fz.datapoints], toZigbee: [tzDataPoints], configure: tuya.configureMagicPacket, exposes: [tuya.exposes.switch(), e.energy(), e.power(), e.voltage(), e.current(), exposes.composite('Leakage threshold', 'leakage_threshold', ea.STATE) .withFeature(exposes.switch().withState('state', true, 'Toggle leakage threshold alarm', ea.STATE_SET)) .withFeature(exposes.numeric('value', ea.STATE).withUnit('mA').withDescription('Value of trigger for leakage threshold')) .withDescription('Works only on 2P device'), exposes.composite('Thresholds', 'thresholds', ea.STATE_SET) .withFeature(exposes.composite('Overcurrent threshold', 'overcurrent_threshold', ea.STATE) .withFeature(exposes.switch().withState('state', true, 'Toggle overcurrent threshold alarm', ea.STATE_SET)) .withFeature(exposes.numeric('value', ea.STATE_SET).withUnit('A').withValueMax(63).withValueMin(10).withValueStep(1) .withPreset('default', 35, 'Default value').withDescription('Value of trigger for overcurrent threshold'))) .withFeature(exposes.composite('Overvoltage threshold', 'overvoltage_threshold', ea.STATE) .withFeature(exposes.switch().withState('state', true, 'Toggle overvoltage threshold alarm', ea.STATE_SET)) .withFeature(exposes.numeric('value', ea.STATE_SET).withUnit('V').withValueMax(400).withValueMin(1).withValueStep(1) .withPreset('default', 265, 'Default value').withDescription('Value of trigger for overvoltage threshold'))) .withFeature(exposes.composite('Undervoltage threshold', 'undervoltage_threshold', ea.STATE) .withFeature(exposes.switch().withState('state', true, 'Toggle undervoltage threshold alarm', ea.STATE_SET)) .withFeature(exposes.numeric('value', ea.STATE_SET).withUnit('V').withValueMax(300).withValueMin(50).withValueStep(1) .withPreset('default', 180, 'Default value').withDescription('Value of trigger for undervoltage threshold'))), exposes.text('breaker_id', ea.STATE).withDescription('Device identificator from manufacturer'), ], meta: { tuyaDatapoints: [ [1, 'energy', tuya.valueConverter.divideBy100], [6, null, tuya.valueConverter.phaseVariant2], [16, 'state', tuya.valueConverter.onOff], // {"type":"Buffer","data":[4,1,0,30]} - leakage enabled // {"type":"Buffer","data":[4,0,0,30]} - leakage disabled [17, 'leakage_threshold', valueConverter.thresholdVariant1({4: 4}, {'ON': 1, 'OFF': 0})], //[17, 'leakage_threshold', valueConverter.threshold2], // {"type":"Buffer","data":[1,1,0,30,3,0,0,250,4,0,0,150]} - overcurr enabled 30A | overvolt enabled 250V | undervolt enabled 150V // {"type":"Buffer","data":[1,0,0,21,3,0,0,250,4,0,0,150]} - overcurr disabled 21A | overvolt disabled 250V | undervolt disabled 150V [18, 'thresholds', valueConverter.thresholdVariant2(['overcurrent', 'overvoltage', 'undervoltage'], {1: 1, 3: 3, 4: 4}, {'ON': 1, 'OFF': 0})], //[18, 'overcurrent_threshold', valueConverter.thresholdVariant2([], {1: 1}, {'ON': 1, 'OFF': 0})], //[18, 'overvoltage_threshold', valueConverter.thresholdVariant2([], {3: 3}, {'ON': 1, 'OFF': 0})], //[18, 'undervoltage_threshold', valueConverter.thresholdVariant2([], {4: 4}, {'ON': 1, 'OFF': 0})], [19, 'breaker_id', tuya.valueConverter.raw], ], }, };

module.exports = definition;

Creo2005 avatar Mar 13 '23 10:03 Creo2005

Hello. Download converter file? What is flat above needs to be edited.

Avdeich avatar Mar 13 '23 19:03 Avdeich

Creo2005 https://github.com/Koenkk/zigbee2mqtt/issues/16118#issuecomment-1465844355 Hello. Your code gives me an error in the z2m logs, could you help me fix it, please? p.s.: I'm not good at programming) изображение изображение

kva4991 avatar Mar 14 '23 07:03 kva4991

Creo2005 #16118 (comment) Hello. Your code gives me an error in the z2m logs, could you help me fix it, please? p.s.: I'm not good at programming) изображение изображение

this is a test code for developers, it still needs to be finalized

Creo2005 avatar Mar 14 '23 07:03 Creo2005

@Creo2005 Can you post the working code?

lucasimons avatar Mar 15 '23 19:03 lucasimons

@Creo2005 Can you post the working code?

Sorry, no, this code started make a friend, but never finished. Maybe someone here can fix it :)

Creo2005 avatar Mar 15 '23 21:03 Creo2005

@VladimirTuzovGitHub can you adjust your code with the @Creo2005 's coda?

lucasimons avatar Mar 19 '23 19:03 lucasimons

What can I do to help debugging?

sash1024-cloud avatar Apr 11 '23 13:04 sash1024-cloud

Dear @Koenkk, What can I do to help debugging?

sash1024-cloud avatar Apr 12 '23 06:04 sash1024-cloud

Unfortunately, @Creo2005 copied/pasted the code instead of attaching it, so GitHub converted it using markdown and these automatic changes made the code unusable.

I took the liberty to un-markdown his code and attach it here _TZE204_davzgqq0.js.txt (remember to remove the .txt extension as GitHub didn't allow me to upload it directly as .js)

I have no idea how it works, but at least it doesn't produce any errors. Enjoy...

Now if only someone could build upon it to expose the switch about remembering the last state after a power failure, that would be sweet.

Saxtus avatar Apr 17 '23 08:04 Saxtus

Unfortunately, @Creo2005 copied/pasted the code instead of attaching it, so GitHub converted it using markdown and these automatic changes made the code unusable.

I took the liberty to un-markdown his code and attach it here _TZE204_davzgqq0.js.txt (remember to remove the .txt extension as GitHub didn't allow me to upload it directly as .js)

I have no idea how it works, but at least it doesn't produce any errors. Enjoy...

Now if only someone could build upon it to expose the switch about remembering the last state after a power failure, that would be sweet.

ts0601.js.zip Code in file.

Creo2005 avatar Apr 17 '23 08:04 Creo2005

I can confirm this JS kind of works, but getting errors

Exception while calling fromZigbee converter: Cannot read properties of undefined (reading 'power')}

and doesn't report any current or power consumption

scaytrase avatar May 10 '23 01:05 scaytrase

Add support pleaze.

TolianIPB avatar May 21 '23 18:05 TolianIPB

Did somebody find out the datapoints of this device? https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html

Koenkk avatar May 22 '23 14:05 Koenkk

Did somebody find out the datapoints of this device? https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html

https://github.com/zigpy/zha-device-handlers/issues/2061#issuecomment-1515908547

tuyaDatapoints: [ [1, 'energy', tuya.valueConverter.divideBy100], [6, null, tuya.valueConverter.phaseVariant2], [16, 'state', tuya.valueConverter.onOff], // {"type":"Buffer","data":[4,1,0,30]} - leakage enabled // {"type":"Buffer","data":[4,0,0,30]} - leakage disabled [17, 'leakage_threshold', valueConverter.thresholdVariant1({4: 4}, {'ON': 1, 'OFF': 0})], //[17, 'leakage_threshold', valueConverter.threshold2], // {"type":"Buffer","data":[1,1,0,30,3,0,0,250,4,0,0,150]} - overcurr enabled 30A | overvolt enabled 250V | undervolt enabled 150V // {"type":"Buffer","data":[1,0,0,21,3,0,0,250,4,0,0,150]} - overcurr disabled 21A | overvolt disabled 250V | undervolt disabled 150V [18, 'thresholds', valueConverter.thresholdVariant2(['overcurrent', 'overvoltage', 'undervoltage'], {1: 1, 3: 3, 4: 4}, {'ON': 1, 'OFF': 0})], //[18, 'overcurrent_threshold', valueConverter.thresholdVariant2([], {1: 1}, {'ON': 1, 'OFF': 0})], //[18, 'overvoltage_threshold', valueConverter.thresholdVariant2([], {3: 3}, {'ON': 1, 'OFF': 0})], //[18, 'undervoltage_threshold', valueConverter.thresholdVariant2([], {4: 4}, {'ON': 1, 'OFF': 0})], [19, 'breaker_id', tuya.valueConverter.raw], ],

oscrey avatar Jun 02 '23 17:06 oscrey

Unfortunately, @Creo2005 copied/pasted the code instead of attaching it, so GitHub converted it using markdown and these automatic changes made the code unusable. I took the liberty to un-markdown his code and attach it here _TZE204_davzgqq0.js.txt (remember to remove the .txt extension as GitHub didn't allow me to upload it directly as .js) I have no idea how it works, but at least it doesn't produce any errors. Enjoy... Now if only someone could build upon it to expose the switch about remembering the last state after a power failure, that would be sweet.

ts0601.js.zip Code in file.

Tested on EARU EAYCBM-Z-1P https://www.aliexpress.com/item/1005004894129906.html Power , Current , Voltage and sum of energy working perfectly. Ignored leakage alarm as it only supported on 2P devices.

Thanks

laplac avatar Jun 27 '23 08:06 laplac

@Koenkk Hi Koen, I love your work and effort you put into this !!!

I also have the TS0601_din_1 _TZE204_davzgqq0 device, and used the above ts0601.js as an external convertor. It works partly: the voltage, amps, power and on/off switch work fine.

The energy does not work, it keeps increasing even if the amps are 0. It looks like it has some kind of timer running that counts the seconds the breaker is switched ON. That timer resets every 12 hours. Maybe, the energy uses that timer to report a daily usage ?

Also, and that is what worries me: I can not switch on the overcurrent threshold alarm:

image

I can move the off/on switch, and click 'apply', but the next time I check the status, it is OFF again.

In the debug I see no change, the output stays like this:

2023-07-03 15:59:46Received Zigbee message from 'KookplaatFuse', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[1,0,0,24,3,0,1,144,4,0,0,50],"type":"Buffer"},"datatype":0,"dp":18}],"seq":60672}' from endpoint 1 with groupID 0

2023-07-03 15:59:46MQTT publish: topic 'zigbee2mqtt/KookplaatFuse', payload '{"breaker_id":"YKLD-ZCH V1.0","current":0,"energy":14.34,"leakage_threshold":{"state":1,"status":4,"value":30},"linkquality":66,"power":0,"state":"ON","thresholds":{"overcurrent_threshold":{"state":0,"status":1,"value":24},"overvoltage_threshold":{"state":0,"status":3,"value":400},"undervoltage_threshold":{"state":0,"status":4,"value":50}},"voltage":239.6}'

Now I'm afraid the breaker is not going to switch off, if more than 24Amps is running. that would result in a dangerous situation.

Please Help !!

meganiekje avatar Jul 03 '23 14:07 meganiekje

I just bought 2 of these devices (2 poles version) and so far it mostly works but here are a few issues.

Energy doesn't work.

on/off switch is sometimes unresponsive. switch state is not updated when you turn it off using the test function.

Setting the limits don't work.

jampez77 avatar Jul 05 '23 21:07 jampez77

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

github-actions[bot] avatar Aug 05 '23 00:08 github-actions[bot]

This problem is still present. It would be very nice if it can be fixed

meganiekje avatar Aug 05 '23 09:08 meganiekje

I manage to get state, energy, power, voltage and current to work. 1 But rest of the states do not work 2

I got the 2P Earu ZigBee Circuit Breaker, Model EAYCBM-Z-2P (I'm new to adding unsupported ZigBee units, so this is my first one)

Nordranei avatar Aug 08 '23 22:08 Nordranei