Issue with triggers from multiple inputs

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
rpalmer68
Posts: 3
Joined: 22 Jul 2019 14:08
Location: Sydney, Australia

Issue with triggers from multiple inputs

Post by rpalmer68 »

Hi,

I have written the sketch below from examples I found here, but I'm very new to this so think I have made a mistake as it not quite working as I expected and just can't work out why!

I have 8 relays connected to my alarm system that mirror the 8 PIRs in my house that I want to trigger lights from, each relay is connected to an input pin on the Z-Uno (pins 24, 25, and 3 - 8).

I have the relays connected to the Z-Uno ground line, so when they close the input pin on the Z-Uno gets taken to ground, the relays stay closed for 30 seconds when triggered.

All seems to be basically working, except for some reason when Relay 1 closes (connected to pin 24) I get motion notifications in Homeseer for Relay 1 AND Relay 6 (connected to pin 6), but if Relays 2 through to 8 close I only get a motion notification for the single relay, which is what I was expecting.

I have tested the wiring and also the relays and can confirm there are no shorts between the inputs and the relays are operating as expected, so I have to assume it's something I have got wrong in my code.

Here is an example for my Homeseer logs:

This is when the PIR in the hallway is triggered (relay 1) as you can see relay 6 (in another unoccupied room also triggers),
Jul-22 9:40:00 PM Event Event Trigger "Floor Lights Motion Detected - Study"
Jul-22 9:40:00 PM Z-Wave Device: Node 32 Z-Wave Relay 6 - Study Sensor Set to On/Open/Motion
Jul-22 9:40:00 PM Event Event Trigger "Floor Lights Motion Detected - Hallway"
Jul-22 9:40:00 PM Z-Wave Device: Node 32 Z-Wave Relay 1 - Upstairs Hallway Sensor Set to On/Open/Motion

This is when other PIRs in different locations are triggered, as you can see they only trigger the one event:
Jul-22 9:21:03 PM Event Event Trigger "Floor Lights Motion Detected - Lounge"
Jul-22 9:21:03 PM Z-Wave Device: Node 32 Z-Wave Relay 3 - Lounge Sensor Set to On/Open/Motion
Jul-22 9:20:56 PM Event Event Trigger "Floor Lights Motion Detected - Kitchen"
Jul-22 9:20:56 PM Z-Wave Device: Node 32 Z-Wave Relay 4 - Kitchen Sensor Set to On/Open/Motion


So could somebody please have a look at the code below and tell me if I have done something wrong??

Many many thanks
Richard

Code: Select all

// Pin definitions
#define LED_PIN 13
#define MotionInput_1 24
#define MotionInput_2 25
#define MotionInput_3 3
#define MotionInput_4 4
#define MotionInput_5 5
#define MotionInput_6 6
#define MotionInput_7 7
#define MotionInput_8 8


#define RelaxMotionTime 3000  //  ~3 sec relax time
#define SWITCH_ON 0xff
#define SWITCH_OFF 0

// Global variables
byte lastMotionValue_1 = 0;
byte lastMotionValue_2 = 0;
byte lastMotionValue_3 = 0;
byte lastMotionValue_4 = 0;
byte lastMotionValue_5 = 0;
byte lastMotionValue_6 = 0;
byte lastMotionValue_7 = 0;
byte lastMotionValue_8 = 0;
word relaxMotion_1 = 0;
word relaxMotion_2 = 0;
word relaxMotion_3 = 0;
word relaxMotion_4 = 0;
word relaxMotion_5 = 0;
word relaxMotion_6 = 0;
word relaxMotion_7 = 0;
word relaxMotion_8 = 0;


ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_ALWAYS_AWAKE);


// Z-Wave channels
ZUNO_SETUP_CHANNELS(
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterMotion_1),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterMotion_2),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterMotion_3),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterMotion_4),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterMotion_5),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterMotion_6),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterMotion_7),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterMotion_8)  
);

void setup() {
  // set up I/O pins.
  pinMode(LED_PIN, OUTPUT);
  pinMode(MotionInput_1, INPUT_PULLUP);
  pinMode(MotionInput_2, INPUT_PULLUP);
  pinMode(MotionInput_3, INPUT_PULLUP);
  pinMode(MotionInput_4, INPUT_PULLUP);
  pinMode(MotionInput_5, INPUT_PULLUP);
  pinMode(MotionInput_6, INPUT_PULLUP);
  pinMode(MotionInput_7, INPUT_PULLUP);
  pinMode(MotionInput_8, INPUT_PULLUP);
}

void loop() {
  byte currentMotionValue_1;
  byte currentMotionValue_2;
  byte currentMotionValue_3;
  byte currentMotionValue_4;
  byte currentMotionValue_5;
  byte currentMotionValue_6;
  byte currentMotionValue_7;  
  byte currentMotionValue_8;  

// Trigger motion and wait for relax before report idle
  
// Input 1
  currentMotionValue_1 = !digitalRead(MotionInput_1);
  if (currentMotionValue_1) {
    if (relaxMotion_1 == 0) {
      lastMotionValue_1 = 1;
      zunoSendReport(1);
      digitalWrite(LED_PIN, HIGH);        // turn LED on
    }
    relaxMotion_1 = RelaxMotionTime; 
  }

  if (lastMotionValue_1 == 1 && relaxMotion_1 == 0) {
    lastMotionValue_1 = 0; 
    zunoSendReport(1);
   }
    
//Input 2
  currentMotionValue_2 = !digitalRead(MotionInput_2);
  if (currentMotionValue_2) {
    if (relaxMotion_2 == 0) {
      lastMotionValue_2 = 1;
      zunoSendReport(2);
      digitalWrite(LED_PIN, HIGH);        // turn LED on
    }
    relaxMotion_2 = RelaxMotionTime;
  }

  if (lastMotionValue_2 == 1 && relaxMotion_2 == 0) {
    lastMotionValue_2 = 0; 
    zunoSendReport(2);
    
  }
  
//Input 3
  currentMotionValue_3 = !digitalRead(MotionInput_3);
  if (currentMotionValue_3) {
    if (relaxMotion_3 == 0) {
      lastMotionValue_3 = 1;
      zunoSendReport(3);
      digitalWrite(LED_PIN, HIGH);        // turn LED on      
    }
    relaxMotion_3 = RelaxMotionTime;
  }

  if (lastMotionValue_3 == 1 && relaxMotion_3 == 0) {
    lastMotionValue_3 = 0; 
    zunoSendReport(3);
   }

//Input 4
  currentMotionValue_4 = !digitalRead(MotionInput_4);
  if (currentMotionValue_4) {
    if (relaxMotion_4 == 0) {
      lastMotionValue_4 = 1;
      zunoSendReport(4);
      digitalWrite(LED_PIN, HIGH);        // turn LED on      
    }
    relaxMotion_4 = RelaxMotionTime;
  }

  if (lastMotionValue_4 == 1 && relaxMotion_4 == 0) {
    lastMotionValue_4 = 0; 
    zunoSendReport(4);
  }

    
//Input 5
  currentMotionValue_5 = !digitalRead(MotionInput_5);
  if (currentMotionValue_5) {
    if (relaxMotion_5 == 0) {
      lastMotionValue_5 = 1;
      zunoSendReport(5);
      digitalWrite(LED_PIN, HIGH);        // turn LED on      
    }
    relaxMotion_5 = RelaxMotionTime;
  }

  if (lastMotionValue_5 == 1 && relaxMotion_5 == 0) {
    lastMotionValue_5 = 0; 
    zunoSendReport(5);
  }

      
//Input 6
  currentMotionValue_6 = !digitalRead(MotionInput_6);
  if (currentMotionValue_6) {
    if (relaxMotion_6 == 0) {
      lastMotionValue_6 = 1;
      zunoSendReport(6);
      digitalWrite(LED_PIN, HIGH);        // turn LED on      
    }
    relaxMotion_6 = RelaxMotionTime;
  }

  if (lastMotionValue_6 == 1 && relaxMotion_6 == 0) {
    lastMotionValue_6 = 0; 
    zunoSendReport(6);
  }



//Input 7
  currentMotionValue_7 = !digitalRead(MotionInput_7);
  if (currentMotionValue_7) {
    if (relaxMotion_7 == 0) {
      lastMotionValue_7 = 1;
      zunoSendReport(7);
      digitalWrite(LED_PIN, HIGH);        // turn LED on      
    }
    relaxMotion_7 = RelaxMotionTime;
  }

  if (lastMotionValue_7 == 1 && relaxMotion_7 == 0) {
    lastMotionValue_7 = 0; 
    zunoSendReport(7);
  }

//Input 8
  currentMotionValue_8 = !digitalRead(MotionInput_8);
  if (currentMotionValue_8) {
    if (relaxMotion_8 == 0) {
      lastMotionValue_8 = 1;
      zunoSendReport(8);
      digitalWrite(LED_PIN, HIGH);        // turn LED on      
    }
    relaxMotion_8 = RelaxMotionTime;
  }

  if (lastMotionValue_8 == 1 && relaxMotion_8 == 0) {
    lastMotionValue_8 = 0; 
    zunoSendReport(8);
  }

  if (relaxMotion_1) relaxMotion_1--;
  if (relaxMotion_2) relaxMotion_2--;
  if (relaxMotion_3) relaxMotion_3--;
  if (relaxMotion_4) relaxMotion_4--;
  if (relaxMotion_5) relaxMotion_5--;
  if (relaxMotion_6) relaxMotion_6--;
  if (relaxMotion_7) relaxMotion_7--;
  if (relaxMotion_8) relaxMotion_8--;

  if (lastMotionValue_1 == 0 && lastMotionValue_2 == 0 && lastMotionValue_3 == 0 && lastMotionValue_4 == 0 && lastMotionValue_5 == 0 && lastMotionValue_6 == 0 && lastMotionValue_7 == 0 && lastMotionValue_8 == 0) {
     digitalWrite(LED_PIN, LOW);         // turn LED off
  }
}


// Getters and setters
byte getterMotion_1(void) {
  return lastMotionValue_1 ? 0xff : 0;
}

byte getterMotion_2(void) {
  return lastMotionValue_2 ? 0xff : 0;
}

byte getterMotion_3(void) {
  return lastMotionValue_3 ? 0xff : 0;
}

byte getterMotion_4(void) {
  return lastMotionValue_4 ? 0xff : 0;
}

byte getterMotion_5(void) {
  return lastMotionValue_5 ? 0xff : 0;
}

byte getterMotion_6(void) {
  return lastMotionValue_6 ? 0xff : 0;
}

byte getterMotion_7(void) {
  return lastMotionValue_7 ? 0xff : 0;
}

byte getterMotion_8(void) {
  return lastMotionValue_8 ? 0xff : 0;
}
User avatar
PoltoS
Posts: 7571
Joined: 26 Jan 2011 19:36

Re: Issue with triggers from multiple inputs

Post by PoltoS »

Hi!

We have heard about such problems with HomeSeer. Please write to their support - it is on their side and they claim to fix it a year ago.

HS support do have a Z-Uno to make tests. You can keep us in CC so we can assist.
rpalmer68
Posts: 3
Joined: 22 Jul 2019 14:08
Location: Sydney, Australia

Re: Issue with triggers from multiple inputs

Post by rpalmer68 »

Here's the response I finally received last night:
This device has never been tested here so it is likely not fully compatible. I have submitted a bug report to our development team who will look into it as soon as possible. If we have any further questions about this particular bug we'll reach out to you directly, otherwise, we will update your ticket when the issue has been resolved.
I guess we now wait and see hat happens next.
Post Reply