hal/test/se/hal/plugin/tellstick/TelstickSerialCommNexaOnOffTest.java
2016-08-18 16:43:05 +02:00

53 lines
1.6 KiB
Java
Executable file

package se.hal.plugin.tellstick;
import se.hal.plugin.tellstick.device.NexaSelfLearning;
import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol;
import se.hal.struct.devicedata.SwitchEventData;
/**
* Created by Ziver on 2015-11-19.
*/
public class TelstickSerialCommNexaOnOffTest {
public static void main(String[] args) {
try {
System.out.println("Connecting to db...");
TellstickSerialComm comm = new TellstickSerialComm();
// http://developer.telldus.com/doxygen/TellStick.html
comm.initialize("COM8");
//comm.connect("/dev/ttyUSB1");
Thread.sleep(1000);
NexaSelfLearning nexaDevice = new NexaSelfLearning();
//nexa.setHouse(11772006);
nexaDevice.setHouse(14160770);
nexaDevice.setGroup(false);
nexaDevice.setUnit(1);
SwitchEventData nexaData = new SwitchEventData();
System.out.println("Up and Running");
while(true) {
Thread.sleep(2000);
nexaData.turnOn();
nexaDevice.setUnit(0);
comm.send(nexaDevice, nexaData);
Thread.sleep(2000);
nexaDevice.setUnit(1);
comm.send(nexaDevice, nexaData);
Thread.sleep(2000);
nexaData.turnOff();
nexaDevice.setUnit(0);
comm.send(nexaDevice, nexaData);
Thread.sleep(2000);
nexaDevice.setUnit(1);
comm.send(nexaDevice, nexaData);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}