Multiple channels of the same type (and referencing them in Smartthings)
Posted: 01 Mar 2020 21:17
I'm just starting out with Zuno, and I'm trying to make a device which can control 4 relays. Although I'm sure I could configure the Zuno as a dimmer (and just use the dim-level as a bitmap for which relays should be on/off) or a color bulb (and I still might end up doing it this way, for reasons I'll explain below), I wanted to see if it was possible to do it the "right" way by setting up four channels, all of them ZUNO_SWITCH_BINARY.
In one of the code samples in the quick-start guide, they show how to setup multiple channels:
but I noticed that all of the channels are different. It is not clear to me if the multiple channels can be identical (and then the Z-Wave protocol has some way for the controller to address a certain channel by number) or if the protocol only has a way to address certain "capabilities" (i.e. a device either has a single "binary switch" capability or it doesn't, and if it does, a controller asks to talk to that device's "binary switch").
Is it possible to do something like:
If so...
In one of the code samples in the quick-start guide, they show how to setup multiple channels:
Code: Select all
ZUNO_SETUP_CHANNELS(
ZUNO_SWITCH_BINARY(getterLED, setterLED),
ZUNO_SWITCH_MULTILEVEL(getterDimmer, setterDimmer),
ZUNO_SENSOR_BINARY_GENERAL_PURPOSE(getterButton)
);
Is it possible to do something like:
Code: Select all
ZUNO_SETUP_CHANNELS(
ZUNO_SWITCH_BINARY(getter1, setter1),
ZUNO_SWITCH_BINARY(getter2, setter2),
ZUNO_SWITCH_BINARY(getter3, setter3)
);
- how would you select which switch you wanted to control from a Smartthings device-handler? I can't find any mention of a "channel number" in their methods for constructing a Z-wave message.
- Is there a way for the getter/setter to discover the channel number they were activated with? If so, you can have multiple channels share a single getter/setter pair (because they can figure out, from the channel number, which switch is being set/queried). Something like:
If there isn't a way to do this, then it's probably best to have the Zuno pretend to be a dimmer, so that the desired value of all of the relays can be encoded as a bitmap in the dimmer value and you can use a single getter/setter.
Code: Select all
void setter(byte value) { int switch_num = get_channel(); digitalWrite(switch_num, (value==0)?LOW:HIGH); }