Z Uno Tellstick

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
Geirbakke
Posts: 7
Joined: 22 May 2017 16:09

Z Uno Tellstick

Post by Geirbakke » 30 May 2017 23:16

What am I doing wrong?
I can't get the status change for the input pins.

Code: Select all

#define Relay_PIN_1 19 //Relay 1
#define Relay_PIN_2 20 //Relay 2
#define Relay_PIN_3 21 //Relay 3
#define Relay_PIN_4 22 //Relay 4
#define Sensor_PIN_1  17 //Sensor 1
#define Sensor_PIN_2  18 //Sensor 2
#define Door_PIN_1  12 //Door 1
#define Door_PIN_2  13 //Door 2
#define Door_PIN_3  14 //Door 3
#define Disable_Alarm   15 //Button

#define SWITCH_ON 0xff
#define SWITCH_OFF 0


ZUNO_SETUP_DEBUG_MODE(DEBUG_ON);


// Global variables to store data reported via getters
byte currentRelay_1_Value = 0; //Relay 1
byte currentRelay_2_Value = 0; //Relay 2
byte currentRelay_3_Value = 0; //Relay 3
byte currentRelay_4_Value = 0; //Relay 4
byte LastSensor_1_state = 0; //Sensor 1
word relaxMotion_1 = 0; //Sensor 1
byte LastSensor_2_state = 0; //Sensor 2
word relaxMotion_2 = 0; //Sensor 2
byte LastDoor_1_state = 0; //Door 1
byte LastDoor_2_state = 0; //Door 2
byte LastDoor_3_state = 0; //Door 3
byte LastDisable_Alarm_state = 0; //Disable Alarm button


ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_ALWAYS_AWAKE);

ZUNO_SETUP_ASSOCIATIONS(ZUNO_ASSOCIATION_GROUP_SET_VALUE); // Send Basic Set to association group


// Set up 10 channels
ZUNO_SETUP_CHANNELS(
  ZUNO_SWITCH_BINARY(getterSwitch1, setterSwitch1),
  ZUNO_SWITCH_BINARY(getterSwitch2, setterSwitch2),
  ZUNO_SWITCH_BINARY(getterSwitch3, setterSwitch3),
  ZUNO_SWITCH_BINARY(getterSwitch4, setterSwitch4),
  ZUNO_SENSOR_BINARY_MOTION(getterSensor1),
  ZUNO_SENSOR_BINARY_MOTION(getterSensor2),
  ZUNO_SENSOR_BINARY_DOOR_WINDOW(getterDoor1),
  ZUNO_SENSOR_BINARY_DOOR_WINDOW(getterDoor2),
  ZUNO_SENSOR_BINARY_DOOR_WINDOW(getterDoor3),
  ZUNO_SENSOR_BINARY_GENERAL_PURPOSE(getterDisableAlarm)
);

// the setup routine runs once when you press reset:
void setup() {
  Serial.begin();
    
  Serial.println("Setup");
  
  pinMode(Relay_PIN_1, OUTPUT); // setup pin as output
  pinMode(Relay_PIN_2, OUTPUT); // setup pin as output
  pinMode(Relay_PIN_3, OUTPUT); // setup pin as output
  pinMode(Relay_PIN_4, OUTPUT); // setup pin as output
  pinMode(Sensor_PIN_1, INPUT_PULLUP); // set Sensor 1 pin as input
  pinMode(Sensor_PIN_2, INPUT_PULLUP); // set Sensor 2 pin as input
  pinMode(Door_PIN_1, INPUT_PULLUP); // set Door 1 pin as input
  pinMode(Door_PIN_2, INPUT_PULLUP); // set Door 2 pin as input
  pinMode(Door_PIN_3, INPUT_PULLUP); // set Door 3 pin as input
  
}
// the loop routine runs over and over again forever:
void loop() {
  byte currenSensor_1_State;
  byte currentSensor_1_State;
  byte currentSensor_2_State;
  byte currentDoor_1_State;
  byte currentDoor_2_State;
  byte currentDoor_3_State;
  byte currentDisable_Alarm_State;

  
 // Trigger motion and wait for relax (about 5 sec) before report idle
  currentSensor_1_State = !digitalRead(Sensor_PIN_1);
  Serial.print("currentSensor_1_State: ");
  Serial.println(currentSensor_1_State);
  if (currentSensor_1_State) {
    if (relaxMotion_1 == 0) {
      LastSensor_1_state = 1;
      zunoSendReport(5);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion_1 = 1900; // impirical for ~5 sec relax time
  }
  if (LastSensor_1_state == 1 && relaxMotion_1 == 0) {
    LastSensor_1_state = 0; 
    zunoSendReport(5);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion_1) relaxMotion_1--;
  

  currentSensor_2_State = !digitalRead(Sensor_PIN_2);
  if (currentSensor_2_State) {
    if (relaxMotion_2 == 0) {
      LastSensor_2_state = 1;
      zunoSendReport(6);
      zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_ON);
    }
    relaxMotion_2 = 1900; // impirical for ~5 sec relax time
  }
  if (LastSensor_2_state == 1 && relaxMotion_2 == 0) {
    LastSensor_2_state = 0; 
    zunoSendReport(6);
    zunoSendToGroupSetValueCommand(CTRL_GROUP_1, SWITCH_OFF);
  }
  if (relaxMotion_2) relaxMotion_2--;
  
/*
    if (currenButtonState == LOW) { // if button is pressed
      digitalWrite(LED_PIN, HIGH);  // turn the LED on
    } else {                        // if button is released
      digitalWrite(LED_PIN, LOW);   // turn the LED off
*/
  
    

  currentDoor_1_State = digitalRead(Door_PIN_1); 
  if (currentDoor_1_State != LastDoor_1_state) { 
  Serial.println(currentDoor_1_State);
    LastDoor_1_state = currentDoor_1_State;
    zunoSendReport(7);
  }

  currentDoor_2_State = digitalRead(Door_PIN_2); 
  if (currentDoor_2_State != LastDoor_2_state) { 
    LastDoor_2_state = currentDoor_2_State;
    zunoSendReport(8);
  }

  currentDoor_3_State = digitalRead(Door_PIN_3); 
  if (currentDoor_3_State != LastDoor_3_state) { 
    LastDoor_3_state = currentDoor_3_State;
    zunoSendReport(9);
 }

  currentDisable_Alarm_State = digitalRead(Disable_Alarm); 
  if (currentDisable_Alarm_State != LastDisable_Alarm_state) { 
    LastDisable_Alarm_state = currentDisable_Alarm_State;
    zunoSendReport(10);
 }

  }

byte getterSensor1() {
  Serial.println("getterSensor1");
 if (LastSensor_1_state == 0) { // if button is pressed
    return 0xff;              // return "Triggered" state to the controller
  } else {                    // if button is released
    return 0;                 // return "Idle" state to the controller
  }
}

byte getterSensor2() {
 if (LastSensor_2_state == 0) { // if button is pressed
    return 0xff;              // return "Triggered" state to the controller
  } else {                    // if button is released
    return 0;                 // return "Idle" state to the controller
  }
}

byte getterDoor1(void) {
if (LastDoor_1_state == 0) { // if button is pressed
    return 0xff;              // return "Triggered" state to the controller
  } else {                    // if button is released
    return 0;                 // return "Idle" state to the controller
  }
}
byte getterDoor2(void) {
 if (LastDoor_2_state == 0) { // if button is pressed
    return 0xff;              // return "Triggered" state to the controller
  } else {                    // if button is released
    return 0;                 // return "Idle" state to the controller
  }
}
byte getterDoor3(void) {
if (LastDoor_3_state == 0) { // if button is pressed
    return 0xff;              // return "Triggered" state to the controller
  } else {                    // if button is released
    return 0;                 // return "Idle" state to the controller
  }
}

byte getterDisableAlarm(void) {
 if (LastDisable_Alarm_state == 0) { // if button is pressed
    return 0xff;              // return "Triggered" state to the controller
  } else {                    // if button is released
    return 0;                 // return "Idle" state to the controller
  }
}



void setterSwitch1(byte value) {
  if (value > 0) {               // if greater then zero
    digitalWrite (Relay_PIN_1, HIGH); //turn the LED on (HIGH is the voltage level)
  } else {                         // if equals zero
    digitalWrite(Relay_PIN_1, LOW);   //turn the LED off by making the voltage LOW
  }
  currentRelay_1_Value = value;
}

byte getterSwitch1(){
  return currentRelay_1_Value;
}

void setterSwitch2(byte value) {
  if (value > 0) {               // if greater then zero
    digitalWrite (Relay_PIN_2, HIGH); //turn the LED on (HIGH is the voltage level)
  } else {                         // if equals zero
    digitalWrite(Relay_PIN_2, LOW);   //turn the LED off by making the voltage LOW
  }
  currentRelay_2_Value = value;
}

byte getterSwitch2(){
  return currentRelay_2_Value;
}


void setterSwitch3(byte value) {
  if (value > 0) {               // if greater then zero
    digitalWrite (Relay_PIN_3, HIGH); //turn the LED on (HIGH is the voltage level)
  } else {                         // if equals zero
    digitalWrite(Relay_PIN_3, LOW);   //turn the LED off by making the voltage LOW
  }
  currentRelay_3_Value = value;
}

byte getterSwitch3(){
  return currentRelay_3_Value;
}

void setterSwitch4(byte value) {
    if (value > 0) {               // if greater then zero
    digitalWrite (Relay_PIN_4, HIGH); //turn the LED on (HIGH is the voltage level)
  } else {                         // if equals zero
    digitalWrite(Relay_PIN_4, LOW);   //turn the LED off by making the voltage LOW
  }
  currentRelay_4_Value = value;
}

byte getterSwitch4(){
  return currentRelay_4_Value;
}




User avatar
PoltoS
Posts: 3739
Joined: 26 Jan 2011 19:36

Re: Z Uno Tellstick

Post by PoltoS » 31 May 2017 00:59

What do you mean by can't get status? Do you see 4 switches in your Tellsitck controller?

Geirbakke
Posts: 7
Joined: 22 May 2017 16:09

Re: Z Uno Tellstick

Post by Geirbakke » 31 May 2017 12:20

Hi I am getting 11 devices, one master and 10 slave.
The switches (output) I can control from the gateway.
But the input's are not updating the status at the controller.

Hope this explains the problem I am experiensing.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests