Page 1 of 1

zunoSendReport in the Setup routine

Posted: 13 Mar 2019 18:33
by aleconakad
I want in my sketch to revert the relays defined in channel 1 to 3 to the default state after a restart event. I do it like this:

Code: Select all

void setup() {
relais1_state = 0;
relais2_state = 0;
relais3_state = 0;

zunoSendReport (1);
zunoSendReport (2);
zunoSendReport (3);
}

void loop() {
...
}

byte relais1_getter() {
  if (relais1_state) {
    return ZUNO_SWITCHED_ON;
  } else {
    return ZUNO_SWITCHED_OFF;
  }
}

byte relais2_getter() {
  if (relais2_state ) {
    return ZUNO_SWITCHED_ON;
  } else {
    return ZUNO_SWITCHED_OFF;
  }
}

byte relais3_getter() {
  if (relais3_state ) {
    return ZUNO_SWITCHED_ON;
  } else {
    return ZUNO_SWITCHED_OFF;
  }
}
is this allowed? does it have any side effects? will the Z-Wave stack be fully initialized before running code from the setup() routine?

thanks

Re: zunoSendReport in the Setup routine

Posted: 14 Mar 2019 21:13
by PoltoS
No! As stated in the documentation, setup () bus only for hardware initialization.

Define a variable book firstBoot = True and in the loop:
if (firstBoot) { firstBoot = false; zunoSendReport(....); ... }