Binary sensor on Fibaro HC3

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
jrossouw
Posts: 16
Joined: 22 Sep 2020 12:38

Binary sensor on Fibaro HC3

Post by jrossouw »

Hi,

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);
}
User avatar
PoltoS
Posts: 7562
Joined: 26 Jan 2011 19:36

Re: Binary sensor on Fibaro HC3

Post by PoltoS »

We need to check it, but I think a ticket to Fibaro is required. As you see, they changed their engine very much passing to version 3
Spectator
Posts: 1
Joined: 24 May 2023 11:17

Re: Binary sensor on Fibaro HC3

Post by Spectator »

Greetings!

I'd like you to help me with z-uno. So i included z-uno in fibaro hc3 network. There's just one channel in z-uno - ZUNO_SENSOR_BINARY (TYPE_MOTION).
But it doesn't work properly. The problem begins when i'm trying to stop alarming (motion detecting).
It works fine when you send report first time (using ZUNO_SENDREPORT) with value HIGH (or 1): the sign of a man in controller changes to a walking man.
On the opposite when you try to send report with value LOW (or 0) the sign of a man doesn't change to a standing man.

I'm using Z-UNO2 with further code (in Arduino IDE):

Code: Select all

ZUNO_SETUP_CHANNELS(ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getter));
byte ledColor;
 
void setup()
{
}
 
void loop()
{
  if (ledColor==LOW) {ledColor=HIGH;} else {ledColor=LOW;}
  digitalWrite(LED_BUILTIN,ledColor);
  zunoSendReport(1);
  delay(3000);
}
 
byte getter(void)
{
  return 0;
}
I tried to do next steps:
1) Changed parameter 11 of ZUNO channel, obviously this can't help due to the type of SENSOR (BINARY, not MULTILEVEL)
2) Left just one lifeline association in controller: there are two association by default: singlechannel and multichannel.

What am i doing wrong?
Manurev
Posts: 15
Joined: 30 Apr 2023 19:35

Re: Binary sensor on Fibaro HC3

Post by Manurev »

Hello, I'm Manu, I have a Z1 V2, with Fibaro HC1 Yubii home and the same thing happens to me, I can't get the Binary Sensor to work. Have you achieved anything so far?
Greetings
yves
Posts: 44
Joined: 17 Sep 2021 18:05

Re: Binary sensor on Fibaro HC3

Post by yves »

Hi all,
As a late reply and as a gobal rule :
Do not comment partially ZUNO macros (such as ZUNO_SETUP_CHANNELS), especially using "//".
Unpredictable results are granted!!

This is not a ZUNO/arduino 'bug' but C macro 'properties'.

Instead, if you want to keep track of your tests:
  • Duplicate the FULL macro,
  • comment one copy (inside /* and */),
  • then modify the other.
Then you will be 'sure' of what will be the result.

Regards,

PS Same apply adding simple comments inside a macro using "//" : bad idea...
Manurev
Posts: 15
Joined: 30 Apr 2023 19:35

Re: Binary sensor on Fibaro HC3

Post by Manurev »

Hello

Very interesting.
Thanks for the information. It helps me a lot.
Greetings.
Post Reply