I have the following sketch that used to work on the old Fibaro HC3 z-wave engine, but since migrating to the new engine (3) and the latest firmware (5.130.64) the moment I add a binary switch into the sketch, I no longer see all the sensors and switches declared in the sketch - but only a subset of them. The code is attached below. The sketch as it is works as expected, but if I uncomment the float sensor (binary sensor) then not all the sensors are discovered. Moving the order of the channels around results in a different set of end-points being discovered. I am using a Z-Uno revision 1.
Code: Select all
#define PIN_PUMP 11
#define PIN_VALVE_TOGGLE 12
#define PIN_FLOAT_SWITCH 14
byte pumpValue = 0;
byte valveValue = 0;
byte lastFloatValue = 0;
int16_t lastTank1Level = 0;
int16_t lastTank2Level = 0;
enum{
PUMP_SWITCH_CHANNEL = 1,
VALVE_SWITCH_CHANNEL,
//FLOAT_SENSOR_CHANNEL,
TANK1_SENSOR_CHANNEL,
TANK2_SENSOR_CHANNEL
};
ZUNO_SETUP_CHANNELS(
ZUNO_SWITCH_BINARY(pumpValue, NULL),
ZUNO_SWITCH_BINARY(valveValue, NULL),
//ZUNO_SENSOR_BINARY_TILT(lastFloatValue),
ZUNO_SENSOR_MULTILEVEL_DISTANCE(lastTank1Level),
ZUNO_SENSOR_MULTILEVEL_DISTANCE(lastTank2Level)
);
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_ALWAYS_AWAKE);
void setup() {
// put your setup code here, to run once:
pinMode(PIN_PUMP, OUTPUT);
pinMode(PIN_VALVE_TOGGLE, OUTPUT);
pinMode(PIN_FLOAT_SWITCH, INPUT_PULLUP);
}
unsigned long float_last_update = 0;
unsigned long valve_last_update = 0;
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(PIN_PUMP, pumpValue);
digitalWrite(PIN_VALVE_TOGGLE, valveValue);
if (valveValue != 0) {
if (valve_last_update == 0) {
valve_last_update = millis();
} else {
if (millis() > valve_last_update + 2000) {
valveValue = 0;
valve_last_update = 0;
zunoSendReport(VALVE_SWITCH_CHANNEL);
}
}
}
byte currentFloatValue = digitalRead(PIN_FLOAT_SWITCH);
if (currentFloatValue != lastFloatValue) {
lastFloatValue = currentFloatValue;
//zunoSendReport(FLOAT_SENSOR_CHANNEL);
}
int16_t currentTank1Level = (millis() / 10000);
if (abs(currentTank1Level - lastTank1Level) > 0) {
lastTank1Level = currentTank1Level;
zunoSendReport(TANK1_SENSOR_CHANNEL);
}
int16_t currentTank2Level = (millis() / 12000);
if (abs(currentTank2Level - lastTank2Level) > 0) {
lastTank2Level = currentTank2Level;
zunoSendReport(TANK2_SENSOR_CHANNEL);
}
delay(50);
}