You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I wrote a converter for a custom device having a custom cluster. Without modern extend it is necessary to add the cluster definition in cluster.ts, while the function deviceAddCustomCluster is now available. I read a lot of converters for available device but I'm not able to understand how the converterSet and Get are handled in the modern way (some attributes are both GET and SET).
I leave here my converter (classic, old way) which I would like to transform in a modern one to make it update safe. Someone can help me?
/*ADD TO CLUSTER.JS in NODE-MODULEmvManuWaterLevel: { ID: 0xfc01, attributes: { measuredValue: {ID: 0, type: dataType_1.default.UINT16}, tankHeight: {ID: 1, type: dataType_1.default.UINT16}, elevation: {ID: 2, type: dataType_1.default.UINT16}, }, commands: {}, commandsResponse: {}, },*/constfz=require('zigbee-herdsman-converters/converters/fromZigbee');consttz=require('zigbee-herdsman-converters/converters/toZigbee');constexposes=require('zigbee-herdsman-converters/lib/exposes');constconstants=require('zigbee-herdsman-converters/lib/constants');constreporting=require('zigbee-herdsman-converters/lib/reporting');conste=exposes.presets;constea=exposes.access;constfromZbLocal={waterLevel: {cluster: 'mvManuWaterLevel',type: ['attributeReport','readResponse'],convert: (model,msg,publish,options,meta)=>{if(msg.data.hasOwnProperty('measuredValue')){constlevel=parseFloat(msg.data['measuredValue'])/100.0;return{'waterLevel': level};}},},tankHeight: {cluster: 'mvManuWaterLevel',type: ['attributeReport','readResponse'],convert: (model,msg,publish,options,meta)=>{if(msg.data.hasOwnProperty('tankHeight')){constlevel=parseFloat(msg.data['tankHeight'])/100.0;return{'tankHeight': level};}},},elevation: {cluster: 'mvManuWaterLevel',type: ['attributeReport','readResponse'],convert: (model,msg,publish,options,meta)=>{if(msg.data.hasOwnProperty('elevation')){constlevel=parseFloat(msg.data['elevation'])/100.0;return{'elevation': level};}},},}consttoZbLocal={tankHeight: {key: ['tankHeight'],convertSet: async(entity,key,value,meta)=>{varv=value*100;constpayload={tankHeight: v};awaitentity.write('mvManuWaterLevel',payload);return{'tankHeight': v};},convertGet: async(entity,key,meta)=>{awaitentity.read('mvManuWaterLevel',['tankHeight']);},},elevation: {key: ['elevation'],convertSet: async(entity,key,value,meta)=>{varv=value*100;constpayload={elevation: v};//UINT16awaitentity.write('mvManuWaterLevel',payload);return{'elevation': v};},convertGet: async(entity,key,meta)=>{awaitentity.read('mvManuWaterLevel',['elevation']);},},}constdefinition={zigbeeModel: ['PLSYSZB1'],model: 'PLSYSZB1',vendor: 'MVDevZB',description: 'Irrigation Plant System',extend: [],fromZigbee: [fz.on_off,fromZbLocal.waterLevel,fromZbLocal.tankHeight,fromZbLocal.elevation],toZigbee: [tz.on_off,toZbLocal.tankHeight,toZbLocal.elevation],exposes: [e.switch().withLabel("Pump State"),e.numeric('waterLevel',ea.STATE).withDescription('Water Level Percentage').withUnit('%').withLabel("Water Level"),e.numeric('tankHeight',ea.ALL).withDescription('Tank Height in cm. The max height water can reach').withUnit('cm').withLabel("Max Water Level"),e.numeric('elevation',ea.ALL).withDescription('Sensor elevation from the maximum water surface').withUnit('cm').withLabel("Sensor Elevation")],configure: async(device,coordinatorEndpoint)=>{constendpoint=device.getEndpoint(10);awaitreporting.bind(endpoint,coordinatorEndpoint,['genOnOff','mvManuWaterLevel']);awaitendpoint.configureReporting('mvManuWaterLevel',[{attribute: 'measuredValue',minimumReportInterval: constants.repInterval.SECONDS_5,maximumReportInterval: constants.repInterval.HOUR,reportableChange: 1}]);},};module.exports=definition;
Thanks
The text was updated successfully, but these errors were encountered:
Hi,
I wrote a converter for a custom device having a custom cluster. Without modern extend it is necessary to add the cluster definition in cluster.ts, while the function
deviceAddCustomCluster
is now available. I read a lot of converters for available device but I'm not able to understand how the converterSet and Get are handled in the modern way (some attributes are both GET and SET).I leave here my converter (classic, old way) which I would like to transform in a modern one to make it update safe. Someone can help me?
Thanks
The text was updated successfully, but these errors were encountered: