Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.22k stars 1.69k forks source link

[New device support]: TS0601_TZE284_cjbofhxw Electricity Energy Monitor #22627

Open tihonovsp opened 6 months ago

tihonovsp commented 6 months ago

Link

https://aliexpress.ru/item/1005005982564709.html?sku_id=12000035168648246

Database entry

{"id":15,"type":"Router","ieeeAddr":"0x842712fffe481c3e","nwkAddr":41105,"manufId":4098,"manufName":"_TZE284_cjbofhxw","powerSource":"Mains (single phase)","modelId":"TS0601","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[0,4,5,61184,0,60672],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65503":"\u000e��-i","65506":31,"65508":0,"65534":0,"modelId":"TS0601","manufacturerName":"_TZE284_cjbofhxw","powerSource":1,"zclVersion":3,"appVersion":74,"stackVersion":0,"hwVersion":1,"dateCode":""}}},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":74,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{"configured":332242049},"lastSeen":1715676501556}

Comments

There is a similar electric energy monitor, made on its basis (TZE204_cjbofhxw). Please add it. TZE284

External definition

const {} = require('zigbee-herdsman-converters/lib/modernExtend');
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 ota = require('zigbee-herdsman-converters/lib/ota');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const utils = require('zigbee-herdsman-converters/lib/utils');
const globalStore = require('zigbee-herdsman-converters/lib/store');
const e = exposes.presets;
const ea = exposes.access;

const fzLocal = {
    gateway_connection_status: {
        cluster: 'manuSpecificTuya',
        type: ['commandMcuGatewayConnectionStatus'],
        convert: async (model, msg, publish, options, meta) => {
            const payload = {payloadSize: 1,payload: 1}
            await msg.endpoint.command('manuSpecificTuya', 'mcuGatewayConnectionStatus', payload, {});
        },
    },
}

const definition = {
    zigbeeModel: ['TS0601'],
    model: 'PJ-1203-W',
    vendor: 'TuYa',
    description: 'Electricity Energy Monitor',
    extend: [],
    fromZigbee: [tuya.fz.datapoints, fzLocal.gateway_connection_status],
    toZigbee: [tuya.tz.datapoints],
    configure: tuya.configureMagicPacket,
    exposes: [e.current(), e.power(), e.voltage(), e.energy()],
    meta: {
                tuyaDatapoints: [
            [18, 'current', tuya.valueConverter.divideBy1000],
            [19, 'power', tuya.valueConverter.divideBy10],
            [20, 'voltage', tuya.valueConverter.divideBy10],
            [101, 'energy', tuya.valueConverter.divideBy1000],
        ],  
    },
};

module.exports = definition;
bman765 commented 6 months ago

Hi, I believe I have the same device and I tried this external converter, but I have the impression it's not picked up. The data is coming in, but it's not converted.

DB entry :

{"id":4,"type":"Router","ieeeAddr":"0x0cae5ffffef2419e","nwkAddr":53478,"manufId":4098,"manufName":"_TZE284_cjbofhxw","powerSource":"Mains (single phase)","modelId":"TS0601","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[0,4,5,61184,0,60672],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65503":"cw�-\u0013^?w�-e^?w�-\u0012�w�-\u0012","65506":31,"65508":0,"modelId":"TS0601","manufacturerName":"_TZE284_cjbofhxw","stackVersion":0,"dateCode":"","appVersion":74}}},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":74,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1715774420235}

This exact code works for you ?

tihonovsp commented 6 months ago

1 2 Yes, the code that I posted above works with it

bman765 commented 6 months ago

Hi, thank you, it does work indeed. I did have to include the external_converter from the GUI however. When I added it in the configuration.yaml directly it was not picked up, even though that should also work and I do make changes in this way too.

There is something not OK with this energy meter however : the "Energy" counter does not count the total kWh that is measured. In my case it hovers at 0,42 constantly, even though the measured heat pump continues to consume (a lot of) energy.

I have contacted the seller.

tihonovsp commented 6 months ago

I'm still testing, so I can't say anything about the accuracy of the measurement. If you find out any new information about this device, please let us know.

bman765 commented 6 months ago

Hi, where does the datapoint mapping come from ? Or the "energy" mapping is wrong, or my device is broken.

EM01 is the "energy" kWh of the device in this issue. The EM02 is a similar EM with 2 clamps that I connected in parallel. As far as I see, the EM02 does add up the used Watts, but the EM01 does not. Hence my conclusion that this device is broken, or the datapoint mapping is wrong.

image

        [18, 'current', tuya.valueConverter.divideBy1000],
        [19, 'power', tuya.valueConverter.divideBy10],
        [20, 'voltage', tuya.valueConverter.divideBy10],
        [101, 'energy', tuya.valueConverter.divideBy1000],  -> ???
tihonovsp commented 6 months ago

I took as a basis the data from this post https://github.com/Koenkk/zigbee2mqtt/issues/15359 Where did it come from [101, 'energy', tuya.valueConverter.divideBy1000], I don't know

dermotos commented 6 months ago

Thank you for this configuration. I've tested it on this device as an external configuration and it works. I'm not getting any data for "energy", however the power metering seems to be pretty close to what I'm expecting. Testing a toaster rated at 1700W reports a value of around 1715W from this device.

julienrat commented 6 months ago

Excellent ! do you know how to add this device to ZHA? Via ZHA quirks for example ?

kappa85 commented 6 months ago

Thank you for the config, it works but the power reported in my case is not reliable. I compared it with a Shelly 2PM and a LCD power meter (that are reporting the same power) and this one is quite different... 190W vs. 160W

kauczu commented 6 months ago

Thank you for the config, it works but the power reported in my case is not reliable. I compared it with a Shelly 2PM and a LCD power meter (that are reporting the same power) and this one is quite different... 190W vs. 160W

I have similar experiences with this device. I tested this device with @tihonovsp external definition on main line and it reported about 2,4 kWh power consumption per day, when actually it was about 5 kWh. So it is ... quite not reliable. I wonder if it's software or hardware related problem...

kisjeth commented 6 months ago

I also have this device and I don't understand how to add it. Everything I get when I ask for the external definition Is:

const definition = {
    zigbeeModel: ['TS0601'],
    model: 'TS0601',
    vendor: '_TZE284_cjbofhxw',
    description: 'Automatically generated definition',
    extend: [],
    meta: {},
};

module.exports = definition;

I'm not familiar with it, what should I do?

zibijw23 commented 6 months ago

Hello I have the external converter set according to the code from the first post and it does not recognize the device. I have this message in the logs: [2024-05-28 11:58:49] error: z2m: Failed to load external converter file '_TZE284_cjbofhxw.js' (ENOENT: no such file or directory, open '/zigbee2mqtt/_TZE284_cjbofhxw.js') [2024-05-28 11:58:49] error: z2m: Probably there is a syntax error in the file or the external converter is not compatible with the current Zigbee2MQTT version [2024-05-28 11:58:49] error: z2m: Note that external converters are not meant for long term usage, it's meant for local testing after which a pull request should be created to add out-of-the-box support for the device

Rom1889 commented 5 months ago

Hello, I have the same device, and I cannot integrate it with z2m in HA.

How to integrate it?

Thanks a lot for your help !

kisjeth commented 5 months ago

Hello, I have the same device, and I cannot integrate it with z2m in HA.

How to integrate it?

Thanks a lot for your help !

Wait for the next update

speedycars commented 5 months ago

Hey, do you hear some sound coming out from this box like a really small siren? It's pretty annoying. Wondering if it's just mine, or if I connected it wrong or something... Otherwise it started working alright, although it seems to be spamming the Zigbee network with pointless updates every 1-5 seconds. Read about similar behavior in other TS0601-based devices.

To the fellows struggling with the external_convertor code: copy the code from the first post here, paste it in an empty .txt file (Notepad/Notepad++), save it, open "File Editor" in your Home Assistant, navigate to your Zigbee2MQTT directory, upload the .txt file created above, while in zigbee2mqtt directory open configuration.yaml file, and add the following at its end:

external_converters:
  - name_of_your_file_you_ve_just_uploaded_just_the_name_with_the_file_extension

Save the configuration.yaml file (CTRL+S), and finally restart the Zigbee2MQTT add-on. If this doesn't help, please feel free to wait until July 1st. :)

nkaliev commented 5 months ago

@tihonovsp thank you, i have this energy monitor and your external definition works good! @Koenkk can we add it to z2m? need to do pull request?

Koenkk commented 4 months ago

@nkaliev if we have a working converter I can add it

thomasgermain commented 4 months ago

Hi there,

I'm testing the converter, looks like power is corret, but energy looks strange, see what I get in HA:

Power: image

Energy: image

-> I'm expecting the total_increasing entity for energy -> Energy is wrong, my device consume arround 30 Watt, so I'm expecting ~ 0.03 kWh. Do I have to calibrate the device ? Or is there an issue with the converter ?

nkaliev commented 4 months ago

Energy is wrong, my device consume arround 30 Watt, so I'm expecting ~ 0.03 kWh.

i think energy is not just power divided by 1000, its more complicated thing that relates on power, load duration, it's like electricity meter.

nkaliev commented 4 months ago

@nkaliev if we have a working converter I can add it

i'll do more tests due comment above and then give you an answer🙏

pmlkaovs commented 2 months ago

Excellent ! do you know how to add this device to ZHA? Via ZHA quirks for example ?

Hello. Have you managed to add this device to ZHA?

julienrat commented 2 months ago

No sorry !Ce mail a été composé rapidement depuis mon mobile. À très bientôt !"Le 11 sept. 2024 09:50, pmlkaovs @.***> a écrit :

Excellent ! do you know how to add this device to ZHA? Via ZHA quirks for example ?

Hello. Have you managed to add this device to ZHA?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>