Some progress
This commit is contained in:
parent
52afc53660
commit
3bdb4ea043
14 changed files with 212 additions and 173 deletions
|
|
@ -50,17 +50,17 @@ public class HalSpeechClient {
|
|||
bot.initialize();
|
||||
|
||||
/********************************************************************/
|
||||
/* NexaSelfLearning nexa1 = new NexaSelfLearning();
|
||||
/* NexaSelfLearningProtocol nexa1 = new NexaSelfLearningProtocol();
|
||||
nexa1.setHouse(15087918);
|
||||
nexa1.setUnit(0);
|
||||
switches.put("livingroom", new SwitchEventData("livingroom", nexa1));
|
||||
|
||||
NexaSelfLearning nexa2 = new NexaSelfLearning();
|
||||
NexaSelfLearningProtocol nexa2 = new NexaSelfLearningProtocol();
|
||||
nexa2.setHouse(15087918);
|
||||
nexa2.setUnit(1);
|
||||
switches.put("bedroom", new SwitchEventData("bedroom", nexa2));
|
||||
|
||||
NexaSelfLearning nexa3 = new NexaSelfLearning();
|
||||
NexaSelfLearningProtocol nexa3 = new NexaSelfLearningProtocol();
|
||||
nexa3.setHouse(15087918);
|
||||
nexa3.setUnit(3);
|
||||
switches.put("kitchen", new SwitchEventData("kitchen", nexa3));
|
||||
|
|
@ -70,7 +70,7 @@ public class HalSpeechClient {
|
|||
public void stateChange(TellstickProtocol protocol) {
|
||||
for(SwitchEventData s : switches.values()) {
|
||||
if(s.equals(protocol)) {
|
||||
String response = s.getName()+" window is "+(((NexaSelfLearning)protocol).isEnabled() ? "open": "closed");
|
||||
String response = s.getName()+" window is "+(((NexaSelfLearningProtocol)protocol).isEnabled() ? "open": "closed");
|
||||
System.out.println(">>> " + response);
|
||||
tts.speak(response);
|
||||
return;
|
||||
|
|
|
|||
25
src/se/hal/intf/HalDeviceData.java
Executable file
25
src/se/hal/intf/HalDeviceData.java
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
package se.hal.intf;
|
||||
|
||||
/**
|
||||
* Interface representing one report from an event
|
||||
*
|
||||
* Created by Ziver on 2016-08-17.
|
||||
*/
|
||||
public abstract class HalDeviceData {
|
||||
|
||||
private long timestamp = -1;
|
||||
|
||||
|
||||
public long getTimestamp(){
|
||||
return timestamp;
|
||||
}
|
||||
public void setTimestamp(long timestamp){
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return serialized event data converted to double that will be saved in DB.
|
||||
*/
|
||||
public abstract double getData();
|
||||
}
|
||||
|
|
@ -5,21 +5,6 @@ package se.hal.intf;
|
|||
*
|
||||
* Created by Ziver on 2016-08-17.
|
||||
*/
|
||||
public abstract class HalEventData {
|
||||
public abstract class HalEventData extends HalDeviceData{
|
||||
|
||||
private long timestamp = -1;
|
||||
|
||||
|
||||
public long getTimestamp(){
|
||||
return timestamp;
|
||||
}
|
||||
public void setTimestamp(long timestamp){
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return serialized event data converted to double that will be saved in DB.
|
||||
*/
|
||||
public abstract double getData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,21 +5,6 @@ package se.hal.intf;
|
|||
*
|
||||
* Created by Ziver on 2016-08-17.
|
||||
*/
|
||||
public abstract class HalSensorData {
|
||||
public abstract class HalSensorData extends HalDeviceData{
|
||||
|
||||
private long timestamp = -1;
|
||||
|
||||
|
||||
public long getTimestamp(){
|
||||
return timestamp;
|
||||
}
|
||||
public void setTimestamp(long timestamp){
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return serialized sensor data converted to double that will be saved in DB.
|
||||
*/
|
||||
public abstract double getData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public interface TellstickGroupProtocol {
|
|||
* Protocols should extend this method if it has group functionality.
|
||||
* @return true if this object an the input is in the same group.
|
||||
*/
|
||||
public boolean equalsGroup(TellstickProtocol obj);
|
||||
public boolean equalsGroup(TellstickGroupProtocol obj);
|
||||
|
||||
/**
|
||||
* Copy the state data from the group to this object.
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
package se.hal.plugin.tellstick;
|
||||
|
||||
import se.hal.plugin.tellstick.protocols.NexaSelfLearning;
|
||||
import se.hal.plugin.tellstick.protocols.Oregon0x1A2D;
|
||||
import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol;
|
||||
import se.hal.plugin.tellstick.protocol.Oregon0x1A2DProtocol;
|
||||
import zutil.converter.Converter;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
|
|
@ -41,8 +41,8 @@ public class TellstickParser {
|
|||
private static HashMap<String, Class<? extends TellstickProtocol>> protocolMap;
|
||||
|
||||
static {
|
||||
registerProtocol(NexaSelfLearning.class);
|
||||
registerProtocol(Oregon0x1A2D.class);
|
||||
registerProtocol(NexaSelfLearningProtocol.class);
|
||||
registerProtocol(Oregon0x1A2DProtocol.class);
|
||||
}
|
||||
|
||||
private int firmwareVersion = -1;
|
||||
|
|
|
|||
|
|
@ -19,20 +19,18 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package se.hal.plugin.tellstick;
|
||||
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventData;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-02-18.
|
||||
*/
|
||||
public abstract class TellstickProtocol {
|
||||
|
||||
private String protocol;
|
||||
private String model;
|
||||
private long timestamp = -1;
|
||||
private final String protocol;
|
||||
private final String model;
|
||||
|
||||
|
||||
public TellstickProtocol(String protocol, String model){
|
||||
|
|
@ -48,22 +46,7 @@ public abstract class TellstickProtocol {
|
|||
return model;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
public Class<? extends HalEventController> getEventController() {
|
||||
return TellstickSerialComm.class;
|
||||
}
|
||||
public Class<? extends HalSensorController> getSensorController() {
|
||||
return TellstickSerialComm.class;
|
||||
}
|
||||
|
||||
public abstract String encode();
|
||||
public String encode(HalEventConfig deviceConfig, HalEventData deviceData){ return null; }
|
||||
public abstract void decode(byte[] data);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,13 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package se.hal.plugin.tellstick.protocols;
|
||||
package se.hal.plugin.tellstick.device;
|
||||
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.plugin.tellstick.TellstickGroupProtocol;
|
||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||
import se.hal.struct.devicedata.SwitchEventData;
|
||||
import se.hal.plugin.tellstick.TellstickSerialComm;
|
||||
import zutil.ByteUtil;
|
||||
import zutil.parser.binary.BinaryStruct;
|
||||
import zutil.parser.binary.BinaryStructInputStream;
|
||||
|
|
@ -37,8 +38,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* Created by Ziver on 2015-02-18.
|
||||
*/
|
||||
public class NexaSelfLearning extends TellstickProtocol
|
||||
implements HalEventConfig,TellstickGroupProtocol,BinaryStruct {
|
||||
public class NexaSelfLearning implements HalEventConfig,TellstickGroupProtocol,BinaryStruct {
|
||||
|
||||
@BinaryField(index=1, length=26)
|
||||
@Configurator.Configurable("House code")
|
||||
|
|
@ -56,59 +56,6 @@ public class NexaSelfLearning extends TellstickProtocol
|
|||
private int unit = 0;
|
||||
|
||||
|
||||
|
||||
public NexaSelfLearning() {
|
||||
super("arctech", "selflearning");
|
||||
}
|
||||
|
||||
|
||||
public String encode(){
|
||||
try {
|
||||
// T[t0][t1][t2][t3][length][d1]..[dn]+
|
||||
StringBuilder enc = new StringBuilder(90); // Tellstick supports max 74 bytes
|
||||
enc.append(new char[]{'T', 127, 255, 24, 0});
|
||||
enc.append((char)0); // length
|
||||
|
||||
enc.append((char)0b0000_1001); // preamble
|
||||
int length = 4;
|
||||
byte[] data = BinaryStructOutputStream.serialize(this);
|
||||
for (byte b : data){
|
||||
for (int i=7; i>=0; --i){
|
||||
if (ByteUtil.getBits(b, i, 1) == 0)
|
||||
enc.append((char) 0b1010_1000); // 0b1010_1000
|
||||
else // 1
|
||||
enc.append((char) 0b1000_1010); // 0b1000_1010
|
||||
length += 4;
|
||||
}
|
||||
}
|
||||
enc.append((char)0b0000_0000); // postemble
|
||||
length += 2;
|
||||
enc.setCharAt(5, (char)length); // Set calculated length
|
||||
|
||||
enc.append("+");
|
||||
return enc.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public void decode(byte[] data){
|
||||
// Data positions
|
||||
// house = 0xFFFFFFC0
|
||||
// group = 0x00000020
|
||||
// method = 0x00000010
|
||||
// unit = 0x0000000F
|
||||
// ----------------h------------ g m --u-
|
||||
// 0x2CE81990 - 00101100_11101000_00011001_10 0 1 0000 - ON
|
||||
// 0x2CE81980 - 00101100_11101000_00011001_10 0 0 0000 - OFF
|
||||
|
||||
BinaryStructInputStream.read(this, data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getHouse() {
|
||||
return house;
|
||||
}
|
||||
|
|
@ -146,7 +93,7 @@ public class NexaSelfLearning extends TellstickProtocol
|
|||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean equalsGroup(TellstickProtocol obj) {
|
||||
public boolean equalsGroup(TellstickGroupProtocol obj) {
|
||||
if(obj instanceof NexaSelfLearning)
|
||||
return ((NexaSelfLearning) obj).house == house &&
|
||||
(((NexaSelfLearning) obj).group || group );
|
||||
|
|
@ -158,4 +105,8 @@ public class NexaSelfLearning extends TellstickProtocol
|
|||
this.enable = ((NexaSelfLearning) group).enable;
|
||||
}
|
||||
|
||||
|
||||
public Class<? extends HalEventController> getEventController() {
|
||||
return TellstickSerialComm.class;
|
||||
}
|
||||
}
|
||||
55
src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java
Executable file
55
src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
package se.hal.plugin.tellstick.device;
|
||||
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||
import se.hal.plugin.tellstick.TellstickSerialComm;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.ui.Configurator;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-11-19.
|
||||
*/
|
||||
public class Oregon0x1A2D implements HalSensorConfig {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
@Configurator.Configurable("Address")
|
||||
private int address = 0;
|
||||
@Configurator.Configurable("Report Interval(ms)")
|
||||
private int interval = 60*1000; // default 1 min
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(! (obj instanceof Oregon0x1A2D))
|
||||
return false;
|
||||
return ((Oregon0x1A2D)obj).address == this.address;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "address:"+address;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public long getDataInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AggregationMethod getAggregationMethod() {
|
||||
return AggregationMethod.SUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends HalSensorController> getSensorController() {
|
||||
return TellstickSerialComm.class;
|
||||
}
|
||||
|
||||
}
|
||||
95
src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java
Executable file
95
src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java
Executable file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Ziver
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package se.hal.plugin.tellstick.protocol;
|
||||
|
||||
import se.hal.intf.HalEventConfig;
|
||||
import se.hal.plugin.tellstick.TellstickGroupProtocol;
|
||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||
import zutil.ByteUtil;
|
||||
import zutil.parser.binary.BinaryStruct;
|
||||
import zutil.parser.binary.BinaryStructInputStream;
|
||||
import zutil.parser.binary.BinaryStructOutputStream;
|
||||
import zutil.ui.Configurator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-02-18.
|
||||
*/
|
||||
public class NexaSelfLearningProtocol extends TellstickProtocol {
|
||||
|
||||
|
||||
|
||||
public NexaSelfLearningProtocol() {
|
||||
super("arctech", "selflearning");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encode(){
|
||||
try {
|
||||
// T[t0][t1][t2][t3][length][d1]..[dn]+
|
||||
StringBuilder enc = new StringBuilder(90); // Tellstick supports max 74 bytes
|
||||
enc.append(new char[]{'T', 127, 255, 24, 0});
|
||||
enc.append((char)0); // length
|
||||
|
||||
enc.append((char)0b0000_1001); // preamble
|
||||
int length = 4;
|
||||
byte[] data = BinaryStructOutputStream.serialize(this);
|
||||
for (byte b : data){
|
||||
for (int i=7; i>=0; --i){
|
||||
if (ByteUtil.getBits(b, i, 1) == 0)
|
||||
enc.append((char) 0b1010_1000); // 0b1010_1000
|
||||
else // 1
|
||||
enc.append((char) 0b1000_1010); // 0b1000_1010
|
||||
length += 4;
|
||||
}
|
||||
}
|
||||
enc.append((char)0b0000_0000); // postemble
|
||||
length += 2;
|
||||
enc.setCharAt(5, (char)length); // Set calculated length
|
||||
|
||||
enc.append("+");
|
||||
return enc.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(byte[] data){
|
||||
// Data positions
|
||||
// house = 0xFFFFFFC0
|
||||
// group = 0x00000020
|
||||
// method = 0x00000010
|
||||
// unit = 0x0000000F
|
||||
// ----------------h------------ g m --u-
|
||||
// 0x2CE81990 - 00101100_11101000_00011001_10 0 1 0000 - ON
|
||||
// 0x2CE81980 - 00101100_11101000_00011001_10 0 0 0000 - OFF
|
||||
|
||||
BinaryStructInputStream.read(this, data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
package se.hal.plugin.tellstick.protocols;
|
||||
package se.hal.plugin.tellstick.protocol;
|
||||
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||
import se.hal.struct.devicedata.PowerConsumptionSensorData;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.ui.Configurator;
|
||||
|
||||
|
|
@ -11,29 +10,16 @@ import java.util.logging.Logger;
|
|||
/**
|
||||
* Created by Ziver on 2015-11-19.
|
||||
*/
|
||||
public class Oregon0x1A2D extends TellstickProtocol implements HalSensorConfig {
|
||||
public class Oregon0x1A2DProtocol extends TellstickProtocol {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
@Configurator.Configurable("Address")
|
||||
private int address = 0;
|
||||
@Configurator.Configurable("Report Interval(ms)")
|
||||
private int interval = 60*1000; // default 1 min
|
||||
|
||||
private double temperature = 0;
|
||||
private double humidity = 0;
|
||||
|
||||
|
||||
|
||||
public Oregon0x1A2D(){
|
||||
public Oregon0x1A2DProtocol(){
|
||||
super("oregon", "0x1A2D");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String encode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(byte[] data) {
|
||||
//class:sensor;protocol:oregon;model:0x1A2D;data:20BA000000002700;
|
||||
|
|
@ -68,29 +54,4 @@ public class Oregon0x1A2D extends TellstickProtocol implements HalSensorConfig {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(! (obj instanceof Oregon0x1A2D))
|
||||
return false;
|
||||
return ((Oregon0x1A2D)obj).address == this.address;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "address:"+address+
|
||||
", temperature:"+temperature+
|
||||
", humidity:"+humidity;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public long getDataInterval() {
|
||||
return interval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AggregationMethod getAggregationMethod() {
|
||||
return AggregationMethod.SUM;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ public class SensorDataAggregationDeamonTest {
|
|||
System.out.println("Adding user to database");
|
||||
db.exec("INSERT INTO user(id, external, username) VALUES(222, 0, 'test')"); //adding user
|
||||
System.out.println("Adding sensor to database");
|
||||
db.exec("INSERT INTO sensor(id, user_id, external_id, type) VALUES(111, 222, 333, 'se.hal.plugin.tellstick.protocols.Oregon0x1A2D')"); //adding sensor
|
||||
db.exec("INSERT INTO sensor(id, user_id, external_id, type) VALUES(111, 222, 333, 'se.hal.plugin.tellstick.protocol.Oregon0x1A2DProtocol')"); //adding sensor
|
||||
System.out.println("Generating raw data and saving it to the database...");
|
||||
PreparedStatement stmt = db.getPreparedStatement("INSERT INTO sensor_data_raw (timestamp, sensor_id, data) VALUES(?, ?, ?)");
|
||||
try{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package se.hal.plugin.tellstick;
|
||||
|
||||
import se.hal.plugin.tellstick.protocols.NexaSelfLearning;
|
||||
import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-11-19.
|
||||
|
|
@ -17,7 +17,7 @@ public class TelstickSerialCommNexaOnOffTest {
|
|||
|
||||
Thread.sleep(1000);
|
||||
|
||||
NexaSelfLearning nexa = new NexaSelfLearning();
|
||||
NexaSelfLearningProtocol nexa = new NexaSelfLearningProtocol();
|
||||
//nexa.setHouse(11772006);
|
||||
nexa.setHouse(14160770);
|
||||
nexa.setGroup(false);
|
||||
|
|
|
|||
|
|
@ -20,9 +20,8 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package se.hal.plugin.tellstick.protocols;
|
||||
package se.hal.plugin.tellstick.protocol;
|
||||
|
||||
import zutil.ByteUtil;
|
||||
import zutil.converter.Converter;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
|
@ -33,7 +32,7 @@ public class NexaSelfLearningTest {
|
|||
|
||||
@org.junit.Test
|
||||
public void testEncode() throws Exception {
|
||||
NexaSelfLearning nexa = new NexaSelfLearning();
|
||||
NexaSelfLearningProtocol nexa = new NexaSelfLearningProtocol();
|
||||
nexa.setHouse(11_772_006);
|
||||
nexa.setUnit(0);
|
||||
nexa.turnOn();
|
||||
|
|
@ -61,7 +60,7 @@ public class NexaSelfLearningTest {
|
|||
|
||||
@org.junit.Test
|
||||
public void decode_ON() throws Exception {
|
||||
NexaSelfLearning nexa = decode("0x2CE81990");
|
||||
NexaSelfLearningProtocol nexa = decode("0x2CE81990");
|
||||
|
||||
assertEquals("House Code", 11772006, nexa.getHouse());
|
||||
assertEquals("Unit Code", 0, nexa.getUnit());
|
||||
|
|
@ -70,15 +69,15 @@ public class NexaSelfLearningTest {
|
|||
|
||||
@org.junit.Test
|
||||
public void decode_OFF() throws Exception {
|
||||
NexaSelfLearning nexa = decode("0x2CE81980");
|
||||
NexaSelfLearningProtocol nexa = decode("0x2CE81980");
|
||||
|
||||
assertEquals("House Code", 11772006, nexa.getHouse());
|
||||
assertEquals("Unit Code", 0, nexa.getUnit());
|
||||
assertFalse("Enabled", nexa.isOn());
|
||||
}
|
||||
|
||||
private NexaSelfLearning decode(String data){
|
||||
NexaSelfLearning nexa = new NexaSelfLearning();
|
||||
private NexaSelfLearningProtocol decode(String data){
|
||||
NexaSelfLearningProtocol nexa = new NexaSelfLearningProtocol();
|
||||
nexa.decode(Converter.hexToByte(data));
|
||||
return nexa;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue