Added enum configuration to Oregon and updated configuration pages to show new device structure correctly
This commit is contained in:
parent
95240dd392
commit
c50e50305f
5 changed files with 84 additions and 20 deletions
|
|
@ -22,7 +22,7 @@
|
|||
<tr>
|
||||
<td>{{.getName()}}</td>
|
||||
<td>{{.getType()}}</td>
|
||||
<td>{{.getDeviceData()}}</td>
|
||||
<td>{{.getDeviceConfig()}}</td>
|
||||
<td>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="remove_local_event">
|
||||
|
|
@ -57,13 +57,15 @@
|
|||
<thead>
|
||||
<th>Type</th>
|
||||
<th>Date</th>
|
||||
<th>Data</th>
|
||||
<th>Configuration</th>
|
||||
</thead>
|
||||
{{#detectedEvents}}
|
||||
<tr>
|
||||
<td>{{.getType()}}</td>
|
||||
<td><span class="timestamp">{{.getDeviceData().getTimestamp()}}</span></td>
|
||||
<td>{{.getDeviceData()}}</td>
|
||||
<td>{{.getDeviceData()}}</span></td>
|
||||
<td>{{.getDeviceConfig()}}</td>
|
||||
<td>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<button type="button" class="btn btn-default btn-xs" data-toggle="modal"
|
||||
|
|
@ -172,7 +174,14 @@
|
|||
{{#.params}}
|
||||
<div class="form-group">
|
||||
<label class="control-label">{{.getNiceName()}}:</label>
|
||||
<input type="text" class="form-control" name="{{.getName()}}">
|
||||
{{#.isTypeString()}}<input type="text" class="form-control" name="{{.getName()}}">{{/#.isTypeString()}}
|
||||
{{#.isTypeInt()}}<input type="number" class="form-control" name="{{.getName()}}">{{/#.isTypeInt()}}
|
||||
{{#.isTypeBoolean()}}<input type="checkbox" name="{{.getName()}}">{{/#.isTypeBoolean()}}
|
||||
{{#.isTypeEnum()}}
|
||||
<select class="form-control" name="{{.getName()}}">
|
||||
{{#.getPossibleValues()}}<option>{{.}}</option>{{/.getPossibleValues()}}
|
||||
</select>
|
||||
{{/#.isTypeEnum()}}
|
||||
</div>
|
||||
{{/.params}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<td>{{.getName()}}</td>
|
||||
<td>{{.getType()}}</td>
|
||||
<td>{{.isSynced()}}</td>
|
||||
<td>{{.getDeviceData()}}</td>
|
||||
<td>{{.getDeviceConfig()}}</td>
|
||||
<td>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="remove_local_sensor">
|
||||
|
|
@ -60,13 +60,15 @@
|
|||
<thead>
|
||||
<th>Type</th>
|
||||
<th>Date</th>
|
||||
<th>Data</th>
|
||||
<th>Configuration</th>
|
||||
</thead>
|
||||
{{#detectedSensors}}
|
||||
<tr>
|
||||
<td>{{.getType()}}</td>
|
||||
<td><span class="timestamp">{{.getDeviceData().getTimestamp()}}</span></td>
|
||||
<td>{{.getDeviceData()}}</td>
|
||||
<td>{{.getDeviceData()}}</span></td>
|
||||
<td>{{.getDeviceConfig()}}</td>
|
||||
<td>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<button type="button" class="btn btn-default btn-xs" data-toggle="modal"
|
||||
|
|
@ -156,7 +158,7 @@
|
|||
<tr>
|
||||
<td>{{.getName()}}</td>
|
||||
<td>{{.getType()}}</td>
|
||||
<td>{{.getDeviceData()}}</td>
|
||||
<td>{{.getDeviceConfig()}}</td>
|
||||
<td>
|
||||
<form method="POST">
|
||||
<div class="btn-toolbar pull-right">
|
||||
|
|
@ -299,7 +301,14 @@
|
|||
{{#.params}}
|
||||
<div class="form-group">
|
||||
<label class="control-label">{{.getNiceName()}}:</label>
|
||||
<input type="text" class="form-control" name="{{.getName()}}">
|
||||
{{#.isTypeString()}}<input type="text" class="form-control" name="{{.getName()}}">{{/#.isTypeString()}}
|
||||
{{#.isTypeInt()}}<input type="number" class="form-control" name="{{.getName()}}">{{/#.isTypeInt()}}
|
||||
{{#.isTypeBoolean()}}<input type="checkbox" name="{{.getName()}}">{{/#.isTypeBoolean()}}
|
||||
{{#.isTypeEnum()}}
|
||||
<select class="form-control" name="{{.getName()}}">
|
||||
{{#.getPossibleValues()}}<option>{{.}}</option>{{/.getPossibleValues()}}
|
||||
</select>
|
||||
{{/#.isTypeEnum()}}
|
||||
</div>
|
||||
{{/.params}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
package se.hal.plugin.tellstick.device;
|
||||
|
||||
import se.hal.intf.HalEventController;
|
||||
import se.hal.intf.HalSensorConfig;
|
||||
import se.hal.intf.HalSensorController;
|
||||
import se.hal.intf.HalSensorData;
|
||||
import se.hal.plugin.tellstick.TellstickDevice;
|
||||
import se.hal.plugin.tellstick.TellstickProtocol;
|
||||
import se.hal.plugin.tellstick.TellstickSerialComm;
|
||||
import se.hal.plugin.tellstick.protocol.Oregon0x1A2DProtocol;
|
||||
import se.hal.struct.devicedata.HumiditySensorData;
|
||||
import se.hal.struct.devicedata.LightSensorData;
|
||||
import se.hal.struct.devicedata.PowerConsumptionSensorData;
|
||||
import se.hal.struct.devicedata.TemperatureSensorData;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.ui.Configurator;
|
||||
|
||||
|
|
@ -20,11 +21,16 @@ import java.util.logging.Logger;
|
|||
public class Oregon0x1A2D implements HalSensorConfig,TellstickDevice {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
public enum OregonSensorType{
|
||||
HUMIDITY,LIGHT,POWER,TEMPERATURE
|
||||
}
|
||||
|
||||
@Configurator.Configurable("Address")
|
||||
private int address = 0;
|
||||
@Configurator.Configurable("Report Interval(ms)")
|
||||
private int interval = 60*1000; // default 1 min
|
||||
|
||||
@Configurator.Configurable("Sensor Type")
|
||||
private OregonSensorType sensorType;
|
||||
|
||||
|
||||
public Oregon0x1A2D() { }
|
||||
|
|
@ -37,11 +43,12 @@ public class Oregon0x1A2D implements HalSensorConfig,TellstickDevice {
|
|||
public boolean equals(Object obj){
|
||||
if(! (obj instanceof Oregon0x1A2D))
|
||||
return false;
|
||||
return ((Oregon0x1A2D)obj).address == this.address;
|
||||
return ((Oregon0x1A2D)obj).address == this.address &&
|
||||
((Oregon0x1A2D)obj).sensorType == this.sensorType;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "address:"+address;
|
||||
return "address:"+address+",sensorType:"+ sensorType;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -53,7 +60,9 @@ public class Oregon0x1A2D implements HalSensorConfig,TellstickDevice {
|
|||
|
||||
@Override
|
||||
public AggregationMethod getAggregationMethod() {
|
||||
if (sensorType == OregonSensorType.POWER)
|
||||
return AggregationMethod.SUM;
|
||||
return AggregationMethod.AVERAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -63,7 +72,13 @@ public class Oregon0x1A2D implements HalSensorConfig,TellstickDevice {
|
|||
|
||||
@Override
|
||||
public Class<? extends HalSensorData> getSensorDataClass() {
|
||||
return PowerConsumptionSensorData.class; // TODO: needs to support all data, add enum?
|
||||
switch (sensorType){
|
||||
case HUMIDITY: return HumiditySensorData.class;
|
||||
case LIGHT: return LightSensorData.class;
|
||||
case POWER: return PowerConsumptionSensorData.class;
|
||||
case TEMPERATURE: return TemperatureSensorData.class;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
34
src/se/hal/struct/devicedata/LightSensorData.java
Executable file
34
src/se/hal/struct/devicedata/LightSensorData.java
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
package se.hal.struct.devicedata;
|
||||
|
||||
import se.hal.intf.HalSensorData;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-12-03.
|
||||
*/
|
||||
public class LightSensorData extends HalSensorData {
|
||||
|
||||
private double lux;
|
||||
|
||||
|
||||
public LightSensorData(){}
|
||||
public LightSensorData(double lux){
|
||||
this.lux = lux;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the light intensity in lux
|
||||
*/
|
||||
@Override
|
||||
public double getData() {
|
||||
return lux;
|
||||
}
|
||||
/**
|
||||
* @param lux set the light intensity in lux
|
||||
*/
|
||||
@Override
|
||||
public void setData(double lux) {
|
||||
this.lux = lux;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -19,12 +19,6 @@ public class TemperatureSensorData extends HalSensorData {
|
|||
super.setTimestamp(timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data the temperature to set in degrees C
|
||||
*/
|
||||
public void setTemperature(double data){
|
||||
this.temperature = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return temperature in degrees C
|
||||
|
|
@ -33,6 +27,9 @@ public class TemperatureSensorData extends HalSensorData {
|
|||
public double getData() {
|
||||
return temperature;
|
||||
}
|
||||
/**
|
||||
* @param temperature the temperature to set in degrees C
|
||||
*/
|
||||
@Override
|
||||
public void setData(double temperature) {
|
||||
this.temperature = temperature;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue