zunoSetZWChannel()
Binds device channel to Z-Wave multichannel instance.
First you have to add desired channel using zunoAddChannel, and then you are able to set its multichannel instance via zunoSetZWChannel.
You can bind device channel directly to the main end point, to any multichannel end point, or both to main end point and to some of availiable multichannel end points. You can't bind two channels of the same type to the main endpoint. Each multichannel endpoint represents only one channel of device. It's hightly recommended to bind only the general functionality of the device to main endpoint. For example if you have relay device with energy metering map SwitchBinary to main endpoint, SensorMultilevel channel bind to the first multichannel endpoint.
zunoSetZWChannel(ch, zw_channel)
ch
Device channel in range [0;31]. Each call to zunoAddChannel adds one channel to device. Numbering starts from 0. So for example if you call zunoAddChannel you will have 2 channels: 0 and 1.
zw_channel
Intance of Z-Wave multichannel class. Expected values: 0 - binds channel only to the main end point, value from range [1;31] - binds channel to selected multichannel endpoint, value from range [1;31] ored with ZWAVE_CHANNEL_MAPPED_BIT - binds channel both to main and multichannel end point.
Example 1 Creates one channel and binds it both to main end point and to multichannel endpoint #1.
// Define special command class macroses
// We use SwitchMultilevel and Basic command classes for dimmer, so we have to enable them:
ZUNO_ENABLE(WITH_CC_SWITCH_MULTILEVEL WITH_CC_BASIC)
byte dimmerValue = 99;
void setup() {
if(zunoStartDeviceConfiguration()) {// Check if we are able to reconfigure the device.
// Device can change its characterictics ONLY if it's not included
zunoAddChannel(ZUNO_SWITCH_MULTILEVEL_CHANNEL_NUMBER, 0, 0);// Add SWITCH_MULTILEVEL channel. It doesn't require any optional parameters.
zunoSetZWChannel(0x0, 0x1 | ZWAVE_CHANNEL_MAPPED_BIT); // Bind channel both to main endpoint and to 1st multichannel endpoint.
// The device will have Multichannel command class in its capabilities and only 1 instance is providen via Multichannel
// If you use 0 instead of this the device will have only main endpoint
zunoCommitCfg();//
}
zunoAppendChannelHandler( 0, 1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&dimmerValue);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(dimmerValue*10);
digitalWrite(LED_BUILTIN, LOW);
delay(dimmerValue*10);
}
Example 2 Create 2 channel dimmer and one relay. The first dimmer is avaliable via main end point and via 1-st multichannel end point, the second dimmer is avaliable only via 2-nd multichannel end point, relay is avaliable via 3-d multichannel end point.
In short words it imitates this static-style code:
ZUNO_SETUP_CHANNELS(
ZUNO_SWITCH_MULTILEVEL(dimmerValue, NULL),
ZUNO_SWITCH_MULTILEVEL(dimmerValue, NULL),
ZUNO_SWITCH_BINARY(switchValue2, NULL)
);
if(zunoStartDeviceConfiguration()) {
// Check if we are able to reconfigure the device.
// Device can change its characterictics ONLY if it's not included
zunoAddChannel(ZUNO_SWITCH_MULTILEVEL_CHANNEL_NUMBER, 0, 0);// Add first dimmer channel by means of SWITCH_MULTILEVEL.
zunoSetZWChannel(0, 1 | ZWAVE_CHANNEL_MAPPED_BIT);// First dimmer is availiable via 1st multichannel end point and it's mapped to main end point
zunoAddChannel(ZUNO_SWITCH_MULTILEVEL_CHANNEL_NUMBER, 0, 0);// Add second dimmer channel by means of SWITCH_MULTILEVEL.
zunoSetZWChannel(1, 2);// Second dimmer is availiable via 2nd multichannel end point
zunoAddChannel(ZUNO_SWITCH_BINARY_CHANNEL_NUMBER, 0, 0); // Add realye channel by means of SWITCH_BINARY
zunoSetZWChannel(2, 3);// relay is availiable via 3-d multichannel end point
zunoCommitCfg();// Apply settings ^^^
}