Koenkk / zigbee2mqtt

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

[New device support]: Smart water level meter TLC2206 zigbee #22543

Open TonioClos opened 1 month ago

TonioClos commented 1 month ago

Link

https://es.aliexpress.com/item/1005006395402636.html?gatewayAdapt=glo2esp

Database entry

{"id":66,"type":"EndDevice","ieeeAddr":"0x0ceff6fffe4bdda2","nwkAddr":39698,"manufId":4098,"manufName":"_TZE200_lvkk0hdg","powerSource":"Battery","modelId":"TS0601","epList":[1],"endpoints":{"1":{"profId":260,"epId":1,"devId":81,"inClusterList":[0,4,5,61184],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65503":"�ME-\u0019%NE-\u0019aNE-j�NE-j\u000fPE-j�KE-j�KE-\u0019>LE-i","65506":31,"65508":0,"65534":0,"appVersion":65,"modelId":"TS0601","manufacturerName":"_TZE200_lvkk0hdg","powerSource":3,"zclVersion":3,"stackVersion":0,"hwVersion":1,"dateCode":""}}},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":65,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{"configured":-708457359},"lastSeen":1706198663760,"defaultSendRequestWhen":"immediate"}

I took it from the other post too #21015

Comments

I tried following the guideline to add a new device and using the external definition another guy did in this post #21015 but anything seems to work now. I had it at least supported but without any funtion working or showing in HA, I had another device configured following the guideline for tuya devices in https://www.zigbee2mqtt.io/advanced/support-new-devices/02_support_new_tuya_devices.html and at least shows the data I need but not all the data. I have two questions in here:

Sorry if I made mistakes with my english and for been new to programming, maybe many things can be found easier than I think. Thank you so much in advance with any help given by the community and everyone n_n Edit 1 Totally stuck because it's not even showing as supported but in the logs of z2m shows some info about the device, but can't get to support the device even if before the update was supported, any help on this will be really wlecome

External definition

//BAsically a combination of the code that it's working on the other device, the oficial documentation of Z2M and
//the post mentioned in the comments

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

const definition = {
    // Since a lot of TuYa devices use the same modelID, but use different datapoints
    // it's necessary to provide a fingerprint instead of a zigbeeModel
    fingerprint: [
        {
            // The model ID from: Device with modelID 'TS0601' is not supported
            // You may need to add \u0000 at the end of the name in some cases
            modelID: 'TS0601',
            // The manufacturer name from: Device with modelID 'TS0601' is not supported.
            manufacturerName: '_TZE200_lvkk0hdg',
        },
    ],
    model: 'TYZS3-IPEX',
    vendor: 'TuYa',
    whiteLabel: [
        {
          vendor: 'EPTTECH',
          model: 'TLC2206-ZB',
        },
      ],
description: 'EPTTECH Tank Level Monitor Zigbee',
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
onEvent: tuya.onEventSetTime,
configure: tuya.configureMagicPacket,
exposes: [
  e.numeric('liquid_level_percent', ea.STATE)
    .withUnit('%')
    .withDescription('Liquid level percentage'),
  e.numeric('liquid_depth', ea.STATE)
    .withUnit('m')
    .withDescription('Liquid Depth'),
  e.enum('liquid_state', ea.STATE, ['low', 'normal', 'high'])
    .withDescription('Liquid State'),
  // =============== Found but non functional ===============
  /*
  e.numeric('max_set', ea.STATE_SET)
    .withUnit('%')
    .withDescription('Liquid max percentage')
    .withValueMin(0)
    .withValueMax(100)
    .withValueStep(1),
  e.numeric('mini_set', ea.STATE_SET)
    .withUnit('%')
    .withDescription('Liquid minimal percentage')
    .withValueMin(0)
    .withValueMax(100)
    .withValueStep(1),
  e.numeric('installation_height', ea.STATE_SET)
    .withUnit('mm')
    .withDescription('Height from sensor to tank bottom')
    .withValueMin(100)
    .withValueMax(2500)
    .withValueStep(1),
  e.numeric('liquid_depth_max', ea.STATE_SET)
    .withUnit('mm')
    .withDescription('Height from sensor to liquid level')
    .withValueMin(100)
    .withValueMax(1000)
    .withValueStep(1),
  */
],
meta: {
  tuyaDatapoints: [
    [1, 'liquid_state', tuya.valueConverterBasic.lookup({'low': 1, 'normal': 0, 'high': 2})],
    [2, 'liquid_depth', tuya.valueConverter.divideBy100],
    [22, 'liquid_level_percent', tuya.valueConverter.raw],
    // =============== Found but non functional ===============
    /*
    [7, 'max_set', tuya.valueConverter.raw],
    [8, 'mini_set', tuya.valueConverter.raw],
    [19, 'installation_height', tuya.valueConverter.raw],
    [21, 'liquid_depth_max', tuya.valueConverter.raw],
    */
  ],
},
};

module.exports = definition;
TonioClos commented 1 month ago

@Koenkk any opportunity to at least know why is it not even showing as supported even with the code that the documentation shows?

Koenkk commented 4 weeks ago

Probably the external converter fails to load due to a syntax error, this will be logged at z2m startup. Look for Failed to load external converter file

TonioClos commented 2 weeks ago

This was completed on the original post, that reactivated and a really nice guy completed the code and works fine. Here the link and mention the post #21015. thanks @Koenkk for helping me and @gregorobreza for the code :D