Page 4 of 5

Re: multiple sensors and vera

Posted: 01 Mar 2018 16:41
by aivs
How to Vera + Z-Uno 5 Binary Sensors

Vera Secure - 1.7.3535
Z-Uno - 2.1.3
Vera5Sensors.png
Vera5Sensors.png (287.67 KiB) Viewed 10426 times
Sketch - 5 Motion Sensors

Code: Select all

#define BINARY_PIN1 18
#define BINARY_PIN2 19
#define BINARY_PIN3 20
#define BINARY_PIN4 21
#define BINARY_PIN5 22

// Global variables to store data reported via getters// Global variables to store data reported via getters
byte lastBinaryValue1;
byte lastBinaryValue2;
byte lastBinaryValue3;
byte lastBinaryValue4;
byte lastBinaryValue5;

ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_ALWAYS_AWAKE);
// Set up 5 channels
ZUNO_SETUP_CHANNELS(
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary1),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary2),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary3),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary4),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary5)
);

void setup() {
  pinMode(BINARY_PIN1, INPUT_PULLUP);
  pinMode(BINARY_PIN2, INPUT_PULLUP);
  pinMode(BINARY_PIN3, INPUT_PULLUP);
  pinMode(BINARY_PIN4, INPUT_PULLUP);
  pinMode(BINARY_PIN5, INPUT_PULLUP);
}

void loop() {
  byte currentBinaryValue1 = digitalRead(BINARY_PIN1);
  byte currentBinaryValue2 = digitalRead(BINARY_PIN2);
  byte currentBinaryValue3 = digitalRead(BINARY_PIN3);
  byte currentBinaryValue4 = digitalRead(BINARY_PIN4);
  byte currentBinaryValue5 = digitalRead(BINARY_PIN5);
  
  if (currentBinaryValue1 != lastBinaryValue1) {
    lastBinaryValue1 = currentBinaryValue1;
    zunoSendReport(1);  
  }

  if (currentBinaryValue2 != lastBinaryValue2) {
    lastBinaryValue2 = currentBinaryValue2;
    zunoSendReport(2);  
  }
  
  if (currentBinaryValue3 != lastBinaryValue3) {
    lastBinaryValue3 = currentBinaryValue3;
    zunoSendReport(3);  
  }

  if (currentBinaryValue4 != lastBinaryValue4) {
    lastBinaryValue4 = currentBinaryValue4;
    zunoSendReport(4);  
  }

  if (currentBinaryValue5 != lastBinaryValue5) {
    lastBinaryValue5 = currentBinaryValue5;
    zunoSendReport(5);  
  }
}

byte getterBinary1() {
    return (lastBinaryValue1 == 0) ? 0 : 255;
}

byte getterBinary2() {
    return (lastBinaryValue2 == 0) ? 0 : 255;
}
byte getterBinary3() {
    return (lastBinaryValue3 == 0) ? 0 : 255;
}
byte getterBinary4() {
    return (lastBinaryValue4 == 0) ? 0 : 255;
}
byte getterBinary5() {
    return (lastBinaryValue5 == 0) ? 0 : 255;
}
Z-Uno sends reports from the channels using multichannel association to Lifeline, but by default Vera sets basic association. So at first need to add Vera into Z-Uno multichannel association.
Choose general widget --> Device Options --> 1 Add Group --> Set to: Z-Wave 0; _Scene Controller 0
multichannelAssoc.png
multichannelAssoc.png (108.23 KiB) Viewed 10426 times
After applying the Association settings should be like this
AssocSettings.png
AssocSettings.png (103.3 KiB) Viewed 10426 times
Now Z-Uno can send Sensor Binary and Alarm via multichannel association.

Need to set the widget type to D_MotionSensor1
In each widgets --> Advanced
device_type = urn:schemas-micasaverde-com:device:MotionSensor:1
device_file = D_MotionSensor1.xml
device_json = D_GenericIO1.json
Should be like this
Advanced.png
Advanced.png (121.38 KiB) Viewed 10426 times

Re: multiple sensors and vera

Posted: 01 Mar 2018 16:50
by petergebruers
Ah! Finally some details about multichannel association on vera! I bet this is a very important point. It has been mentioned before... It is important on other controllers as well. I do not own a "vera" so I cannot test this.

Question... You say "Need to set the widget type to D_MotionSensor1". What happens if you do not do that? I am asking this, because I have mentioned that I think vera needs to have a device specific configuration file...

Re: multiple sensors and vera

Posted: 02 Mar 2018 00:15
by Tillsy
OMFG!!! aivs sir, you are a LEGEND!!!

I simply added that association and, seconds later, everything lit up like a Christmas tree! Have also shorted the pins to ground and, instantly, each one caused the green LED to do a data transmission and the Vera updated the relevant sensor status.

This desperately needs adding to the Z-UNO site - as I'm not the only one to have spent an incredible amount of time on this issue.

Thank you :) :) :) :) :)

Re: multiple sensors and vera

Posted: 02 Mar 2018 00:22
by petergebruers
That is awesome news!

Re: multiple sensors and vera

Posted: 20 May 2018 23:16
by jim_meyer
I am experiencing the same original problem in this thread.... In my case I have 2: ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_DISTANCE...... ) Channels. Based on what I see in the Ardurino Serial Monitor my sketch is running correctly.

When I first pair the Z-Uno with my Vera Edge I get 4 devices... one with the name I assigned when I paired (the "parent") and the other 3 are called "_GET_LANG(generic_sensor,sensor) 1", "_GET_LANG(generic_sensor,sensor) 2", '_GET_LANG(generic_sensor,sensor) 3'.... which I find pretty weird.

All 4 devices have the following Advanced Params:
device_type: urn:schemas-micasaverde-com:device:GenericSensor:1
device_file: D_GenericSensor1.xml
device_json: D_GenericSensor1.json

The "parent" works OK... it updates its CurrentLevel variable on a regular basis.... But the 3 children are really slow to update.... seems like 10 minutes or more. "_GET_LANG(generic_sensor,sensor) 1" displays the same distance as the Parent but does not update as often. "_GET_LANG(generic_sensor,sensor) 3" displays my 2nd distance sensor... but again updates are real slow. "_GET_LANG(generic_sensor,sensor) 4" never updates.

I can go into the "parent" Device Options" and add the Associations as described above in this thread... But entering Device options for any of the children simple displays a "N/A"... so I can not assign Associations to those devices.

Also, there are a lot of Advanced->Variables that are present for the Parent (35 of them) that do not exist for the 3 Children.... which only has 5.

Can anyone shed some light on this and help me get to the point where my second distance sensor updates more often?

Thank you!

Re: multiple sensors and vera

Posted: 23 May 2018 00:10
by PoltoS
You only need to set this Association to 1.0 (Multichannel Association) on the root device

Re: multiple sensors and vera

Posted: 28 Nov 2018 00:17
by jim_meyer
PoltoS wrote:
23 May 2018 00:10
You only need to set this Association to 1.0 (Multichannel Association) on the root device
Sorry, but I still cannot get this to work.... The "root/parent/1st channel" device value in Vera updates every time the Getter in my z-uno code gets called but the "child/2nd channel" device value only updates occasionally when its Getter is called... its value is often up to 15 minutes behind.

In the Vera UI I under the "Parent" device under "Device Options-> Associations" I have added a Group ID of 1 with ZWave and _Scene Controller checked.... so the Association "Set to" is "1,2".... but "Currently" just lists "2".

Any help on this is appreciated.

Re: multiple sensors and vera

Posted: 28 Nov 2018 23:13
by jim_meyer
Looks like I finally got this working.

My last problem was solved by not only checking but also entering a "0" in both the ZWave and _Scene Controller fields when setting those 2 associations for the "parent" device.

Re: multiple sensors and vera

Posted: 24 Dec 2018 22:17
by azvarga
Avis/all, I am able to get the inputs outputs working with VERA and then in a different sketch (thanks to Avis) I can get five inputs to work. Now I am struggling to get 3 outputs and 5 inputs working in the same sketch. Compiles fine and the outputs work but the inputs are behaving strange and very sluggish. Only the first input works but I have to take all five high to get it to turn on and then after taking all low it takes some time to turn off. Just programming I am sure.

The sketch is an integration of a 3 output sketch that works and a 5 input sketch that works. It is likely in the definition of the z-wave channel ? It is pasted in the post below

Any thoughts ?

Re: multiple sensors and vera

Posted: 24 Dec 2018 22:19
by azvarga

Code: Select all

/* 
This sketch is used to interface the Genmon Raspberry Pi microprocessor to the Z-Uno Z-wave Arduino processor to provide a Z-wave interface between the generator and the VERA Plus home controller

		          		PI       Z-Uno	
STATUS_READY		16	18	
STATUS_ALARM		18	19	
STATUS_SERVICE 		22	17
STATUS_RUNNING		26	20	
STATUS_EXERCISING		24	21	
STATUS_OFF			21	22	
					
INPUT_STOP			11	9	
INPUT_START			13	10	
INPUT_TRANSFER		15	11	

Off - LOW
On - HIGH
*/

// Pins definitions

#define LedPin1 9
#define LedPin2 10
#define LedPin3 11
#define BINARY_PIN1 18
#define BINARY_PIN2 19
#define BINARY_PIN3 20
#define BINARY_PIN4 21
#define BINARY_PIN5 22

// Global variables to store data reported via getters// Global variables to store data reported via getters

byte switchValue1 = 1;
byte switchValue2 = 1;
byte switchValue3 = 1;
byte lastBinaryValue1;
byte lastBinaryValue2;
byte lastBinaryValue3;
byte lastBinaryValue4;
byte lastBinaryValue5;

ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_ALWAYS_AWAKE);

// Set up 3 output channels and 5 input channels

ZUNO_SETUP_CHANNELS(
  ZUNO_SWITCH_BINARY(getterSwitch1, setterSwitch1),
  ZUNO_SWITCH_BINARY(getterSwitch2, setterSwitch2),
  ZUNO_SWITCH_BINARY(getterSwitch3, setterSwitch3),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary1),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary2),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary3),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary4),
  ZUNO_SENSOR_BINARY(ZUNO_SENSOR_BINARY_TYPE_MOTION, getterBinary5)
);

// set up I/O pins. 

void setup() {
  pinMode(LedPin1, OUTPUT);
  pinMode(LedPin2, OUTPUT);
  pinMode(LedPin3, OUTPUT);
  pinMode(BINARY_PIN1, INPUT_PULLUP);
  pinMode(BINARY_PIN2, INPUT_PULLUP);
  pinMode(BINARY_PIN3, INPUT_PULLUP);
  pinMode(BINARY_PIN4, INPUT_PULLUP);
  pinMode(BINARY_PIN5, INPUT_PULLUP);
}

void loop() {
    byte currentBinaryValue1 = digitalRead(BINARY_PIN1);
  byte currentBinaryValue2 = digitalRead(BINARY_PIN2);
  byte currentBinaryValue3 = digitalRead(BINARY_PIN3);
  byte currentBinaryValue4 = digitalRead(BINARY_PIN4);
  byte currentBinaryValue5 = digitalRead(BINARY_PIN5);
  
  if (currentBinaryValue1 != lastBinaryValue1) {
    lastBinaryValue1 = currentBinaryValue1;
    zunoSendReport(1);  
  }

  if (currentBinaryValue2 != lastBinaryValue2) {
    lastBinaryValue2 = currentBinaryValue2;
    zunoSendReport(2);  
  }
  
  if (currentBinaryValue3 != lastBinaryValue3) {
    lastBinaryValue3 = currentBinaryValue3;
    zunoSendReport(3);  
  }

  if (currentBinaryValue4 != lastBinaryValue4) {
    lastBinaryValue4 = currentBinaryValue4;
    zunoSendReport(4);  
  }

  if (currentBinaryValue5 != lastBinaryValue5) {
    lastBinaryValue5 = currentBinaryValue5;
    zunoSendReport(5);  
  }
}

// Getters and setters

void setterSwitch1(byte value) {
  digitalWrite(LedPin1, (value > 0) ? HIGH : LOW);
  switchValue1 = value;
}

byte getterSwitch1(){
  return switchValue1;
}

 void setterSwitch2(byte value) {
  digitalWrite(LedPin2, (value > 0) ? HIGH : LOW);
  switchValue2 = value;
}

byte getterSwitch2(){
  return switchValue2;
}

void setterSwitch3(byte value) {
  digitalWrite(LedPin3, (value > 0) ? HIGH : LOW);
  switchValue3 = value;
}

byte getterSwitch3(){
  return switchValue3;
}

byte getterBinary1() {
    return (lastBinaryValue1 == 0) ? 0 : 255;
}

byte getterBinary2() {
    return (lastBinaryValue2 == 0) ? 0 : 255;
}
byte getterBinary3() {
    return (lastBinaryValue3 == 0) ? 0 : 255;
}
byte getterBinary4() {
    return (lastBinaryValue4 == 0) ? 0 : 255;
}
byte getterBinary5() {
    return (lastBinaryValue5 == 0) ? 0 : 255;
}