Koenkk / zigbee2mqtt

Zigbee šŸ to MQTT bridge šŸŒ‰, get rid of your proprietary Zigbee bridges šŸ”Ø
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.08k stars 1.68k forks source link

TS004F devices shows as unsupported #22037

Closed ajithprabhakar closed 7 months ago

ajithprabhakar commented 7 months ago

What happened?

TS004F remote stopped working after the latest update. here is my custom converter

` 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 legacy = require('zigbee-herdsman-converters/lib/legacy'); const extend = require('zigbee-herdsman-converters/lib/extend'); 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 definition = { fingerprint: [{modelID: 'TS004F', manufacturerName: '_TZ3000_g9g2xnch'}], model: 'YSR-MINI-Z', vendor: 'TuYa', description: '2 in 1 dimming remote control and scene control', exposes: [ e.battery(), e.action(['on', 'off', 'brightness_move_up', 'brightness_step_up', 'brightness_step_down', 'brightness_move_down', 'brightness_stop', 'color_temperature_step_down', 'color_temperature_step_up', '1_single', '1_double', '1_hold', '2_single', '2_double', '2_hold', '3_single', '3_double', '3_hold', '4_single', '4_double', '4_hold', ]), exposes.enum('operation_mode', ea.ALL, ['command', 'event']).withDescription( 'Operation mode: "command" - for group control, "event" - for clicks'), ], fromZigbee: [fz.battery, fz.command_on, fz.command_off, fz.command_step, fz.command_move, fz.command_stop, fz.command_step_color_temperature, fz.tuya_on_off_action, fz.tuya_operation_mode], toZigbee: [tz.tuya_operation_mode], onEvent: tuya.onEventSetLocalTime, configure: async (device, coordinatorEndpoint, logger) => { const endpoint = device.getEndpoint(1); await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg']); await reporting.batteryPercentageRemaining(endpoint); await endpoint.read('genOnOff', ['tuyaOperationMode']); }, };

module.exports = definition;

`

What did you expect to happen?

This was supported with a custom converter till the last version of zigbee2mqtt , and now it shows as not supported.

How to reproduce it (minimal and precise)

Install latest version of Zigbee2Mqtt

Zigbee2MQTT version

1.36.1-1

Adapter firmware version

20211217

Adapter

usb-Silicon_Labs_slae.sh_cc2652rbstick-_slaesh_s_iot_stuff_00_12_4B_00_23_93_3B_65-if00-port0

Setup

Add-on to Home Assistant Running on Intel PC

Debug log

[10:00:19] INFO: Preparing to start... [10:00:19] INFO: Socat not enabled [10:00:20] INFO: Starting Zigbee2MQTT... Zigbee2MQTT:error 2024-04-02 10:00:21: Failed to load external converter file 'custom_converter.js' (Cannot find module 'zigbee-herdsman-converters/lib/extend' Require stack:

renoye commented 7 months ago

I have the same issue. The previous version 1.36.0-1 , my customized convert works. After, I upgraded to 1.36.1-1. The discovered device becomes unsupported in zig2mqtt db and disappears at HA devices.

this is my customized js

`const {} = require('zigbee-herdsman-converters/lib/modernExtend'); // Add the lines below 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 legacy = require('zigbee-herdsman-converters/lib/legacy'); const reporting = require('zigbee-herdsman-converters/lib/reporting'); const extend = require('zigbee-herdsman-converters/lib/extend'); const ota = require('zigbee-herdsman-converters/lib/ota'); const tuya = require('zigbee-herdsman-converters/lib/tuya'); const {} = 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 definition = { 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_rsj5pu8y', }, ], model: 'MP43L', vendor: 'Raex', description: 'Curtain motor/roller blind motor/window pusher/tubular motor', fromZigbee: [legacy.fromZigbee.tuya_cover, fz.ignore_basic_report], toZigbee: [legacy.toZigbee.tuya_cover_control, legacy.toZigbee.tuya_cover_options], exposes: [ e.cover_position().setAccess('position', ea.STATE_SET), e.composite('options', 'options', ea.STATE_SET) .withFeature(e.numeric('motor_speed', ea.STATE_SET) .withValueMin(0).withValueMax(255).withDescription('Motor speed')) .withFeature(e.binary('reverse_direction', ea.STATE_SET, true, false) .withDescription('Reverse the motor direction'))], };

module.exports = definition;`

Koenkk commented 7 months ago

Remove const extend = require('zigbee-herdsman-converters/lib/extend'); from the converter, I added out-of-the-box support for both devices!

Changes will be available in the dev branch in a few hours from now.

LykkeGit commented 7 months ago

I seem to have the same issue with my TS0601 converter - used to work but now it is unsupported. Removing "const ext..." didn't help, but maybe when new dev branch becoms available?

Rolled back to 1.36.0-1 and it is all working again

++++++ [20:51:18] INFO: Preparing to start... [20:51:19] INFO: Socat not enabled [20:51:21] INFO: Starting Zigbee2MQTT... Zigbee2MQTT:error 2024-04-03 20:51:31: Failed to load external converter file 'TS0601.js' (Cannot find module 'zigbee-herdsman-converters/lib/extend' Require stack:

++++++

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_qyss8gjy', }, ], model: '_TZE200_qyss8gjy', vendor: 'TuYa', description: 'LTECH 24V LED Driver', fromZigbee: [tuya.fz.datapoints], toZigbee: [tuya.tz.datapoints], onEvent: tuya.onEventSetTime, // Add this if you are getting no converter for 'commandMcuSyncTime' configure: tuya.configureMagicPacket, extend: tuya.extend.switch({powerOnBehavior: true}), exposes: [tuya.exposes.lightBrightness(), e.power_on_behavior(), tuya.exposes.countdown()], meta: { // All datapoints go in here tuyaDatapoints: [ [1, 'state', tuya.valueConverter.onOff, {skip: tuya.skip.stateOnAndBrightnessPresent}], [2, 'power_on_behavior', tuya.valueConverter.powerOnBehavior], [3, 'brightness', tuya.valueConverter.scale0_254to0_1000], [7, 'countdown', tuya.valueConverter.countdown], ], }, };

module.exports = definition;