Skip to content
Marcus Davies edited this page Jul 10, 2021 · 22 revisions

The Z-Wave JS CC API, is a no fuss, to the point and easy to use API.

  • Set the cc
  • Set the CC method
  • Provide any params the method needs.
  • Move on

Examples

Turn on a binary switch

let Message = {
    payload: {
        mode: "CCAPI",
        node: 2,
        cc: "Binary Switch",
        method: "set",
        params: [true]
    }
}
return Message

You can also specify an endpoint. i.e. for those devices that may have multiple outlets let say.

let Message = {
    payload: {
        mode: "CCAPI",
        node: 2,
        cc: "Binary Switch",
        endpoint: 2,
        method: "set",
        params: [true]
    }
}
return Message

Or specify a duration, for the CC's that support a duration of time.

let Message = {
    payload: {
        mode: "CCAPI",
        node: 2,
        cc: "Multilevel Switch",
        method: "set",
        params: [20,"1m20s"]
    }
}
return Message

The CC API is a set and forget type of request, therefore, this API does not verify that the value was set.
In normal circumstances, the device being changed, will send an unsolicited value update.

Some devices however, do not do this. In those situations, you can poll for the value after setting it (which should return the recently updated value)

let Message = {
    payload: {
        mode: "CCAPI",
        node: 2,
        cc: "Binary Switch",
        method: "set",
        forceUpdate: {
          property: "currentValue"
        },
        params: [false]
    }
}
return Message

The properties in the forceUpdate object, are those that are provided in VALUE_UPDATED events.
namely a property and sometimes propertyKey.

Whilst you can provide properties to override this query, such as an endpoint, and the commandClass, it is best to allow the driver to control this. For special circumstances however, you are free to modify it.