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: 7565
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: 21
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: 49
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: 21
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.
Manurev
Posts: 21
Joined: 30 Apr 2023 19:35

Re: Binary sensor on Fibaro HC3

Post by Manurev »

Hello good evening.
-.I can't get the Binary Sensor to work.-
Well, I wanted to comment that I have not been able to activate the Binary Sensor in the Z-Uno V2.0, for the HC-1.YUBII Home from Fibaro. Version 5.150.18. Similar to HC-3. I can't get it to work. I have tried all the possible arguments, in the "Return" in a simple sketch, for example. "Simple sensor." From Z-Wave Me.
Arguments. LOW, HIGH, 1, 0, 00, ff, ffff, 0xff, I've tried everything.
And the little man, it doesn't change, the sensor, it always says that there has been no change. He doesn't even flinch, he doesn't do anything. Does not communicate changes.
The circuit is like the example, "Simple Sensor", should I put a physical pull up resistor? Should I connect the button to ground, (-) or positive (+)? Is there some essential condition that I am missing? What am I doing wrong? I've tried everything.
Also say that I have created other channels, such as the Binary Switch, and the Multilevel Sensor, and they work perfectly.
The same thing happened to me last year with another Z-Uno v2 module, and with another version of the previous Fibaro software, and I couldn't make it work, I had to create binary switches, when in my project they are only binary sensors.
I'm desperate with this, I would appreciate some help.
yves
Posts: 49
Joined: 17 Sep 2021 18:05

Re: Binary sensor on Fibaro HC3

Post by yves »

Hi Manurev,

If you are still using the code included in above post, then here might be your bug:
'getter()' is THE function that is call by zunoSendReport to know what is the value to send.

So replacing:

Code: Select all

byte getter(void)
{
  return 0;
}
with:

Code: Select all

byte getter(void)
{
  return ledColor;
}
Should leads you closer to the solution...

PS: I use HC3 and have binarySensors working...
Regards.
Manurev
Posts: 21
Joined: 30 Apr 2023 19:35

Re: Binary sensor on Fibaro HC3

Post by Manurev »

Good afternoon. Thanks for answering.
Ok, I have put all those values in the "getter","return" function.
LOW, HIGH, 1, 0, 00, ff, ffff, 0xff,
But it doesn't change anything.
This is the example I used, from the Z-Uno example page of Z.waveme.

https://z-uno.z-wave.me/examples/SimpleSensor/

I do not know what the problem might be.
yves
Posts: 49
Joined: 17 Sep 2021 18:05

Re: Binary sensor on Fibaro HC3

Post by yves »

Hi Manurev

I would have added following lines before ZUNO_SETUP_CHANNELS():

Code: Select all

//Define 'static inclusion'
ZUNO_DISABLE(NO_MULTIBINARY_SWITCH0);

//define here all other flags
ZUNO_ENABLE(
//ZUNO flag requested
        MODERN_MULTICHANNEL  // No clusters, the first channel is mapped to NIF only
        MODERN_MULTICHANNEL_S2  // S2 encapsulated NIF in multichannel
        MODERN_MULTICHANNEL_S2_ALWAYS // Add S2 to multichannel if device included non-secure            
        WITH_CC_SENSOR_MULTILEVEL 
        WITH_CC_SENSOR_BINARY 
        WITH_CC_BASIC 
        WITH_CC_SWITCH_MULTILEVEL 
        WITH_CC_SWITCH_BINARY
);

ZUNO_SETUP_CHANNELS(....
Regards
Post Reply