This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Z-Wave CommunityApp

driver.js vs. device.js vs. app.json - when and where to put stuff?

Hi,

working on an app to "Copenhagen Blinds": Venetian blinds, Z-Wave plus, battery driven, multi channel (one for up/down, one for tilt).

The device support device class 'windowcoverings' (includes capabilities "onoff'", "dim", "windowcoverings_state", "windowcoverings_tilt_up",  "windowcoverings_tilt_down" and "windowcoverings_tilt_set) as well as it supports capabilites "measure_battery" and "alarm_battery".

I've been looking at a lot of other apps (incl. Fibaro, Neo, LogicHome, Remotec, Slide and Pellini Sceen Line) to get inspiration - and have tried to find advice in the SDK2-docs, including:

https://athombv.github.io/node-homey-meshdriver/ZwaveDevice.html

https://developer.athom.com/docs/apps/tutorial-Drivers-Capabilities.html

https://developer.athom.com/docs/apps/tutorial-Z-Wave.html

https://developer.athom.com/docs/apps/tutorial-Drivers-Reference.html

https://raw.githubusercontent.com/athombv/node-homey-lib/production/lib/deviceclasses/deviceclasses.json

https://github.com/athombv/node-homey-meshdriver/tree/master/examples

I've got the app "basics" working and have it loaded to Homey and can include the device - and get the battery level - so the connection is there. However, I cannot get it to act on anything - and am a bit confused about how much should be included in the app and where to put it: Some of the documents in https://developer.athom.com/docs/apps/ seems contradictory and authors have different styles - as well as some apps are rather complex with a lot of devices etc.

As far as I understand it, is should be something like:

app.json
    "capabilities": [
        "onoff",
        "dim",
        etc...]

and

    "drivers": [
            [...]
            "class": "windowcoverings",
            "capabilities": [
                "onoff",
                "dim",
               etc...]

and

            "zwave": {
                [...]
                "multiChannelNodes": {
                    "1": {
                        "class": "windowcoverings",
                        "capabilities": [
                            "onoff",
                            "dim"
                            ],

device.js
        this.registerCapability(
            'measure_battery',
            'BATTERY', {
                getOpts: {
                    getOnOnline: true
                    }
            }
        );
        this.registerCapability(
            "dim",
            "SWITCH_MULTILEVEL_SET", {
                getOpts: {
                    getOnOnline: true
                },
                multiChannelNodeId: 1
            }
        );

It might be all there in the documents and a matter of me not finding the correct

Is it necessary to also add registerReportListener for each capability as well?
Further, I find it a bit difficult to figure out how many places values on multiChannel should be defined?

Any advice is gladly taken - including examples in other apps that could be useful :-)

Comments

  • TedTolboomTedTolboom Member
    edited February 2018
    @cbh for Z-wave it is quite simple; if you use the meshdriver (all SDK2 Z-wave apps do), there are 2 files important.
    1) the app manifest in app.json in the root of your project
    2) device driver (device.js) in /drivers/[driverID]/

    Check the meshdriver, including the examples provided: https://github.com/athombv/node-homey-meshdriver/
    And use a Z-wave app (SDK2) as reference..

    Main challenge will be to link the specific device capabilities (for the blinds) to the Z-wave command classes, which is done in the device.js
  • And this is where it gets a bit confusing to someone like me... (Who definitely wants to keep it simple)

    The example from Athom (https://github.com/athombv/com.fibaro/tree/feature/sdk2/drivers/FGK-10x) shows a device.js file in the folder drivers, not a driver.js - the same goes for other SDK2-apps like LogicHome, Remotec and Neo - and looking at the example in the meshdriver (https://github.com/athombv/node-homey-meshdriver/blob/master/examples/fibaroplug.js) it seems to be similar to the device.js files...

    The mentioned apps all use Homeyconfig - and looking in /config/drivers/ are only .json files - I now know these are all basically subsections of the app.json file - and therefore not what should be in the driver.js file...

    But if I get it right, basics should be to stick to using driver.js and app.json until I know better :-)
  • So the only typo I made, was mentioning driver.js instead of device.js...
    corrected now...
Sign In or Register to comment.