I am having problems getting the dynamic channel configuration to work properly, I am hoping the forum might have some ideas and pointers to get it right.
What I want to achieve in the end, is a way to control the z-uno from a Python program in a Raspberry Pi.
To make the z-uno code as generic as possible, I decided to explore the concept of dynamically configuring the channels using the macros ZUNO_START_CONFIG(), ZUNO_ADD_CHANNEL(), ZUNO_COMMIT_CONFIG().
My first attempt was to use the sample code "Z-Uno as a modem (AT Commands)". https://z-uno.z-wave.me/examples/z-uno-as-a-modem/
It works to some extent, as long as I only add a maximum of two channels. With more channels, only the first and the last channels are actually configured in the controller, the ones in between are lost.
So, to make sure it was not the sample code that messed it up, I collected all the config commands and put them in a short sketch just to check how setting up the channels works in the controller.
In my example, I am defining two dimmers, one binary switch and two thermometers.
Code 1:
Code: Select all
ZUNO_ENABLE(WITH_CC_SWITCH_MULTILEVEL WITH_CC_METER WITH_CC_SENSOR_BINARY WITH_CC_SWITCH_COLOR WITH_CC_SENSOR_MULTILEVEL WITH_CC_DOORLOCK WITH_CC_SWITCH_BINARY WITH_CC_NOTIFICATION WITH_CC_THERMOSTAT);
ZUNO_DYNAMIC_CHANNELS(32);
void setup() {
ZUNO_START_CONFIG();
// Channel 1 - Switch multilevel
ZUNO_ADD_CHANNEL(2,0,0);
// Channel 2 - Switch multilevel
ZUNO_ADD_CHANNEL(2,0,0);
// Channel 3 - Switch binary
ZUNO_ADD_CHANNEL(1,0,0);
// Channel 4 - Thermometer
ZUNO_ADD_CHANNEL(4,1,66);
// Channel 5 - Thermometer
ZUNO_ADD_CHANNEL(4,1,66);
ZUNO_COMMIT_CONFIG();
}
1 dimmer
1 thermometer.
The other ones are not visible.
So the next thing I tried was to use the ZUNO_SET_ZWCHANNEL() to try to assign each channel explicitly instead. This is what Code 2 is doing. I am using the same model as in the sample code in the z-uno reference: https://z-uno.z-wave.me/Reference/ZUNO_SET_ZWCHANNEL/.
Code 2:
Code: Select all
ZUNO_ENABLE(WITH_CC_SWITCH_MULTILEVEL WITH_CC_METER WITH_CC_SENSOR_BINARY WITH_CC_SWITCH_COLOR WITH_CC_SENSOR_MULTILEVEL WITH_CC_DOORLOCK WITH_CC_SWITCH_BINARY WITH_CC_NOTIFICATION WITH_CC_THERMOSTAT);
ZUNO_DYNAMIC_CHANNELS(32);
#define MAP_TO_ZEROCHANNEL 0x80
void setup() {
ZUNO_START_CONFIG();
// Channel 1 - Switch multilevel
ZUNO_SET_ZWCHANNEL(1| MAP_TO_ZEROCHANNEL);
ZUNO_ADD_CHANNEL(2,0,0);
// Channel 2 - Switch multilevel
ZUNO_SET_ZWCHANNEL(MAP_TO_ZEROCHANNEL + 1);
ZUNO_ADD_CHANNEL(2,0,0);
// Channel 3 - Switch binary
ZUNO_SET_ZWCHANNEL(MAP_TO_ZEROCHANNEL + 2);
ZUNO_ADD_CHANNEL(1,0,0);
// Channel 4 - Thermometer
ZUNO_SET_ZWCHANNEL(MAP_TO_ZEROCHANNEL + 3);
ZUNO_ADD_CHANNEL(4,1,66);
// Channel 5 - Thermometer
ZUNO_SET_ZWCHANNEL(MAP_TO_ZEROCHANNEL + 4);
ZUNO_ADD_CHANNEL(4,1,66);
ZUNO_COMMIT_CONFIG();
}
(1 | 0x80) amounts to the same thing as (0x80 +1) so I am essentially assigning the channel twice as I understand it.
Code 2 results in no less than 8 devices being created in the controller:
2 dimmers (both are mapped to channel 1)
1 binary switch (channel 3)
3 thermometers (only one can be controlled). Channel 4 and 5 are mapped to the same device in the controller
2 generic multilevel sensors (unkown channel numbers).
Final attempt is in Code 3 which uses the same approach as code 2, but is based on another sample code which addresses the channels differently. https://z-uno.z-wave.me/examples/multip ... e-sensors/
Here, the first channel is still 0x81 but then it continues with 2,3,4 etc
Code 3:
Code: Select all
ZUNO_ENABLE(WITH_CC_SWITCH_MULTILEVEL WITH_CC_METER WITH_CC_SENSOR_BINARY WITH_CC_SWITCH_COLOR WITH_CC_SENSOR_MULTILEVEL WITH_CC_DOORLOCK WITH_CC_SWITCH_BINARY WITH_CC_NOTIFICATION WITH_CC_THERMOSTAT);
ZUNO_DYNAMIC_CHANNELS(32);
void setup() {
ZUNO_START_CONFIG();
// Channel 1 - Switch multilevel
ZUNO_SET_ZWCHANNEL(0x81);
ZUNO_ADD_CHANNEL(2,0,0);
// Channel 2 - Switch multilevel
ZUNO_SET_ZWCHANNEL(2);
ZUNO_ADD_CHANNEL(2,0,0);
// Channel 3 - Switch binary
ZUNO_SET_ZWCHANNEL(3);
ZUNO_ADD_CHANNEL(1,0,0);
// Channel 4 - Thermometer
ZUNO_SET_ZWCHANNEL(4);
ZUNO_ADD_CHANNEL(4,1,66);
// Channel 5 - Thermometer
ZUNO_SET_ZWCHANNEL(5);
ZUNO_ADD_CHANNEL(4,1,66);
ZUNO_COMMIT_CONFIG();
}
1 parent device
3 dimmers
1 binary switch
2 thermometers
2 generic multilevel sensors
My controller is a Fibaro Home Center 2 on the latest SW (4.620).
Any ideas what I am doing wrong here?