Koenkk / zigbee2mqtt

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

Changes in DEV tree with postfixWithEndpointName has broken custom converters #13451

Closed RJSDevel closed 2 years ago

RJSDevel commented 2 years ago

What happened?

debug 2022-08-07 22:12:27: TypeError: Cannot read property 'device' of undefined at postfixWithEndpointName (C:\Users\Developer\Desktop\zigbee2mqtt\node_modules\zigbee-herdsman-converters\lib\utils.js:118:45) at Object.convert (C:\Users\Developer\Desktop\zigbee2mqtt\dist\util\externally-loaded.js:48:12) at Receive.onDeviceMessage (C:\Users\Developer\Desktop\zigbee2mqtt\lib\extension\receive.ts:143:51) at EventEmitter.emit (events.js:412:35) at EventBus.emitDeviceMessage (C:\Users\Developer\Desktop\zigbee2mqtt\lib\eventBus.ts:102:22) at Controller. (C:\Users\Developer\Desktop\zigbee2mqtt\lib\zigbee.ts:106:27) at Controller.emit (events.js:400:28) at Controller.selfAndDeviceEmit (C:\Users\Developer\Desktop\zigbee2mqtt\node_modules\zigbee-herdsman\src\controller\controller.ts:495:14) at Controller.onZclOrRawData (C:\Users\Developer\Desktop\zigbee2mqtt\node_modules\zigbee-herdsman\src\controller\controller.ts:706:18) at ZStackAdapter. (C:\Users\Developer\Desktop\zigbee2mqtt\node_modules\zigbee-herdsman\src\controller\controller.ts:143:70)

What did you expect to happen?

No response

How to reproduce it (minimal and precise)

old - postfixWithEndpointName('volume', msg, model) new - postfixWithEndpointName('volume', msg, model, meta)

Zigbee2MQTT version

1.27.0

Adapter firmware version

000000000

Adapter

CC2531

Debug log

log.txt

Koenkk commented 2 years ago

You should update your external converter to also pass the meta property.

RJSDevel commented 2 years ago

All convectors? Could you override one method for save compatibility with alert log? I don't think that people will read readme

Koenkk commented 2 years ago

This was not a refactor but a fix (otherwise the postfixWithEndpointName method doesn't work correctly) so I suggest to update the external converter.

RJSDevel commented 2 years ago

Are you going to warn other developers or add explanation to code if the meta hasn't passed to the method? Because I was finding the reason about half hour. I guess there are extremely changes for "simple people"

Koenkk commented 2 years ago

Valid point, pushed a fix please let me know if it works.

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

RJSDevel commented 2 years ago

This has fixed the error, but device aren't working at all, events haven't received. With meta all right

han-alink commented 2 years ago

I think this issue is causing an error in at least one of my external definitions. But I do not understand what should be changed in the following device description: { zigbeeModel: ['onOffSwitch'], model: 'OnOffTouchController', vendor: 'Alink', description: 'Touch on off step switch', fromZigbee: [fzLocal.touch_input, fz.battery], toZigbee: [], exposes: [e.contact().withEndpoint('left'), e.contact().withEndpoint('right'), e.battery(), e.battery_voltage()], meta: { multiEndpoint: true, battery: {voltageToPercentage: '3V_2500_3200'}}, endpoint: (device) => {return {'left': 1, 'right': 2}}, configure: async (device, coordinatorEndpoint, logger) => { const overides = {min: 1, max: 3600}; const endpoint1 = device.getEndpoint(1); await reporting.bind(endpoint1, coordinatorEndpoint, ['genPowerCfg','genBinaryInput']);
const endpoint2 = device.getEndpoint(2); await reporting.bind(endpoint2, coordinatorEndpoint, ['genBinaryInput']); await reporting.presentValue(endpoint1, overides); await reporting.presentValue(endpoint2, overides); await reporting.batteryVoltage(endpoint1, overides); } },

Found the problem: touch_input: { cluster: 'genBinaryInput', type: 'attributeReport', convert: (model, msg, publish, options, meta) => { const property = utils.postfixWithEndpointName('contact',msg, model,meta); //ADDED meta return {[property]: (msg.data['presentValue']==1)};

github-actions[bot] commented 2 years ago

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