Homey Community Forum

registerCapability not working

Hi,
I’m trying to write a driver app for a Zigbee CO2, Humidity & Temperature sensor from Titan Products. To do so, I have used the homey meshdriver library. I have been able to connect to the sensor and get a Print of the clusters. But when I try to register the Capability to the cluster it does not display those values.

Custom Capability

"temperature": {
      "type": "number",
      "title": {
        "en": "Temperature"
      },
      "uiComponent": "sensor",
      "getable": true,
      "setable": false,
      "icon": "assets/temperature.svg"
    }

In Device.js onMeshInit:

this.registerCapability("temperature", 'msTemperatureMeasurement', {
    report: 'measuredValue',
    reportParser: value => value / 1000,
    get: 'measuredValue',
    getParser: value => value / 1000,
});

image

Just to test I set up an attributeReportListener where I get the desired output:

this.registerAttrReportListener(
            'msTemperatureMeasurement',
            'measuredValue',
            60,
            300,
            50,
            this.onTemperatureMeasurementReport.bind(this))
            .then(() => {
                this.log('registered attr report listener');
            })
            .catch(err => {
                this.error('failed to register attr report listener', err);
            });

onTemperatureMeasurementReport(value){
        this.log('Temperature: ', value / 100);
    }

Output:
2020-07-07 11:45:37 [log] [ManagerDrivers] [co2th] [0] registerAttrReportListener() -> configured attr reporting attrReport_0_msTemperatureMeasurement_measuredValue
2020-07-07 11:45:37 [log] [ManagerDrivers] [co2th] [0] registered attr report listener
2020-07-07 11:47:37 [log] [ManagerDrivers] [co2th] [0] Temperature: 23.35
2020-07-07 11:48:37 [log] [ManagerDrivers] [co2th] [0] Temperature: 23.31
2020-07-07 11:50:37 [log] [ManagerDrivers] [co2th] [0] Temperature: 23.28

What might I be doing wrong?

Can I be curious, why do you use a custom capability while there is a default capability for temperature? That only makes it more prone to mistakes in your code that can cause this.

I didn’t know that I overlooked system capabilities, my bad. I’ve changed the capabilities to the default for CO2, humidity, and temperature, but with the same result:

"capabilities": [
        "onoff",
        "measure_co2",
        "measure_humidity",
        "measure_temperature" ],
this.registerCapability("measure_co2","1037", {
            get: "2",
            getParser:  value => value * 100000,
            report: "2",
            reportParser: value => value * 10000
        });

        this.registerCapability("measure_humidity", 'msRelativeHumidity', {
            report: 'measuredValue',
            reportParser: value => value / 1000,
            get: 'measuredValue',
            getParser: value => value / 1000
        });

        this.registerCapability("measure_temperature","msTemperatureMeasurement", {
            report: 'measuredValue',
            reportParser: value => value / 100,
            get: 'measuredValue',
            getParser: value => value / 100
        });