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

**URL:** <https://community.homey.app/t/trying-to-write-driver-app-for-a-basic-zwave-temp-and-humidity-sensor-im-new-it-cant-be-this-hard/116051>\
**Category:** Developers\
**Created:** [September 14, 2024, 10:15pm UTC](https://community.homey.app/t/trying-to-write-driver-app-for-a-basic-zwave-temp-and-humidity-sensor-im-new-it-cant-be-this-hard/116051 "2024-09-14T22:15:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nico](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/nico/32/66731_2.png) [@Nico](https://community.homey.app/u/Nico)\
**Post date:** [September 14, 2024, 10:15pm UTC](https://community.homey.app/t/trying-to-write-driver-app-for-a-basic-zwave-temp-and-humidity-sensor-im-new-it-cant-be-this-hard/116051/1 "2024-09-14T22:15:28Z")

</div>

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

```auto
'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

```auto
{
  "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

```auto
[
    {
      "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.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [September 15, 2024, 5:03am UTC](https://community.homey.app/t/trying-to-write-driver-app-for-a-basic-zwave-temp-and-humidity-sensor-im-new-it-cant-be-this-hard/116051/2 "2024-09-15T05:03:43Z")

</div>

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

`onNodeInit` is implemented in `ZwaveDevice`:

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

class LSE861 extends ZwaveDevice {
  ...
}

```

More info [here](https://apps.developer.homey.app/wireless/z-wave#homey-zwavedriver).

---

<div class="post-metadata">

**Author:** ![Nico](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/nico/32/66731_2.png) [@Nico](https://community.homey.app/u/Nico)\
**Post date:** [September 15, 2024, 4:11pm UTC](https://community.homey.app/t/trying-to-write-driver-app-for-a-basic-zwave-temp-and-humidity-sensor-im-new-it-cant-be-this-hard/116051/3 "2024-09-15T16:11:05Z")

</div>

> [@robertklep](#):
>
> `class LSE861 extends ZwaveDevice {`

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!

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [September 15, 2024, 4:37pm UTC](https://community.homey.app/t/trying-to-write-driver-app-for-a-basic-zwave-temp-and-humidity-sensor-im-new-it-cant-be-this-hard/116051/4 "2024-09-15T16:37:15Z")

</div>

> [@Nico](#):
>
> Is there a way to find out what the capabilities are?

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

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [September 15, 2024, 8:22pm UTC](https://community.homey.app/t/trying-to-write-driver-app-for-a-basic-zwave-temp-and-humidity-sensor-im-new-it-cant-be-this-hard/116051/5 "2024-09-15T20:22:44Z")

</div>

> [@Nico](#):
>
> 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?

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.
