Introduced MQTT detectors to autodetect MQTT devices
This commit is contained in:
parent
e4707c2493
commit
b7ee6b16dc
21 changed files with 714 additions and 108 deletions
|
|
@ -7,3 +7,20 @@ dependencies {
|
|||
implementation 'org.shredzone.acme4j:acme4j-client:2.12'
|
||||
implementation 'org.shredzone.acme4j:acme4j-utils:2.12'
|
||||
}
|
||||
|
||||
// Make test classes available to other projects
|
||||
|
||||
configurations {
|
||||
testClasses {
|
||||
extendsFrom(testImplementation)
|
||||
}
|
||||
}
|
||||
|
||||
task testJar(type: Jar) {
|
||||
archiveClassifier.set('test')
|
||||
from sourceSets.test.output
|
||||
}
|
||||
|
||||
artifacts {
|
||||
testClasses testJar // add the jar generated by the testJar task to the testClasses dependency
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-4">
|
||||
<div class="panel panel-default drop-shadow">
|
||||
<div class="panel-heading">Daemons</div>
|
||||
<div class="panel-body">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package se.hal;
|
||||
|
||||
|
||||
import se.hal.daemon.HalExternalWebDaemon;
|
||||
import se.hal.intf.*;
|
||||
import se.hal.intf.HalJavascriptModule.HalJsModule;
|
||||
|
|
@ -82,7 +81,7 @@ public class HalServer {
|
|||
logger.info("Looking for plugins.");
|
||||
|
||||
// Disable plugins based on settings
|
||||
for (PluginData plugin : getAllPlugins()) {
|
||||
for (PluginData plugin : (List<PluginData>) pluginManager.getAllPlugins()) {
|
||||
PluginConfig pluginConfig = PluginConfig.getPluginConfig(db, plugin.getName());
|
||||
|
||||
// If plugin is not found in DB then disable it and create an entry.
|
||||
|
|
@ -177,17 +176,13 @@ public class HalServer {
|
|||
logger.info("Plugin '" + name + "' has been " + (enabled ? "enabled" : "disabled") + ", change will take affect after restart.");
|
||||
|
||||
pluginConfig.setEnabled(enabled);
|
||||
pluginManager.getPluginData(name).setEnabled(pluginConfig.isEnabled());
|
||||
pluginManager.getPlugin(name).setEnabled(pluginConfig.isEnabled());
|
||||
pluginConfig.save(db);
|
||||
}
|
||||
|
||||
|
||||
public static List<PluginData> getEnabledPlugins() {
|
||||
return pluginManager.toArray();
|
||||
}
|
||||
|
||||
public static List<PluginData> getAllPlugins() {
|
||||
return pluginManager.toArrayAll();
|
||||
public static PluginManager<?> getPluginManager() {
|
||||
return pluginManager;
|
||||
}
|
||||
|
||||
public static List<HalAbstractControllerManager> getControllerManagers() {
|
||||
|
|
|
|||
|
|
@ -22,4 +22,14 @@ public abstract class HalDeviceData {
|
|||
public abstract double getData();
|
||||
|
||||
public abstract void setData(double data);
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
HalDeviceData that = (HalDeviceData) o;
|
||||
return getTimestamp() == that.getTimestamp() &&
|
||||
getData() == that.getData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ package se.hal.intf;
|
|||
/**
|
||||
* Interface representing one report from an event
|
||||
*/
|
||||
public abstract class HalEventData extends HalDeviceData{
|
||||
public abstract class HalEventData extends HalDeviceData {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class PluginConfigWebPage extends HalWebPage {
|
|||
}
|
||||
|
||||
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
|
||||
tmpl.set("plugins", HalServer.getAllPlugins());
|
||||
tmpl.set("plugins", HalServer.getPluginManager().getAllPlugins());
|
||||
tmpl.set("controllers", HalAbstractControllerManager.getControllers());
|
||||
tmpl.set("daemons", HalServer.getAllDaemons());
|
||||
return tmpl;
|
||||
|
|
|
|||
45
hal-core/test/se/hal/test/MockHalDeviceReportListener.java
Normal file
45
hal-core/test/se/hal/test/MockHalDeviceReportListener.java
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package se.hal.test;
|
||||
|
||||
import se.hal.intf.HalDeviceConfig;
|
||||
import se.hal.intf.HalDeviceData;
|
||||
import se.hal.intf.HalDeviceReportListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class will store all reports to be used later in a test to verify the behaviours
|
||||
*/
|
||||
public class MockHalDeviceReportListener implements HalDeviceReportListener {
|
||||
|
||||
private List<DeviceTestReport> reports = new ArrayList<>();
|
||||
|
||||
|
||||
public int getNumberOfReports() {
|
||||
return reports.size();
|
||||
}
|
||||
|
||||
public DeviceTestReport getReport(int index) {
|
||||
return reports.get(index);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
reports = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportReceived(HalDeviceConfig deviceConfig, HalDeviceData deviceData) {
|
||||
reports.add(new DeviceTestReport(deviceConfig, deviceData));
|
||||
}
|
||||
|
||||
|
||||
public static class DeviceTestReport {
|
||||
public HalDeviceConfig config;
|
||||
public HalDeviceData data;
|
||||
|
||||
private DeviceTestReport(HalDeviceConfig config, HalDeviceData data) {
|
||||
this.config = config;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue