Koenkk / zigbee2mqtt

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

[New device support]: Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL- _TZE200_v1jqz5cy #18704

Open cloudbr34k84 opened 1 year ago

cloudbr34k84 commented 1 year ago

Link

https://www.aliexpress.com/item/1005005575336871.html?spm=a2g0o.order_list.order_list_main.11.28e31802Wxn6Wl

Database entry

{"id":115,"type":"EndDevice","ieeeAddr":"0xe0798dfffeb87446","nwkAddr":42479,"manufId":4098,"manufName":"_TZE200_v1jqz5cy","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":"\u00195y,f\u00195y,\u0012\u001a5y,\u0012\u001e5y,\u0011\"5y,\u0011","65506":31,"65508":0,"appVersion":65,"modelId":"TS0601","manufacturerName":"_TZE200_v1jqz5cy","stackVersion":0,"dateCode":""}}},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":65,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{},"lastSeen":1692789799130,"defaultSendRequestWhen":"immediate"}

Comments

Would someone be willing to make a converter> here are the Data Points

1: TDS 2: temperature 101: ORP 102: CL 7: Battery Percentage 105: backlight Value 10: ph Value 11: EC Value 108: EC Max Value 109: EC Min Value 110: ORP max 111: ORP min 112: CL Max Value 113: CL Min Value 114: PH?? 115: EC?? 116: ORP?? 117: Salt

External converter

No response

Supported color modes

No response

Color temperature range

No response

cloudbr34k84 commented 1 year ago

im giving it a crack

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 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: 'BLE-YL01',
            // The manufacturer name from: Device with modelID 'TS0601' is not supported.
            manufacturerName: 'TZE200_v1jqz5cy',
        },
    ],
    model: 'WiFi Chlorine Meter BLE-YL01',
    vendor: 'yieryi',
    description: 'Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered',
    fromZigbee: [tuya.fz.datapoints, tuya.fz.gateway_connection_status],
    toZigbee: [tuya.tz.datapoints],
    onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime'
    configure: tuya.configureMagicPacket,
    exposes: [
        e.tds(),
        e.temperature()
        e.orp()
        e.cl()
        e.batterypercentage()
        e.backlightvalue()
        e.pHvalue()
        e.ecvalue()
        e.ecmaxvalue()
        e.ecminvalue()
        e.orpmaxvalue()
        e.orpminvalue()
        e.clmaxvalue()
        e.clminvalue()
        e.salt()
        // Here you should put all functionality that your device exposes
    ],
    meta: {
        // All datapoints go in here
        tuyaDatapoints: [
            [1, 'tds', tuya.valueConverter.raw],
            [2, 'temperature', tuya.valueConverter.raw.divideBy10],
            [101, 'orp', tuya.valueConverter.raw],
            [102, 'cl', tuya.valueConverter.raw],
            [7, 'batterypercentage', tuya.valueConverter.raw],
            [105, 'backlightvalue', tuya.valueConverter.raw],
            [10, 'pHvalue', tuya.valueConverter.raw],
            [11, 'ecvalue', tuya.valueConverter.raw],
            [108, 'ecmaxvalue', tuya.valueConverter.raw],
            [109, 'ecminvalue', tuya.valueConverter.raw],
            [110, 'orpmaxvalue', tuya.valueConverter.raw],
            [111, 'orpminvalue', tuya.valueConverter.raw],
            [112, 'clmaxvalue', tuya.valueConverter.raw],
            [113, 'clminvalue', tuya.valueConverter.raw],
            [117, 'salt', tuya.valueConverter.raw],

        ],
    },
};

module.exports = definition;

Gor my first error

[09:44:12] INFO: Preparing to start...
[09:44:13] INFO: Socat not enabled
[09:44:13] INFO: Starting Zigbee2MQTT...
/app/data/extension/externally-loaded.js:30
        e.tds(),
          ^
TypeError: e.tds is not a function
    at /app/data/extension/externally-loaded.js:30:11
    at Script.runInContext (node:vm:141:12)
    at Script.runInNewContext (node:vm:146:17)
    at Object.runInNewContext (node:vm:306:38)
    at loadModuleFromText (/app/lib/util/utils.ts:152:8)
    at loadModuleFromFile (/app/lib/util/utils.ts:159:12)
    at Object.getExternalConvertersDefinitions (/app/lib/util/utils.ts:169:25)
    at getExternalConvertersDefinitions.next (<anonymous>)
    at new ExternalConverters (/app/lib/extension/externalConverters.ts:12:20)
    at new Controller (/app/lib/controller.ts:84:58)
cloudbr34k84 commented 1 year ago

@Koenkk where is a list of the supported datapoints?

Koenkk commented 1 year ago

Here is a list of all standard exposes, but you can easily create new ones: example

mochitoju commented 1 year ago

Is the device already available in z2m or hast anybody a solution?

cloudbr34k84 commented 1 year ago

no its not, i dont know what im doing lol

cloudbr34k84 commented 1 year ago

Here is a list of all standard exposes, but you can easily create new ones: example

thanks but I don't really know what im looking for

tschiex commented 1 year ago

I just got the very same device here, connected to my Home Assistant server, through ZHA. I would be happy to help here. I can write code, but am a ZigBee/Z2MQTT/ZHA newbie...

@cloudbr34k84 Brad, how did you get the Data Points?

cloudbr34k84 commented 1 year ago

i follow the the instructions on Z2M https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html

On Thu, 7 Sept 2023 at 05:44, Thomas Schiex @.***> wrote:

I just got the very same device here, connected to my Home Assistant server, through ZHA. I would be happy to help here. I can write code, but am a ZigBee/Z2MQTT/ZHA newbie...

@cloudbr34k84 https://github.com/cloudbr34k84 Brad, how did you get the Data Points?

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

cloudbr34k84 commented 1 year ago

@Koenkk any chance you can help create the converter pls?

mochitoju commented 1 year ago

Yes, that would bei great!

Freev4lley commented 1 year ago

That would be great for me too!!!

Koenkk commented 1 year ago

With the following ext converter, what shows up in the z2m frontend -> device -> state page?

https://gist.github.com/Koenkk/7262a8a36bb84327ff563e0b8256024b

tschiex commented 1 year ago

Sorry Koenkk, I don't have Z2M installed on HA, but ZHA. Is it easy to switch back and forth?

BTW, I bought a Tuya Gateway and followed the instructions on Z2M https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html

and found more DP Ids:

1: TDS 2: Temperature 101: ORP 102: Chlorine 7: Battery Percentage 103: pH Calibration 104: Backlight 105: Backlight Value 10: pH Value 11: EC Value 106: pH Max Value 107: pH Min Value 108: EC Max Value 109: EC Min Value 110: ORP Max Value 111: ORP Min Value 112: Chlorine Max Value 113: Chlorine Min Value 114: PH Calibration 115: EC Calibration 116: ORP Calibration 117: Salt

(Translation of Chinese by Google Translate camera from Tuya IoT platform website).

There are apparently 2 pH calibration DP Ids (and there are 2 pH calibration standards: Asia uses 6.86/4.00/9.18, EU uses 7/4/10). The two pH calibration DPs could be these 2 maybe?

I was told the device apparently works on deconz: https://forum.phoscon.de/t/tuya-tze200-v1jqz5cy-zigbee-chlorine-meter/3930 (see https://github.com/zigpy/zha-device-handlers/issues/2565).

and here: dresden-elektronik/deconz-rest-plugin#7215

cloudbr34k84 commented 1 year ago

With the following ext converter, what shows up in the z2m frontend -> device -> state page?

https://gist.github.com/Koenkk/7262a8a36bb84327ff563e0b8256024b Nothing shows except Linkquality image

info  2023-09-11 09:30:42: Device '**0xdc8e95fffe832b2f**' joined
info  2023-09-11 09:30:43: MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"friendly_name":"**0xdc8e95fffe832b2f**","ieee_address":"**0xdc8e95fffe832b2f**"},"type":"device_joined"}'
info  2023-09-11 09:30:43: MQTT publish: topic 'zigbee2mqtt/**0xdc8e95fffe832b2f**/availability', payload '{"state":"online"}'
info  2023-09-11 09:30:43: Starting interview of '0xdc8e95fffe832b2f'
info  2023-09-11 09:30:43: MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"friendly_name":"**0xdc8e95fffe832b2f**","ieee_address":"0xdc8e95fffe832b2f","status":"started"},"type":"device_interview"}'
info  2023-09-11 09:30:43: MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"friendly_name":"0xdc8e95fffe832b2f","ieee_address":"0xdc8e95fffe832b2f"},"type":"device_announce"}'
info  2023-09-11 09:30:47: MQTT publish: topic 'zigbee2mqtt/Front Patio EM GPO', payload '{"current_left":0,"energy":0,"linkquality":21,"power_left":0,"state_left":"ON","state_right":"ON","voltage_left":246}'
info  2023-09-11 09:30:47: MQTT publish: topic 'zigbee2mqtt/Hot Water System EM Clamp', payload '{"current":2.3,"energy":0.17,"linkquality":83,"power":566.6,"voltage":248.7}'
info  2023-09-11 09:30:47: MQTT publish: topic 'zigbee2mqtt/Garage Door', payload '{"garage_door_contact":true,"linkquality":94,"trigger":false}'
info  2023-09-11 09:30:48: Successfully interviewed '0xdc8e95fffe832b2f', device has successfully been paired
warn  2023-09-11 09:30:48: Device '0xdc8e95fffe832b2f' with Zigbee model 'TS0601' and manufacturer name '_TZE200_v1jqz5cy' is NOT supported, please follow https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html
info  2023-09-11 09:30:48: MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"definition":null,"friendly_name":"0xdc8e95fffe832b2f","ieee_address":"0xdc8e95fffe832b2f","status":"successful","supported":false},"type":"device_interview"}'
warn  2023-09-11 09:30:48: Received message from unsupported device with Zigbee model 'TS0601' and manufacturer name '_TZE200_v1jqz5cy'
warn  2023-09-11 09:30:48: Please see: https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html
warn  2023-09-11 09:30:49: Received message from unsupported device with Zigbee model 'TS0601' and manufacturer name '_TZE200_v1jqz5cy'
warn  2023-09-11 09:30:49: Please see: https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html
tschiex commented 1 year ago

Brad,

I'm not a Z2M specialist, but the fact that Z2M says:

warn 2023-09-11 09:30:48: Device '0xdc8e95fffe832b2f' with Zigbee model 'TS0601' and manufacturer name '_TZE200_v1jqz5cy' is NOT supported, please follow https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html

may be a hint that Koenkk's handler above is not accessible to Zigbee2MQTT in your setup.

tschiex commented 1 year ago

Or may be the handler is wrong.... Looking into it, I see:

    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: 'BLE-YL01',
            // The manufacturer name from: Device with modelID 'TS0601' is not supported.
            manufacturerName: 'TZE200_v1jqz5cy',
        },
    ],

I assume the modelId is important for recognizing the device?

Because it reports 'TS0601' not 'BLE-YL01'.

Brad, I suppose you should edit Koenkk's script and replace the

            modelID: 'BLE-YL01',

by

            modelID: 'TS0601',
BabaIsYou commented 1 year ago

I was told the device apparently works on deconz: https://forum.phoscon.de/t/tuya-tze200-v1jqz5cy-zigbee-chlorine-meter/3930 (see zigpy/zha-device-handlers#2565).

It's a wok in progress ... ;-)

Koenkk commented 1 year ago

Made a mistake, updated https://gist.github.com/Koenkk/7262a8a36bb84327ff563e0b8256024b

cloudbr34k84 commented 1 year ago

Made a mistake, updated https://gist.github.com/Koenkk/7262a8a36bb84327ff563e0b8256024b

Hey @Koenkk Thanks, its now added correctly, but it has not exposed any entities

info  2023-09-12 07:44:57: Successfully interviewed '0xdc8e95fffe832b2f', device has successfully been paired
info  2023-09-12 07:44:57: Device '0xdc8e95fffe832b2f' is supported, identified as: yieryi Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered (WiFi Chlorine Meter BLE-YL01)
info  2023-09-12 07:44:57: MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"definition":{"description":"Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered","exposes":[{"access":1,"description":"Link quality (signal strength)","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi","value_max":255,"value_min":0}],"model":"WiFi Chlorine Meter BLE-YL01","options":[{"access":2,"description":"Number of digits after decimal point for temperature, takes into effect on next report of device.","name":"temperature_precision","property":"temperature_precision","type":"numeric","value_max":3,"value_min":0},{"access":2,"description":"Calibrates the temperature value (absolute offset), takes into effect on next report of device.","name":"temperature_calibration","property":"temperature_calibration","type":"numeric"}],"supports_ota":false,"vendor":"yieryi"},"friendly_name":"0xdc8e95fffe832b2f","ieee_address":"0xdc8e95fffe832b2f","status":"successful","supported":true},"type":"device_interview"}'
info  2023-09-12 07:44:57: Configuring '0xdc8e95fffe832b2f'
info  2023-09-12 07:44:57: Successfully configured '0xdc8e95fffe832b2f'
alray31 commented 1 year ago

Made a mistake, updated https://gist.github.com/Koenkk/7262a8a36bb84327ff563e0b8256024b

Hey @Koenkk Thanks, its now added correctly, but it has not exposed any entities

info  2023-09-12 07:44:57: Successfully interviewed '0xdc8e95fffe832b2f', device has successfully been paired
info  2023-09-12 07:44:57: Device '0xdc8e95fffe832b2f' is supported, identified as: yieryi Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered (WiFi Chlorine Meter BLE-YL01)
info  2023-09-12 07:44:57: MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"definition":{"description":"Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered","exposes":[{"access":1,"description":"Link quality (signal strength)","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi","value_max":255,"value_min":0}],"model":"WiFi Chlorine Meter BLE-YL01","options":[{"access":2,"description":"Number of digits after decimal point for temperature, takes into effect on next report of device.","name":"temperature_precision","property":"temperature_precision","type":"numeric","value_max":3,"value_min":0},{"access":2,"description":"Calibrates the temperature value (absolute offset), takes into effect on next report of device.","name":"temperature_calibration","property":"temperature_calibration","type":"numeric"}],"supports_ota":false,"vendor":"yieryi"},"friendly_name":"0xdc8e95fffe832b2f","ieee_address":"0xdc8e95fffe832b2f","status":"successful","supported":true},"type":"device_interview"}'
info  2023-09-12 07:44:57: Configuring '0xdc8e95fffe832b2f'
info  2023-09-12 07:44:57: Successfully configured '0xdc8e95fffe832b2f'

I'm not an expert but if you look at the other tuya converters that are using datapoints in zigbee-herdsman-convert/src/devices/tuya.ts, you also need to add the corresponding entries in the expose section, i.e.: exposes: [e.tds, e.temperature, etc...

example: image

So maybe try this? :

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 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_v1jqz5cy',
        },
    ],
    model: 'WiFi Chlorine Meter BLE-YL01',
    vendor: 'yieryi',
    description: 'Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered',
    fromZigbee: [tuya.fz.datapoints, tuya.fz.gateway_connection_status],
    toZigbee: [tuya.tz.datapoints],
    onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime'
    configure: tuya.configureMagicPacket,
    exposes: [e.tds(), e.temperature(), e.orp(), e.cl(), e.batterypercentage(), e.backlightvalue(), e.pHvalue(), e.ecvalue(), e.ecmaxvalue(), e.orpmaxvalue(), e.orpminvalue(), e.clmaxvalue(), e.clminvalue(), e.salt()],
    meta: {
        // All datapoints go in here
        tuyaDatapoints: [
            [1, 'tds', tuya.valueConverter.raw],
            [2, 'temperature', tuya.valueConverter.raw.divideBy10],
            [101, 'orp', tuya.valueConverter.raw],
            [102, 'cl', tuya.valueConverter.raw],
            [7, 'batterypercentage', tuya.valueConverter.raw],
            [105, 'backlightvalue', tuya.valueConverter.raw],
            [10, 'pHvalue', tuya.valueConverter.raw],
            [11, 'ecvalue', tuya.valueConverter.raw],
            [108, 'ecmaxvalue', tuya.valueConverter.raw],
            [109, 'ecminvalue', tuya.valueConverter.raw],
            [110, 'orpmaxvalue', tuya.valueConverter.raw],
            [111, 'orpminvalue', tuya.valueConverter.raw],
            [112, 'clmaxvalue', tuya.valueConverter.raw],
            [113, 'clminvalue', tuya.valueConverter.raw],
            [117, 'salt', tuya.valueConverter.raw],

        ],
    },
};

module.exports = definition;
Koenkk commented 1 year ago

Please make a screenshot of the z2m frontend -> device page -> state page?

cloudbr34k84 commented 1 year ago

Please make a screenshot of the z2m frontend -> device page -> state page?

@Koenkk Screenshot_20230914-044527.png

Koenkk commented 1 year ago

With the following converter: https://gist.github.com/Koenkk/7262a8a36bb84327ff563e0b8256024b , can you provide the debug log when pairing the device + 5 minutes after this?

See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging.

cloudbr34k84 commented 1 year ago

With the following converter: https://gist.github.com/Koenkk/7262a8a36bb84327ff563e0b8256024b , can you provide the debug log when pairing the device + 5 minutes after this?

See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging.

Hey @Koenkk thanks for helping on this When I copy the new code and enable debugging and restart I get an error from the converter

[06:33:10] INFO: Preparing to start...
[06:33:10] INFO: Socat not enabled
[06:33:10] INFO: Zigbee Herdsman debug logging enabled
[06:33:10] INFO: Starting Zigbee2MQTT...
/app/data/extension/externally-loaded.js:27
    onEvent: tuya.onEvent(), // Add this if you are getting no converter for 'commandMcuSyncTime'
                  ^
TypeError: tuya.onEvent is not a function
    at /app/data/extension/externally-loaded.js:27:19
    at Script.runInContext (node:vm:141:12)
    at Script.runInNewContext (node:vm:146:17)
    at Object.runInNewContext (node:vm:306:38)
    at loadModuleFromText (/app/lib/util/utils.ts:152:8)
    at loadModuleFromFile (/app/lib/util/utils.ts:159:12)
    at Object.getExternalConvertersDefinitions (/app/lib/util/utils.ts:169:25)
    at getExternalConvertersDefinitions.next (<anonymous>)
    at new ExternalConverters (/app/lib/extension/externalConverters.ts:12:20)
    at new Controller (/app/lib/controller.ts:84:58)
Koenkk commented 1 year ago

I forgot to mention that this converter only works with the latest-dev branch. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

cloudbr34k84 commented 1 year ago

I forgot to mention that this converter only works with the latest-dev branch. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html) @Koenkk Ok so I have updated my Z2M Edge version - Zigbee2MQTT version 1.33.0-dev commit: 0a69bb5 I have deleted and re-added the device there are no entities in the State Tab except "linkquality": 87 log.txt

cloudbr34k84 commented 1 year ago

Made a mistake, updated https://gist.github.com/Koenkk/7262a8a36bb84327ff563e0b8256024b

Hey @Koenkk Thanks, its now added correctly, but it has not exposed any entities

info  2023-09-12 07:44:57: Successfully interviewed '0xdc8e95fffe832b2f', device has successfully been paired
info  2023-09-12 07:44:57: Device '0xdc8e95fffe832b2f' is supported, identified as: yieryi Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered (WiFi Chlorine Meter BLE-YL01)
info  2023-09-12 07:44:57: MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"definition":{"description":"Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered","exposes":[{"access":1,"description":"Link quality (signal strength)","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi","value_max":255,"value_min":0}],"model":"WiFi Chlorine Meter BLE-YL01","options":[{"access":2,"description":"Number of digits after decimal point for temperature, takes into effect on next report of device.","name":"temperature_precision","property":"temperature_precision","type":"numeric","value_max":3,"value_min":0},{"access":2,"description":"Calibrates the temperature value (absolute offset), takes into effect on next report of device.","name":"temperature_calibration","property":"temperature_calibration","type":"numeric"}],"supports_ota":false,"vendor":"yieryi"},"friendly_name":"0xdc8e95fffe832b2f","ieee_address":"0xdc8e95fffe832b2f","status":"successful","supported":true},"type":"device_interview"}'
info  2023-09-12 07:44:57: Configuring '0xdc8e95fffe832b2f'
info  2023-09-12 07:44:57: Successfully configured '0xdc8e95fffe832b2f'

I'm not an expert but if you look at the other tuya converters that are using datapoints in zigbee-herdsman-convert/src/devices/tuya.ts, you also need to add the corresponding entries in the expose section, i.e.: exposes: [e.tds, e.temperature, etc...

example: image

So maybe try this? :

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 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_v1jqz5cy',
        },
    ],
    model: 'WiFi Chlorine Meter BLE-YL01',
    vendor: 'yieryi',
    description: 'Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered',
    fromZigbee: [tuya.fz.datapoints, tuya.fz.gateway_connection_status],
    toZigbee: [tuya.tz.datapoints],
    onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime'
    configure: tuya.configureMagicPacket,
    exposes: [e.tds(), e.temperature(), e.orp(), e.cl(), e.batterypercentage(), e.backlightvalue(), e.pHvalue(), e.ecvalue(), e.ecmaxvalue(), e.orpmaxvalue(), e.orpminvalue(), e.clmaxvalue(), e.clminvalue(), e.salt()],
    meta: {
        // All datapoints go in here
        tuyaDatapoints: [
            [1, 'tds', tuya.valueConverter.raw],
            [2, 'temperature', tuya.valueConverter.raw.divideBy10],
            [101, 'orp', tuya.valueConverter.raw],
            [102, 'cl', tuya.valueConverter.raw],
            [7, 'batterypercentage', tuya.valueConverter.raw],
            [105, 'backlightvalue', tuya.valueConverter.raw],
            [10, 'pHvalue', tuya.valueConverter.raw],
            [11, 'ecvalue', tuya.valueConverter.raw],
            [108, 'ecmaxvalue', tuya.valueConverter.raw],
            [109, 'ecminvalue', tuya.valueConverter.raw],
            [110, 'orpmaxvalue', tuya.valueConverter.raw],
            [111, 'orpminvalue', tuya.valueConverter.raw],
            [112, 'clmaxvalue', tuya.valueConverter.raw],
            [113, 'clminvalue', tuya.valueConverter.raw],
            [117, 'salt', tuya.valueConverter.raw],

        ],
    },
};

module.exports = definition;

tried this, same issue as when I attempted. i don't understand how to create a new function

[08:30:22] INFO: Preparing to start... [08:30:22] INFO: Socat not enabled [08:30:23] INFO: Zigbee Herdsman debug logging enabled [08:30:23] INFO: Starting Zigbee2MQTT... /app/data/extension/externally-loaded.js:29 exposes: [e.tds(), e.temperature(), e.orp(), e.cl(), e.batterypercentage(), e.backlightvalue(), e.pHvalue(), e.ecvalue(), e.ecmaxvalue(), e.orpmaxvalue(), e.orpminvalue(), e.clmaxvalue(), e.clminvalue(), e.salt()], ^ TypeError: e.tds is not a function at /app/data/extension/externally-loaded.js:29:17 at Script.runInContext (node:vm:141:12) at Script.runInNewContext (node:vm:146:17) at Object.runInNewContext (node:vm:306:38) at loadModuleFromText (/app/lib/util/utils.ts:152:8) at loadModuleFromFile (/app/lib/util/utils.ts:159:12) at Object.getExternalConvertersDefinitions (/app/lib/util/utils.ts:169:25) at getExternalConvertersDefinitions.next (<anonymous>) at new ExternalConverters (/app/lib/extension/externalConverters.ts:12:20) at new Controller (/app/lib/controller.ts:84:58)

cloudbr34k84 commented 1 year ago

@Koenkk not sure if this is helping but I added the exposes entities

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 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_v1jqz5cy',
        },
    ],
    model: 'WiFi Chlorine Meter BLE-YL01',
    vendor: 'yieryi',
    description: 'Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Solar Powered',
    fromZigbee: [tuya.fz.datapoints, tuya.fz.gateway_connection_status],
    toZigbee: [tuya.tz.datapoints],
    onEvent: tuya.onEvent(), // Add this if you are getting no converter for 'commandMcuSyncTime'
    configure: tuya.configureMagicPacket,
    exposes: [
        e.numeric('tdsvalue', ea.STATE).withUnit('ppm').withDescription('Total Dissolved Solids Value'),
        e.temperature(),
        e.numeric('orpvalue', ea.STATE).withUnit('mV').withDescription('Oxidation Reduction Potential Value'),
        e.numeric('clvalue', ea.STATE).withUnit('ppm').withDescription('Free Chlorine Value'),
        e.numeric('batterypercentage', ea.STATE).withUnit('%').withDescription('Remaining battery in %, can take up to 24 hours before reported.').withValueMin(0).withValueMax(100),
        // e.backlightvalue(),
        e.numeric('pHvalue', ea.STATE).withUnit('pH').withDescription('pH Value'),
        e.numeric('ecvalue', ea.STATE).withUnit('µS/cm').withDescription('Electrical Conductivity Value'),
        e.numeric('ecmaxvalue', ea.STATE).withUnit('µS/cm').withDescription('Electrical Conductivity Max Value'),
        e.numeric('ecminvalue', ea.STATE).withUnit('µS/cm').withDescription('Electrical Conductivity Min Value'),
        e.numeric('orpmaxvalue', ea.STATE).withUnit('mV').withDescription('Oxidation Reduction Potential Max Value'),
        e.numeric('orpminvalue', ea.STATE).withUnit('mV').withDescription('Oxidation Reduction Potential Min Value'),
        e.numeric('CLmaxvalue', ea.STATE).withUnit('ppm').withDescription('Free Chlorine Max Value'),
        e.numeric('clmaxvalue', ea.STATE).withUnit('ppm').withDescription('Free Chlorine Min Value'),
        e.numeric('saltvalue', ea.STATE).withUnit('µS/cm').withDescription('Salt Value'),
        e.numeric('phmaxvalue', ea.STATE).withUnit('pH').withDescription('pH Max Value'),
        e.numeric('phminvalue', ea.STATE).withUnit('pH').withDescription('pH Min Value')
    ],
    meta: {
        // All datapoints go in here
        tuyaDatapoints: [
            [1, 'tdsvalue', tuya.valueConverter.raw],
            [2, 'temperature', tuya.valueConverter.raw.divideBy10],
            [7, 'batterypercentage', tuya.valueConverter.raw],
            [10, 'pHvalue', tuya.valueConverter.raw],
            [11, 'ecvalue', tuya.valueConverter.raw],
            [101, 'orpvalue', tuya.valueConverter.raw],
            [102, 'clvalue', tuya.valueConverter.raw],
            [105, 'backlightvalue', tuya.valueConverter.raw],
            [106, 'phmaxvalue', tuya.valueConverter.raw],
            [107, 'phminvalue', tuya.valueConverter.raw],
            [108, 'ecmaxvalue', tuya.valueConverter.raw],
            [109, 'ecminvalue', tuya.valueConverter.raw],
            [110, 'orpmaxvalue', tuya.valueConverter.raw],
            [111, 'orpminvalue', tuya.valueConverter.raw],
            [112, 'clmaxvalue', tuya.valueConverter.raw],
            [113, 'clminvalue', tuya.valueConverter.raw],
            [117, 'saltvalue', tuya.valueConverter.raw],

        ],
    },
};

module.exports = definition;
Koenkk commented 1 year ago

not sure if this is helping but I added the exposes entities

It would expect it still does not provide any data?

Can you provide me the debug log from starting z2m, pairing the device and waiting 5 minutes after that?

See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging.

cloudbr34k84 commented 1 year ago

im not 100% sure how i get the logs tbh I have it enabled and on the tabs inside the Z2M add on, I can see all the logs but I just don't understand how to get the a logfile, however, im not running a docker version of Z2M..

Koenkk commented 1 year ago

If you go to the Z2M page logs, keep the page open and pair the device + wait for 5 mins, you can copy the logs from there.

cloudbr34k84 commented 1 year ago

just to confirm we are talking about the same page.. image

cloudbr34k84 commented 1 year ago

@Koenkk Or this page image

cloudbr34k84 commented 1 year ago

can anyone else help me out here where to find these logs??

Koenkk commented 1 year ago

yes thats the correct page

cloudbr34k84 commented 1 year ago

yes thats the correct page

So what I just copy what's on that page???

cloudbr34k84 commented 1 year ago

@Koenkk i really dont understand how to get the logs. Here is a video of the page after I connected the device?? how does this help? can you please help me understand how you get the logs especially when they disappear constantly?? screencast-bpconcjcammlapcogcnnelfmaeghhagj-2023.09.19-08_21_38.webm

mageali commented 1 year ago

@cloudbr34k84 Not an expert either but very intrested in the device. First tip with logs is filter them for "TS0601" by adding that in "filter by text" field. Or better use the device name which I think based on the screencapture you took is this: Screenshot_20230919_164617_Chrome

Koenkk commented 1 year ago

@cloudbr34k84 ah sorry, I wasn't aware that the logs immediately disappear. With this addon you should be able to browse the files. From the z2m directory -> data -> logs folder grab the latest logs.

cloudbr34k84 commented 1 year ago

How is this any different to grabbing the logs via VSCode?

On Wed, Sep 20, 2023, 3:53 AM Koen Kanters @.***> wrote:

@cloudbr34k84 https://github.com/cloudbr34k84 ah sorry, I wasn't aware that the logs immediately disappear. With this https://community.home-assistant.io/t/home-assistant-addon-filebrowser/282108 addon you should be able to browse the files. From the z2m directory -> data -> logs folder grab the latest logs.

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

cloudbr34k84 commented 1 year ago

@cloudbr34k84 ah sorry, I wasn't aware that the logs immediately disappear. With this addon you should be able to browse the files. From the z2m directory -> data -> logs folder grab the latest logs.

@Koenkk is this what you are after?? log.txt

cloudbr34k84 commented 1 year ago

@Koenkk

i did a quick copy and paste when I paired

2023-09-20 08:25:23MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"friendly_name":"0xdc8e95fffe832b2f","ieee_address":"0xdc8e95fffe832b2f"},"type":"device_announce"}'
Info 2023-09-20 08:25:24Successfully interviewed '0xdc8e95fffe832b2f', device has successfully been paired
Info 2023-09-20 08:25:24Device '0xdc8e95fffe832b2f' is supported, identified as: yieryi Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered (WiFi Chlorine Meter BLE-YL01)
Info 2023-09-20 08:25:25MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"definition":{"description":"Smart WiFi Zigbee Chlorine Meter PH ORP EC TDS Salinity Temp CL Tester Swimming Pool Water Quality Analyzer USB Solar Powered","exposes":[{"access":1,"description":"Link quality (signal strength)","label":"Linkquality","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi","value_max":255,"value_min":0}],"model":"WiFi Chlorine Meter BLE-YL01","options":[{"access":2,"description":"Number of digits after decimal point for temperature, takes into effect on next report of device.","label":"Temperature precision","name":"temperature_precision","property":"temperature_precision","type":"numeric","value_max":3,"value_min":0},{"access":2,"description":"Calibrates the temperature value (absolute offset), takes into effect on next report of device.","label":"Temperature calibration","name":"temperature_calibration","property":"temperature_calibration","type":"numeric"}],"supports_ota":false,"vendor":"yieryi"},"friendly_name":"0xdc8e95fffe832b2f","ieee_address":"0xdc8e95fffe832b2f","status":"successful","supported":true},"type":"device_interview"}'
Koenkk commented 1 year ago

@cloudbr34k84 yes that is the log I need, but make sure to set the log level to debug.

See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging.

cloudbr34k84 commented 1 year ago

@cloudbr34k84 yes that is the log I need, but make sure to set the log level to debug.

See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging.

@Koenkk I have had them enabled for a long time. See my Z2M config. What am I doing wrong here?

data_path: /config/zigbee2mqtt
socat:
  enabled: false
  master: pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777
  slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
  options: "-d -d"
  log: true
mqtt:
  base_topic: zigbee2mqtt
  user: mqtt-user
  password: xxxxxxxxxxxxxxxxx
  server: mqtt://core-mosquitto:1883
serial:
  port: tcp://xxxxxxxxxxxx
zigbee_herdsman_debug: true
availability: true
advanced:
  log_directory: /config/data/log/%TIMESTAMP%
  timestamp_format: DD-MM-YYYY HH:mm:ss
  log_file: log.txt
  log_level: debug
  pan_id: GENERATE
  log_output:
    - console
    - file
  ext_pan_id:
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
  network_key: GENERATE
  channel: 24
homeassistant: true
discovery_topic: homeassistant
status_topic: hass/status
cloudbr34k84 commented 1 year ago

@Koenkk so for some reason in my add on config, all the logging was set, but when I check the config file in VS code, it doesn't have the same logging permissions.. sigh

Is this now what you need? log.txt

Koenkk commented 1 year ago

That exactly the logging I need, but the device doesn't report any datapoints. I guess the TuYa gateway does some magic setup in order to get the device start reporting. To debug this further, I need to have a sniff when pairing this device with the TuYa gateway: https://www.zigbee2mqtt.io/advanced/zigbee/04_sniff_zigbee_traffic.html

tschiex commented 1 year ago

Ok. I have a spare EZSP (pop) zigbee dongle somewhere, a tuya gateway and the tuya phmeter. I will try to sniff... this weekend hopefully.

cloudbr34k84 commented 1 year ago

Ok. I have a spare EZSP (pop) zigbee dongle somewhere, a tuya gateway and the tuya phmeter. I will try to sniff... this weekend hopefully.

Oh man thank you! I don't have the sniffer gear.

tschiex commented 1 year ago

I used my POPP key and it correctly sniffs the Zigbee traffic in my main Zigbee network. Wireshark already had the trust center and default network key in it. I powered up the Tuya gateway, associated it with my wifi router, and then Zigbee-paired the pH meter to it. The problem I have is that I don't know the network key of the Tuya gateway Zigbee network. I successfully repaired the ph meter to it but... saw no "Device Announcement" packet coming through in Wireshark.

I retried several times, to no avail.

cloudbr34k84 commented 1 year ago

I used my POPP key and it correctly sniffs the Zigbee traffic in my main Zigbee network. Wireshark already had the trust center and default network key in it. I powered up the Tuya gateway, associated it with my wifi router, and then Zigbee-paired the pH meter to it. The problem I have is that I don't know the network key of the Tuya gateway Zigbee network. I successfully repaired the ph meter to it but... saw no "Device Announcement" packet coming through in Wireshark.

I retried several times, to no avail.

Is this because you don't have the network key?