Z-UNO 2 Channel configuration not working with HC2

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
yves
Posts: 51
Joined: 17 Sep 2021 18:05

Z-UNO 2 Channel configuration not working with HC2

Post by yves »

Hi,

I am trying to include 'something' in a fibaro HC2 network
(Up to now I was succesfully using Z-uno-1)
  • Z-Uno bootloader version:3.0.9
    Security:none
    Frequency:EU
    Device included:yes/no I would like !!!
    Device included securely by controller:yes/no
    Controller:Fibaro HC2
I have tried many things using dynamic configuration.
Unsuccessful I went back to a basic static configuration:

Code: Select all

#include "Arduino.h"
#include "ArduinoTypes.h"

#if (ZUNO_CORE_VERSION_MAJOR < 3)
#error "-------             This code should be complied for ZUNO 2 target"
#endif

  #define SPDBGSTART(X) Serial.begin(X)
  #define SPDBG(...)      Serial.print(__VA_ARGS__)
  #define SPDBGLN(...)    Serial.println(__VA_ARGS__)

uint32_t switchValue[2];
uint32_t dimmerValue[2];
ZUNO_SETUP_CHANNELS(
  ZUNO_SWITCH_BINARY(switchValue, NULL)
  ZUNO_SWITCH_BINARY(switchValue, NULL)
  ZUNO_SWITCH_MULTILEVEL(dimmerValue, NULL),
  ZUNO_SWITCH_MULTILEVEL(dimmerValue, NULL),
);

// SETUP      SETUP      SETUP      SETUP      SETUP      SETUP      SETUP     
//_________________________________________________________________________________
void setup() {
  SPDBGSTART(57600);
  SPDBGLN(" ");
  SPDBGLN("SetupStart");
  pinMode(BUILTIN_LED_PIN, OUTPUT);
  SPDBGLN("INIT Done");
}

//  LOOP               LOOP               LOOP               LOOP               LOOP             
//_________________________________________________________________________________
void loop() {  
    digitalWrite(BUILTIN_LED_PIN, HIGH);
    delay(2000);
    digitalWrite(BUILTIN_LED_PIN, LOW);
    delay(500);
}
whatever I try, the result is the same : after 'said inclusion' I get only one switch, probably the one bound to chan 0, not mine...:
Image

Any idea/advice that may help?
Thanks,
Yves
Attachments
HC2AfterIncusion.jpg
HC2AfterIncusion.jpg (42.16 KiB) Viewed 2559 times
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: Z-UNO 2 Channel configuration not working with HC2

Post by p0lyg0n1 »

Hi,
Please try this code at the beginning of your sketches

Code: Select all

ZUNO_ENABLE(            
	    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
        );
It enables support for the latest innovations in the Multichannel command class. This approach should help.

Best regards,
Alex.
yves
Posts: 51
Joined: 17 Sep 2021 18:05

Re: Z-UNO 2 Channel configuration not working with HC2

Post by yves »

Hi p0lyg0n1,

Applied 'as it', it does not work at all: it loops infinitly while adding the board to HC2.
Looking closer, the precompilation phase does not seem to find what it is looking for:
preprocessing "TestInclude.ino" .............................. ***Warning! Function prototypes were generated the wrong way. Function body before the function prototypes. Please organize the sketch right way: #includes/typedefs/ZUNO_SETUP_CHANNELS/functions()
***OUT:___zunoEnableList
error:C:\Users\yvesg\AppData\Local\Temp\arduino_build_647852\\TestInclude_ino.cpp:32 ZUNOPREPROC Problems in ZUNO_SETUP_CHANNELS macro. Can't compile it! Please check the spelling inside the brackets!
error:C:\Users\yvesg\AppData\Local\Temp\arduino_build_647852\\TestInclude_ino.cpp:82 ZUNOPREPROC Problems in ZUNO_SETUP_CHANNELS macro. Can't compile it! Please check the spelling inside the brackets!


(But then the rest of the code is compiled and uploaded : that is confusing!)

I have found a workaround to my problem described in next post.
Sincerly I hope it is only a temporary workaround. It works but that is very heavy (code and actions required)!

Thanks
yves
Posts: 51
Joined: 17 Sep 2021 18:05

Re: Z-UNO 2 Channel configuration not working with HC2

Post by yves »

Hi everyone,
I have found workarounds to be able to include Z-uno2 in HC2. It works but it is very heavy:
  • The code must be both static and dynamic ???
  • The inclusion is a 15(!!) steps 'procedure' that, in fact, implies 3 consecutives configurations. It looks as if there were somes timeouts fights between Z-uno & HC2 during inclusion.


I hope anyway that it will help someone that does not want to wait for next release.

CODE: It is largely inspired from ZunoTest.ino (the certified ZWave device).
The astounding fact is that it includes both a static declaration of devices to include and a dynamic one. I can’t really figure out why, to me it reduces a lot 'dynamic code' interest ?
The static declaration part seems to be required to declare some memory space to be saved ‘before’ the real compilation:
Somewhere at the beginning of compilation, the following message appears:Core version: 03.09 Channels:x, where x is the number of channel declared by the ‘static code’. Check that it is what you require.

Other strange thing : the ‘dynamic code’ must include at least one zunoAddAssociation(). So most of the time there will be 2 groups in HC2 but that is not always the case, even when it works.
This is probably the next bug, but so far, I am not using groups….

Here it is :

Code: Select all

#include "Arduino.h"
#include "ArduinoTypes.h"
#define ZUNO_STATICGATHERING_PHASE
#include "ZUNO_StaticData.h"

#if (ZUNO_CORE_VERSION_MAJOR < 3)
#error "-------             This code should be complied for ZUNO 2 target"
#endif
#define SPDBGSTART(X) Serial.begin(X)
#define SPDBG(...)      Serial.print(__VA_ARGS__)
#define SPDBGLN(...)    Serial.println(__VA_ARGS__)
#define BUILTIN_LED_PIN 13

ZUNO_DISABLE(NO_MULTIBINARY_SWITCH0);
ZUNO_ENABLE(WITH_CC_SENSOR_MULTILEVEL WITH_CC_SENSOR_BINARY WITH_CC_BASIC WITH_CC_SWITCH_MULTILEVEL WITH_CC_SWITCH_BINARY);

uint32_t au32myZwaveValues[10];
ZUNO_SETUP_CHANNELS(
  ZUNO_SWITCH_BINARY(au32myZwaveValues[0], NULL),
  ZUNO_SWITCH_BINARY(au32myZwaveValues[1], NULL),
  ZUNO_SWITCH_MULTILEVEL(au32myZwaveValues[2], NULL),
  ZUNO_SWITCH_MULTILEVEL(au32myZwaveValues[3], NULL),
  ZUNO_SENSOR_MULTILEVEL_VOLTAGE(au32myZwaveValues[4]),
  ZUNO_SENSOR_MULTILEVEL_VOLTAGE(au32myZwaveValues[5]),
  ZUNO_SENSOR_MULTILEVEL_VOLTAGE(au32myZwaveValues[6])
);


// SETUP      SETUP      SETUP      SETUP      SETUP      SETUP      SETUP     
//_________________________________________________________________________________
void setup() {

  SPDBGSTART(57600);  SPDBGLN("SetupStart");
  
  pinMode(BUILTIN_LED_PIN, OUTPUT);
  if(zunoStartDeviceConfiguration()) {
    SPDBGLN("NewConf");
		zunoAddChannel(1,0,0);
		zunoSetZWChannel( 0, 0x01 | ZWAVE_CHANNEL_MAPPED_BIT);
		zunoAddChannel(1,0,0);
		zunoSetZWChannel( 1, 0x02);
    
		zunoAddChannel(2,0,0);
		zunoSetZWChannel( 2, 0x03);
		zunoAddChannel(2,0,0);
		zunoSetZWChannel( 3, 0x04);
    
    zunoAddChannel(4,ZUNO_SENSOR_MULTILEVEL_TYPE_VOLTAGE,34);
		zunoSetZWChannel( 4, 0x05);
    zunoAddChannel(4,ZUNO_SENSOR_MULTILEVEL_TYPE_VOLTAGE,34);
		zunoSetZWChannel( 5, 0x06);
    zunoAddChannel(4,ZUNO_SENSOR_MULTILEVEL_TYPE_VOLTAGE,34);
		zunoSetZWChannel( 6, 0x07);
		zunoAddAssociation(1, 0);
		zunoCommitCfg();
	}
  zunoAppendChannelHandler( 0,  1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[0]);
	zunoAppendChannelHandler( 1,  1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[1]);
	zunoAppendChannelHandler( 2,  1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[2]);
	zunoAppendChannelHandler( 3,  1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[3]);
	zunoAppendChannelHandler( 4,  1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[4]);
	zunoAppendChannelHandler( 5,  1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[5]);
	zunoAppendChannelHandler( 6,  1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[6]);
 
  SPDBGLN("INIT Done");
}

//  LOOP               LOOP               LOOP               LOOP               LOOP             
//_________________________________________________________________________________
void loop() {
  static uint32_t u32Count=0;
  uint8_t u8i;
  uint8_t bChgt=false;

  digitalWrite(BUILTIN_LED_PIN, HIGH);delay(2000);
  digitalWrite(BUILTIN_LED_PIN, LOW);delay(500);
  for(u8i=0;u8i<7;u8i++){ SPDBG(u8i);SPDBG(":");SPDBGLN(au32myZwaveValues[u8i]);}
  if (((u32Count /3) % 2) == 0) {bChgt =(au32myZwaveValues[3]!=80); au32myZwaveValues[3]=80;au32myZwaveValues[0] = 255;zunoSendReport(1);zunoSendReport(3);}
  else {bChgt =(au32myZwaveValues[3]!=30);au32myZwaveValues[3]=30;au32myZwaveValues[0] = 0;}
  if (bChgt) {zunoSendReport(1);zunoSendReport(4);}
  if ((u32Count % 20)== 0)
  {
    au32myZwaveValues[4] = u32Count*10;
    zunoSendReport(5);
  }
  u32Count++;
}
INCLUSION PROCEDURE:
1) get Z-uno2 board in rescue mode even with a ligh 'loop code' (you must have a light loop code anyways after step 11, you will replace it later)
2) start 'Add device' on HC2 and triple click on Z-uno2
3) wait & wait & wait...
4) device is added but not configured and only lifeline appears:
1.jpg
1.jpg (42.7 KiB) Viewed 2531 times
5) go to the page of the new master & to the 'advanced' tab
2.jpg
2.jpg (179.23 KiB) Viewed 2531 times
6) click on 'Setting Association' and check, for every groups, that S & M are 'ON'
3.jpg
3.jpg (138.69 KiB) Viewed 2531 times
7) click on 'Reconfigure Device' (red circle above). At this stage you should still be in Rescue mode
8) In the next popup don't be shy and 'YES!!' pretend that you know what you are doing :D.
4.jpg
4.jpg (77.36 KiB) Viewed 2531 times
8) wait & wait & wait...
9) But most of the time it is not finished yet, as you should still be close to 4) :o !!!
10) Repeat step 6 (some other group may have appeared)
11) press reset on the Z-uno2
12) click in the notification icon
5.jpg
5.jpg (204.96 KiB) Viewed 2531 times
13) click on retry
14) wait & wait & wait...
15) this time it should be OK!!!,
6.jpg
6.jpg (49.33 KiB) Viewed 2531 times
If not: try again once from 10), if still KO, then suspect your code, most of the time the bug lies somewhere between keyboard and chair but, in that particular case, understanding of documentation may be also involved :-)

Have a nice day,
Yves
yves
Posts: 51
Joined: 17 Sep 2021 18:05

Re: Z-UNO 2 Channel configuration not working with HC2

Post by yves »

Hi,
Some news:
  1. I confirm that the the following code :

    Code: Select all

    ZUNO_ENABLE(            
    	    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
            );
    does not help, it does not make things worse as well..
  1. I have found another bug :The first included switch does not work (at least the values written by Zuno are not seen on HC2, I didn't check the other way. But the values seen on HC2 are quickly forced to 255.


Yves
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: Z-UNO 2 Channel configuration not working with HC2

Post by p0lyg0n1 »

Hi,
Sketch with code^^^ passes modern certification. Please try the original certification sketch (https://z-uno.z-wave.me/examples/Certified10Ch/), as I wrote before. If you have the same troubles with this sketch, please provide your HC2 firmware version. I'll try to reproduce the issue in our office.

With respect,
Alex.
Post Reply