Trying to write driver & app for a basic zwave temp and humidity sensor. I'm new, it can't be this hard

I’ve tried to write an app that literally just receives the temp, humidity and battery from an LSE861 temperature and humidty ZWave sensor.

But nothing is reported. Please help me, I feel quite stupid. Nothing shows up in the console log, nothing is reported on homey. It pairs and unpairs. It’s a ZWave multisensor class, i’ll include the device info I have at the bottom. First, here are the driver files:

device.js

'use strict';

const Homey = require('homey');
const { ZwaveDevice } = require('homey-zwavedriver');

class LSE861 extends Homey.Device {

  /**
   * onInit is called when the device is initialized.
   */
  async onInit() {
 /**   this.registerCapability('measure_temperature','SENSOR_MULTILEVEL');
   * this.registerCapability('measure_humidity','SENSOR_MULTILEVEL');
    */
 this.registerCapabilityListener('measure_battery', async(value)=> {
  this.log ('Battery:', value);
});

this.registerCapabilityListener('measure_temperature', async(value)=> {
  this.log ('Temperature:', value);
});

this.registerCapabilityListener('measure_humidity', async(value)=> {
  this.log ('Humidity:', value);
});
}

onNodeInit({ node }) {
  // enable debugging
  this.enableDebug();

  this.log('Print the node info to the console');
  this.printNode();

  this.log('Log node');
  this.log(node);

  this.registerCapabilityListener('measure_battery', 'BATTERY', {
    get: 'BATTERY_GET',
    getOpts: {
      getOnOnline: true,
    },
    report: 'BATTERY_REPORT',
    reportParser: (report) => {
      this.log('Battery report');
      const level = Number(report['Battery Level']);
      this.log(level);
      this.setCapabilityValue('measure_battery', level);
    },
  });

  this.registerCapability('measure_temperature', 'SENSOR_MULTILEVEL', {
    get: 'SENSOR_MULTILEVEL_GET',
    getOpts: {
      getOnOnline: true,
    },
  });

  this.registerCapability('measure_humidity', 'SENSOR_MULTILEVEL', {
    get: 'SENSOR_MULTILEVEL_GET',
    getOpts: {
      getOnOnline: true,
    },
  });
  }

  /**
   * onAdded is called when the user adds the device, called just after pairing.
   */
  async onAdded() {
    this.log('An LS 861 has been added');
  }

  /**
   * onSettings is called when the user updates the device's settings.
   * @param {object} event the onSettings event data
   * @param {object} event.oldSettings The old settings object
   * @param {object} event.newSettings The new settings object
   * @param {string[]} event.changedKeys An array of keys changed since the previous version
   * @returns {Promise<string|void>} return a custom message that will be displayed
   */
  async onSettings({ oldSettings, newSettings, changedKeys }) {
    this.log('MyDevice settings where changed');
  }

  /**
   * onRenamed is called when the user updates the device's name.
   * This method can be used this to synchronise the name to the device.
   * @param {string} name The new name
   */
  async onRenamed(name) {
    this.log('MyDevice was renamed');
  }

  /**
   * onDeleted is called when the user deleted the device.
   */
  async onDeleted() {
    this.log('MyDevice has been deleted');
  }

}

module.exports = LSE861;

driver.compose.json

{
  "name": {
    "en": "LSE861"
  },
  "class": "sensor",
  "capabilities": [
    "measure_battery",
    "measure_humidity",
    "measure_temperature"
  ],
  "energy": {
    "batteries": ["AAA", "AAA"]
  },
  "platforms": [
    "local"
  ],
  "connectivity": [
    "zwave"
  ],
  "images": {
    "small": "{{driverAssetsPath}}/images/small.png",
    "large": "{{driverAssetsPath}}/images/large.png",
    "xlarge": "{{driverAssetsPath}}/images/xlarge.png"
  },
  "zwave": {
    "manufacturerId": 113,
    "productTypeId": [
      2
    ],
    "productId": [
      861
    ],
    "zwaveAllianceProductId": 300
  }
}

driver.settings.compose.json

[
    {
      "id": "temperature_sensor_unit",
      "type": "number",
      "label": { "en": "Temperature sensor unit" },
      "value": 0,
      "attr": { "min": 0,"max": 1 },
      "hint": { "en": "0 – Celsius. 1 – Fahrenheit" },
      "zwave": {
        "index": 1,
        "size": 1
      }
    },
    {
      "id": "report_temperature_change",
      "type": "number",
      "label": { "en": "Temperature Change Reporting" },
      "value": 10,
      "attr": { "min": 1,"max": 50 },
      "hint": { "en": "Set temperature change to be reported by the sensor, 1 - 50 (where 1 stands for 0.1 degree C and 50 stands for 5 degrees)" },
      "zwave": {
        "index": 2,
        "size": 1
      }
    },
    {
      "id": "report_humidity_change",
      "type": "number",
      "label": {
        "en": "Humidity Change Reporting"
      },
      "value": 10,
      "attr": {
        "min": 1,
        "max": 50
      },
      "hint": {
        "en": "Set humidity change to be reported by the sensor, 1 - 50 (where 1 stands for 1% and 50 stands for 50%)"
      },
      "zwave": {
        "index": 3,
        "size": 1
      }
    }
  ]

ZWave info on device:

3.1 Multi sensor

Following temperature, humidity and setpoint ranges and resolutions are given:

Default Value

Potentiometer range 0-100 %

Ambient temperature 0 - 50°C

Potentiometer resolution ±0.5%

Potentiometer accuracy ±10%

Send on Delta Percentage 2 - 10% 5%

Wake up 1 minute - 1 day 23 hours

3.2 Z-wave Configuration Button

The configuration button is used for inclusion/excluding to new or existing Z-wave network.

The device gets reset to factory default when it is excluded from the network.

The device can receive commands during wakeup. When the device is included it is awake for

approx 30 seconds.

Function Button Press Description

Include/Exclude Short press Wake up

Sensor report Pin leave Start learn mode

3.3 Z-wave Configuration parameters

Parameter number Parameter name Parameter range

1 Delta Percentage 2-10

2 Send Setpoint when wakeup Off=<64 On=>64Z-Wave Z-Point

6

4. Technical Specifications

4.1 Technical specifications

Power supply: 2 Alkaline batteries ≥ 1.200 mAh – size: AAA

Frequency: RF 868.42 Mhz

Size HxWxD: 71 x 71 x 25 mm

Ambient temperature: 0 - 50°C

4.2 Potentiometer

Type: 22K

4.3 Z-Wave Module

ZM3102 Z-Wave Module

4.4 Product code

Product code: 35038


I have scoured for more information about how to create a working driver and actually, there’s very little of anything on the matter that makes sense and is relevant for homey.

Thank you for any and all information in advance.

Please format your code using the </> button in the editor, it’s not very readable.

onNodeInit is implemented in ZwaveDevice:

const { ZwaveDevice } = require(‘homey-zwavedriver’);

class LSE861 extends ZwaveDevice {
  ...
}

More info here.

1 Like

Hi Robert,

I’ve formatted it now. It’s working. Also turns out, I think that it doesn’t have humidity. Is there a way to find out what the capabilities are?

I had to unpair and re-pair but now it displays the temperature accurately.

It was precisely this: class LSE861 extends ZwaveDevice {

Instead of Homey.

Thank you so much!

I don’t know, I never worked with Z-Wave before. Perhaps @Caseda does?

With a simple command you can only receive the supported command classes (this.printNode() in the nodeInit()).
But that doesn’t account for things like humidity, as humidity is only a sub part of a single command class, which belongs in the same command class as for example temperature.
Some command classes have a “COMMANDCLASS.supported.get” command, but as i’m currently not at home it is a bit difficult to look into the zwave documentation.

1 Like