mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Password reset functionality, ZWave switch schedule improvement, support zwave controller on pi, support relay switches and security sensors.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<groupId>com.lanternsoftware.currentmonitor</groupId>
|
||||
<artifactId>lantern-currentmonitor</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.4</version>
|
||||
<name>lantern-currentmonitor</name>
|
||||
|
||||
<properties>
|
||||
@@ -25,7 +25,7 @@
|
||||
<dependency>
|
||||
<groupId>com.pi4j</groupId>
|
||||
<artifactId>pi4j-gpio-extension</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.hypfvieh</groupId>
|
||||
|
||||
@@ -178,14 +178,14 @@ public class MonitorApp {
|
||||
return new byte[]{NetworkMonitor.getNetworkStatus().toMask()};
|
||||
if (HubConfigCharacteristic.NetworkDetails == ch) {
|
||||
NetworkStatus status = NetworkMonitor.getNetworkStatus();
|
||||
DaoEntity meta = DaoSerializer.fromZipBson(pool.executeToByteArray(new HttpGet(host + "update/version")));
|
||||
DaoEntity meta = (host == null)?null:DaoSerializer.fromZipBson(pool.executeToByteArray(new HttpGet(host + "update/version")));
|
||||
status.setPingSuccessful(CollectionUtils.isNotEmpty(meta));
|
||||
return DaoSerializer.toZipBson(status);
|
||||
}
|
||||
if (HubConfigCharacteristic.Log == ch) {
|
||||
String[] log = NullUtils.cleanSplit(ResourceLoader.loadFileAsString(WORKING_DIR + "log/log.txt"), "\n");
|
||||
if (log.length > 10)
|
||||
log = Arrays.copyOfRange(log, log.length-10, log.length);
|
||||
if (log.length > 15)
|
||||
log = Arrays.copyOfRange(log, log.length-15, log.length);
|
||||
return ZipUtils.zip(NullUtils.toByteArray(CollectionUtils.delimit(Arrays.asList(log), "\n")));
|
||||
}
|
||||
return null;
|
||||
@@ -341,7 +341,7 @@ public class MonitorApp {
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
payload = ResourceLoader.loadFile(file.getAbsolutePath());
|
||||
if (post(payload, file.getName().endsWith("dat") ? "power/batch" : "power/hub"))
|
||||
if (post(payload, "power/hub"))
|
||||
file.delete();
|
||||
else
|
||||
break;
|
||||
@@ -401,7 +401,7 @@ public class MonitorApp {
|
||||
private static final class UpdateChecker implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
if (NullUtils.isNotEmpty(host)) {
|
||||
if (NullUtils.isNotEmpty(host) && config.isAutoUpdate()) {
|
||||
DaoEntity meta = DaoSerializer.fromZipBson(pool.executeToByteArray(new HttpGet(host + "update/version")));
|
||||
String newVersion = DaoSerializer.getString(meta, "version");
|
||||
if (NullUtils.isNotEqual(newVersion, version)) {
|
||||
|
||||
@@ -17,6 +17,7 @@ public class MonitorConfig {
|
||||
private int connectTimeout;
|
||||
private int socketTimeout;
|
||||
private int updateInterval;
|
||||
private boolean autoUpdate;
|
||||
private float autoCalibrationVoltage;
|
||||
private boolean needsCalibration;
|
||||
private String mqttBrokerUrl;
|
||||
@@ -107,6 +108,14 @@ public class MonitorConfig {
|
||||
updateInterval = _updateInterval;
|
||||
}
|
||||
|
||||
public boolean isAutoUpdate() {
|
||||
return autoUpdate;
|
||||
}
|
||||
|
||||
public void setAutoUpdate(boolean _autoUpdate) {
|
||||
autoUpdate = _autoUpdate;
|
||||
}
|
||||
|
||||
public float getAutoCalibrationVoltage() {
|
||||
return autoCalibrationVoltage;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class MonitorConfigSerializer extends AbstractDaoSerializer<MonitorConfig
|
||||
d.put("connect_timeout", _o.getConnectTimeout());
|
||||
d.put("socket_timeout", _o.getSocketTimeout());
|
||||
d.put("update_interval", _o.getUpdateInterval());
|
||||
d.put("auto_update", _o.isAutoUpdate());
|
||||
d.put("auto_calibration_voltage", _o.getAutoCalibrationVoltage());
|
||||
d.put("needs_calibration", _o.isNeedsCalibration());
|
||||
d.put("mqtt_broker_url", _o.getMqttBrokerUrl());
|
||||
@@ -60,6 +61,7 @@ public class MonitorConfigSerializer extends AbstractDaoSerializer<MonitorConfig
|
||||
o.setConnectTimeout(DaoSerializer.getInteger(_d, "connect_timeout"));
|
||||
o.setSocketTimeout(DaoSerializer.getInteger(_d, "socket_timeout"));
|
||||
o.setUpdateInterval(DaoSerializer.getInteger(_d, "update_interval"));
|
||||
o.setAutoUpdate(DaoSerializer.getBoolean(_d, "auto_update"));
|
||||
o.setAutoCalibrationVoltage(DaoSerializer.getFloat(_d, "auto_calibration_voltage"));
|
||||
o.setNeedsCalibration(DaoSerializer.getBoolean(_d, "needs_calibration"));
|
||||
o.setMqttBrokerUrl(DaoSerializer.getString(_d, "mqtt_broker_url"));
|
||||
|
||||
Reference in New Issue
Block a user