From e1618604c9cba3ea4261158cbfab2652af8b422a Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Sat, 8 May 2021 01:41:13 +0200 Subject: [PATCH] Updated with new Configurator changes and cleaned up imports --- .../src/se/hal/EventControllerManager.java | 8 +-- hal-core/src/se/hal/HalContext.java | 9 ++- hal-core/src/se/hal/HalServer.java | 11 ++- .../src/se/hal/SensorControllerManager.java | 7 +- .../src/se/hal/action/SendEventAction.java | 17 ++--- .../daemon/SensorDataAggregatorDaemon.java | 3 +- .../intf/HalAbstractControllerManager.java | 5 +- .../src/se/hal/intf/HalAbstractDevice.java | 2 +- hal-core/src/se/hal/intf/HalWebPage.java | 1 - .../src/se/hal/page/EventConfigWebPage.java | 4 +- hal-core/src/se/hal/page/HalAlertManager.java | 3 +- hal-core/src/se/hal/page/MapJsonPage.java | 2 +- .../se/hal/page/PropertyConfigWebPage.java | 3 +- hal-core/src/se/hal/page/SensorJsonPage.java | 2 - .../se/hal/page/SensorOverviewWebPage.java | 1 - hal-core/src/se/hal/page/TriggerWebPage.java | 1 - .../src/se/hal/page/UserConfigWebPage.java | 1 - hal-core/src/se/hal/struct/Action.java | 5 -- .../se/hal/struct/ClassConfigurationData.java | 4 +- hal-core/src/se/hal/struct/Event.java | 5 +- hal-core/src/se/hal/struct/Trigger.java | 4 -- .../src/se/hal/trigger/DateTimeTrigger.java | 4 +- .../src/se/hal/trigger/DeviceTrigger.java | 20 ++---- hal-core/src/se/hal/trigger/EventTrigger.java | 23 +++--- .../src/se/hal/trigger/SensorTrigger.java | 26 ++++--- hal-core/src/se/hal/trigger/TimerTrigger.java | 2 +- .../se/hal/util/ConfigEventValueProvider.java | 55 ++++++++++++++ .../hal/util/ConfigSensorValueProvider.java | 55 ++++++++++++++ .../src/se/hal/util/DeviceDataSqlResult.java | 1 - .../se/hal/util/HalDeviceChangeListener.java | 2 +- .../se/hal/SensorControllerManagerTest.java | 3 +- hal-core/test/se/hal/TriggerManagerTest.java | 3 +- .../SensorDataAggregationDaemonTest.java | 5 +- .../test/se/hal/test/TestDeviceConfig.java | 5 +- hal-core/test/se/hal/util/TimePeriodTest.java | 1 - .../test/se/hal/util/TimeUtilityTest.java | 71 +++++++++---------- .../assistant/google/SmartHomeImpl.java | 10 +-- .../assistant/google/SmartHomePage.java | 14 ++-- .../se/hal/plugin/dummy/DummyController.java | 3 +- .../hal/plugin/dummy/DummyHumiditySensor.java | 5 +- .../se/hal/plugin/dummy/DummySwitchEvent.java | 5 +- .../plugin/dummy/DummyTemperatureSensor.java | 5 +- .../mqtt/device/HalMqttDeviceConfig.java | 1 - .../se/hal/plugin/netscan/NetworkDevice.java | 3 +- .../hal/plugin/nutups/NutUpsController.java | 5 +- .../se/hal/plugin/nutups/NutUpsDevice.java | 3 +- .../hal/plugin/nvr/rtsp/RTSPCameraConfig.java | 3 +- .../src/se/hal/plugin/nvr/struct/Camera.java | 2 +- .../daemon/PCDataSynchronizationClient.java | 5 +- .../daemon/PCDataSynchronizationDaemon.java | 2 +- .../raspberry/RPiPowerConsumptionSensor.java | 3 +- .../raspberry/RPiTemperatureSensor.java | 3 +- .../tellstick/device/NexaSelfLearning.java | 3 +- .../device/NexaSelfLearningDimmer.java | 3 +- .../plugin/tellstick/device/Oregon0x1A2D.java | 3 +- .../protocol/NexaSelfLearningProtocol.java | 2 +- .../TellstickSerialCommEventTest.java | 4 +- .../TellstickSerialCommSensorTest.java | 4 +- .../tellstick/test/TestEventDevice.java | 2 - .../tellstick/test/TestSensorDevice.java | 2 - .../zigbee/deconz/rest/DeConzRestRules.java | 3 +- .../deconz/rest/DeConzRestTouchlink.java | 3 +- .../plugin/zigbee/HalZigbeeController.java | 14 ++-- .../plugin/zigbee/ZigBeeJSerialCommPort.java | 3 +- .../hal/plugin/zwave/HalZWaveController.java | 1 - settings.gradle | 2 +- 66 files changed, 297 insertions(+), 198 deletions(-) create mode 100644 hal-core/src/se/hal/util/ConfigEventValueProvider.java create mode 100644 hal-core/src/se/hal/util/ConfigSensorValueProvider.java diff --git a/hal-core/src/se/hal/EventControllerManager.java b/hal-core/src/se/hal/EventControllerManager.java index 3658349c..cfc99cdc 100644 --- a/hal-core/src/se/hal/EventControllerManager.java +++ b/hal-core/src/se/hal/EventControllerManager.java @@ -6,13 +6,13 @@ import se.hal.util.HalDeviceUtil; import zutil.db.DBConnection; import zutil.log.LogUtil; import zutil.plugin.PluginManager; -import zutil.ui.Configurator; -import zutil.ui.Configurator.PostConfigurationActionListener; -import zutil.ui.Configurator.PreConfigurationActionListener; import java.sql.PreparedStatement; import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/hal-core/src/se/hal/HalContext.java b/hal-core/src/se/hal/HalContext.java index fce945ce..f47b5f6a 100644 --- a/hal-core/src/se/hal/HalContext.java +++ b/hal-core/src/se/hal/HalContext.java @@ -11,8 +11,13 @@ import zutil.log.LogUtil; import java.io.File; import java.io.FileReader; -import java.sql.*; -import java.util.*; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; import java.util.logging.Logger; diff --git a/hal-core/src/se/hal/HalServer.java b/hal-core/src/se/hal/HalServer.java index d78009bf..636ba9ff 100644 --- a/hal-core/src/se/hal/HalServer.java +++ b/hal-core/src/se/hal/HalServer.java @@ -1,8 +1,11 @@ package se.hal; -import se.hal.intf.*; -import se.hal.page.*; +import se.hal.intf.HalAbstractControllerManager; +import se.hal.intf.HalDaemon; +import se.hal.intf.HalJsonPage; +import se.hal.intf.HalWebPage; +import se.hal.page.HalAlertManager; import se.hal.struct.PluginConfig; import zutil.db.DBConnection; import zutil.io.file.FileUtil; @@ -14,7 +17,9 @@ import zutil.plugin.PluginData; import zutil.plugin.PluginManager; import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.logging.Level; diff --git a/hal-core/src/se/hal/SensorControllerManager.java b/hal-core/src/se/hal/SensorControllerManager.java index d9ec0eed..9f442c05 100644 --- a/hal-core/src/se/hal/SensorControllerManager.java +++ b/hal-core/src/se/hal/SensorControllerManager.java @@ -6,13 +6,12 @@ import se.hal.util.HalDeviceUtil; import zutil.db.DBConnection; import zutil.log.LogUtil; import zutil.plugin.PluginManager; -import zutil.ui.Configurator; -import zutil.ui.Configurator.PostConfigurationActionListener; -import zutil.ui.Configurator.PreConfigurationActionListener; import java.sql.PreparedStatement; import java.sql.SQLException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/hal-core/src/se/hal/action/SendEventAction.java b/hal-core/src/se/hal/action/SendEventAction.java index e961eafb..7ac658af 100644 --- a/hal-core/src/se/hal/action/SendEventAction.java +++ b/hal-core/src/se/hal/action/SendEventAction.java @@ -5,9 +5,10 @@ import se.hal.HalContext; import se.hal.intf.HalAction; import se.hal.intf.HalEventData; import se.hal.struct.Event; +import se.hal.util.ConfigEventValueProvider; import zutil.db.DBConnection; import zutil.log.LogUtil; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; import java.util.logging.Level; import java.util.logging.Logger; @@ -18,8 +19,8 @@ import java.util.logging.Logger; public class SendEventAction implements HalAction { private static final Logger logger = LogUtil.getLogger(); - @Configurator.Configurable("Event Device ID") - private int eventId; + @Configurator.Configurable(value = "Event Device", valueProvider = ConfigEventValueProvider.class) + private Event event; @Configurator.Configurable("Data to Send") private double data; @@ -28,7 +29,6 @@ public class SendEventAction implements HalAction { public void execute() { try { DBConnection db = HalContext.getDB(); - Event event = Event.getEvent(db, eventId); if (event != null) { HalEventData dataObj = (HalEventData) event.getDeviceConfig().getDeviceDataClass().newInstance(); dataObj.setData(data); @@ -37,7 +37,7 @@ public class SendEventAction implements HalAction { EventControllerManager.getInstance().send(event); } else - logger.warning("Unable to find event with id: "+ eventId); + logger.warning("Unable to find event with id: "+ event.getId()); } catch (Exception e) { logger.log(Level.SEVERE, null, e); } @@ -45,11 +45,8 @@ public class SendEventAction implements HalAction { public String toString(){ - DBConnection db = HalContext.getDB(); - Event event = null; - try{ event = Event.getEvent(db, eventId); } catch (Exception e){} //ignore exception - return "Send event: "+ eventId + + return "Send event: " + event.getId() + " (" + (event!=null ? event.getName() : null) + ")" + - " with data: "+ data; + " with data: " + data; } } diff --git a/hal-core/src/se/hal/daemon/SensorDataAggregatorDaemon.java b/hal-core/src/se/hal/daemon/SensorDataAggregatorDaemon.java index 4735d454..612620c0 100644 --- a/hal-core/src/se/hal/daemon/SensorDataAggregatorDaemon.java +++ b/hal-core/src/se/hal/daemon/SensorDataAggregatorDaemon.java @@ -12,7 +12,8 @@ import zutil.db.SQLResultHandler; import zutil.db.handler.SimpleSQLResult; import zutil.log.LogUtil; import zutil.ui.UserMessageManager; -import zutil.ui.UserMessageManager.*; +import zutil.ui.UserMessageManager.MessageTTL; +import zutil.ui.UserMessageManager.UserMessage; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/hal-core/src/se/hal/intf/HalAbstractControllerManager.java b/hal-core/src/se/hal/intf/HalAbstractControllerManager.java index 8e6b945c..a88153c1 100644 --- a/hal-core/src/se/hal/intf/HalAbstractControllerManager.java +++ b/hal-core/src/se/hal/intf/HalAbstractControllerManager.java @@ -4,7 +4,10 @@ import zutil.ClassUtil; import zutil.log.LogUtil; import zutil.plugin.PluginManager; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/hal-core/src/se/hal/intf/HalAbstractDevice.java b/hal-core/src/se/hal/intf/HalAbstractDevice.java index 1510b155..d222fc86 100644 --- a/hal-core/src/se/hal/intf/HalAbstractDevice.java +++ b/hal-core/src/se/hal/intf/HalAbstractDevice.java @@ -8,7 +8,7 @@ import zutil.db.bean.DBBean; import zutil.log.LogUtil; import zutil.parser.json.JSONParser; import zutil.parser.json.JSONWriter; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; import java.sql.SQLException; import java.util.LinkedList; diff --git a/hal-core/src/se/hal/intf/HalWebPage.java b/hal-core/src/se/hal/intf/HalWebPage.java index 93f7d6b9..aa908907 100644 --- a/hal-core/src/se/hal/intf/HalWebPage.java +++ b/hal-core/src/se/hal/intf/HalWebPage.java @@ -9,7 +9,6 @@ import zutil.net.http.HttpHeader; import zutil.net.http.HttpPage; import zutil.net.http.HttpPrintStream; import zutil.parser.Templator; -import zutil.parser.json.JSONWriter; import zutil.ui.Navigation; import java.io.IOException; diff --git a/hal-core/src/se/hal/page/EventConfigWebPage.java b/hal-core/src/se/hal/page/EventConfigWebPage.java index 82fa6c7c..3ce8007b 100644 --- a/hal-core/src/se/hal/page/EventConfigWebPage.java +++ b/hal-core/src/se/hal/page/EventConfigWebPage.java @@ -11,7 +11,9 @@ import zutil.db.DBConnection; import zutil.io.file.FileUtil; import zutil.log.LogUtil; import zutil.parser.Templator; -import zutil.ui.UserMessageManager.*; +import zutil.ui.UserMessageManager.MessageLevel; +import zutil.ui.UserMessageManager.MessageTTL; +import zutil.ui.UserMessageManager.UserMessage; import java.util.ArrayList; import java.util.Map; diff --git a/hal-core/src/se/hal/page/HalAlertManager.java b/hal-core/src/se/hal/page/HalAlertManager.java index b5f1c118..42d781ae 100644 --- a/hal-core/src/se/hal/page/HalAlertManager.java +++ b/hal-core/src/se/hal/page/HalAlertManager.java @@ -11,7 +11,8 @@ import zutil.ui.UserMessageManager; import zutil.ui.UserMessageManager.UserMessage; import java.io.IOException; -import java.util.*; +import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/hal-core/src/se/hal/page/MapJsonPage.java b/hal-core/src/se/hal/page/MapJsonPage.java index 662f0ff1..ade55206 100644 --- a/hal-core/src/se/hal/page/MapJsonPage.java +++ b/hal-core/src/se/hal/page/MapJsonPage.java @@ -1,8 +1,8 @@ package se.hal.page; import se.hal.HalContext; -import se.hal.intf.HalJsonPage; import se.hal.intf.HalAbstractDevice; +import se.hal.intf.HalJsonPage; import se.hal.struct.Event; import se.hal.struct.Sensor; import zutil.db.DBConnection; diff --git a/hal-core/src/se/hal/page/PropertyConfigWebPage.java b/hal-core/src/se/hal/page/PropertyConfigWebPage.java index 5a4970b8..715c1ba2 100644 --- a/hal-core/src/se/hal/page/PropertyConfigWebPage.java +++ b/hal-core/src/se/hal/page/PropertyConfigWebPage.java @@ -2,11 +2,10 @@ package se.hal.page; import se.hal.HalContext; import se.hal.intf.HalWebPage; -import zutil.db.DBConnection; import zutil.io.file.FileUtil; import zutil.parser.Templator; -import java.util.*; +import java.util.Map; public class PropertyConfigWebPage extends HalWebPage { private static final String TEMPLATE = HalContext.RESOURCE_WEB_ROOT + "/property_config.tmpl"; diff --git a/hal-core/src/se/hal/page/SensorJsonPage.java b/hal-core/src/se/hal/page/SensorJsonPage.java index c8ac8a0b..b139729c 100644 --- a/hal-core/src/se/hal/page/SensorJsonPage.java +++ b/hal-core/src/se/hal/page/SensorJsonPage.java @@ -9,8 +9,6 @@ import se.hal.util.UTCTimeUtility; import zutil.ArrayUtil; import zutil.db.DBConnection; import zutil.log.LogUtil; -import zutil.net.http.HttpHeader; -import zutil.net.http.HttpPrintStream; import zutil.parser.DataNode; import java.util.ArrayList; diff --git a/hal-core/src/se/hal/page/SensorOverviewWebPage.java b/hal-core/src/se/hal/page/SensorOverviewWebPage.java index f1e2a35f..39acf2d7 100644 --- a/hal-core/src/se/hal/page/SensorOverviewWebPage.java +++ b/hal-core/src/se/hal/page/SensorOverviewWebPage.java @@ -12,7 +12,6 @@ import zutil.io.file.FileUtil; import zutil.parser.Templator; import java.sql.PreparedStatement; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/hal-core/src/se/hal/page/TriggerWebPage.java b/hal-core/src/se/hal/page/TriggerWebPage.java index 1f4003bb..92961c2a 100644 --- a/hal-core/src/se/hal/page/TriggerWebPage.java +++ b/hal-core/src/se/hal/page/TriggerWebPage.java @@ -12,7 +12,6 @@ import zutil.db.DBConnection; import zutil.io.file.FileUtil; import zutil.log.LogUtil; import zutil.parser.Templator; -import zutil.ui.UserMessageManager; import java.util.ArrayList; import java.util.Map; diff --git a/hal-core/src/se/hal/page/UserConfigWebPage.java b/hal-core/src/se/hal/page/UserConfigWebPage.java index 51f5e3e6..2ba36916 100644 --- a/hal-core/src/se/hal/page/UserConfigWebPage.java +++ b/hal-core/src/se/hal/page/UserConfigWebPage.java @@ -7,7 +7,6 @@ import zutil.db.DBConnection; import zutil.io.file.FileUtil; import zutil.log.LogUtil; import zutil.parser.Templator; -import zutil.ui.UserMessageManager; import java.util.Map; import java.util.logging.Logger; diff --git a/hal-core/src/se/hal/struct/Action.java b/hal-core/src/se/hal/struct/Action.java index 49e01249..f4224c8a 100644 --- a/hal-core/src/se/hal/struct/Action.java +++ b/hal-core/src/se/hal/struct/Action.java @@ -1,16 +1,11 @@ package se.hal.struct; import se.hal.intf.HalAction; -import se.hal.intf.HalTrigger; import zutil.db.DBConnection; import zutil.db.bean.DBBean; import zutil.db.bean.DBBeanObjectDSO; -import zutil.db.bean.DBBeanSQLResultHandler; -import java.sql.PreparedStatement; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; /** * Defines a action that will be executed diff --git a/hal-core/src/se/hal/struct/ClassConfigurationData.java b/hal-core/src/se/hal/struct/ClassConfigurationData.java index 17e548d6..1d794d6a 100644 --- a/hal-core/src/se/hal/struct/ClassConfigurationData.java +++ b/hal-core/src/se/hal/struct/ClassConfigurationData.java @@ -1,7 +1,7 @@ package se.hal.struct; -import zutil.ui.Configurator; -import zutil.ui.Configurator.ConfigurationParam; +import zutil.ui.conf.Configurator; +import zutil.ui.conf.Configurator.ConfigurationParam; /** * A Data class used by the dynamic class configuration pages diff --git a/hal-core/src/se/hal/struct/Event.java b/hal-core/src/se/hal/struct/Event.java index b3970f49..a64854e0 100644 --- a/hal-core/src/se/hal/struct/Event.java +++ b/hal-core/src/se/hal/struct/Event.java @@ -1,6 +1,9 @@ package se.hal.struct; -import se.hal.intf.*; +import se.hal.intf.HalAbstractDevice; +import se.hal.intf.HalEventConfig; +import se.hal.intf.HalEventController; +import se.hal.intf.HalEventData; import se.hal.util.DeviceDataSqlResult; import zutil.db.DBConnection; import zutil.db.bean.DBBean; diff --git a/hal-core/src/se/hal/struct/Trigger.java b/hal-core/src/se/hal/struct/Trigger.java index 52dc4cb6..34bbdc41 100644 --- a/hal-core/src/se/hal/struct/Trigger.java +++ b/hal-core/src/se/hal/struct/Trigger.java @@ -4,12 +4,8 @@ import se.hal.intf.HalTrigger; import zutil.db.DBConnection; import zutil.db.bean.DBBean; import zutil.db.bean.DBBeanObjectDSO; -import zutil.db.bean.DBBeanSQLResultHandler; -import java.sql.PreparedStatement; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; /** * A class that declares a trigger/condition that diff --git a/hal-core/src/se/hal/trigger/DateTimeTrigger.java b/hal-core/src/se/hal/trigger/DateTimeTrigger.java index 3046d7e9..7777dd5b 100644 --- a/hal-core/src/se/hal/trigger/DateTimeTrigger.java +++ b/hal-core/src/se/hal/trigger/DateTimeTrigger.java @@ -2,11 +2,11 @@ package se.hal.trigger; import se.hal.intf.HalTrigger; import zutil.CronTimer; -import zutil.ui.Configurator; -import zutil.ui.Configurator.PreConfigurationActionListener; +import zutil.ui.conf.Configurator; import java.text.SimpleDateFormat; + public class DateTimeTrigger implements HalTrigger,Configurator.PostConfigurationActionListener { @Configurator.Configurable("Minute (Cron format)") diff --git a/hal-core/src/se/hal/trigger/DeviceTrigger.java b/hal-core/src/se/hal/trigger/DeviceTrigger.java index ffa8a0a9..dd8d3276 100644 --- a/hal-core/src/se/hal/trigger/DeviceTrigger.java +++ b/hal-core/src/se/hal/trigger/DeviceTrigger.java @@ -1,14 +1,10 @@ package se.hal.trigger; import se.hal.TriggerManager; -import se.hal.intf.HalDeviceConfig; -import se.hal.intf.HalDeviceData; -import se.hal.intf.HalDeviceReportListener; -import se.hal.intf.HalTrigger; -import se.hal.intf.HalAbstractDevice; -import zutil.ui.Configurator; -import zutil.ui.Configurator.PostConfigurationActionListener; -import zutil.ui.Configurator.PreConfigurationActionListener; +import se.hal.intf.*; +import zutil.ui.conf.Configurator; +import zutil.ui.conf.Configurator.PostConfigurationActionListener; +import zutil.ui.conf.Configurator.PreConfigurationActionListener; /** * An abstract class that implements generic device data logic @@ -18,8 +14,6 @@ public abstract class DeviceTrigger implements HalTrigger, PostConfigurationActionListener, HalDeviceReportListener { - @Configurator.Configurable("Device ID") - protected int deviceId = -1; @Configurator.Configurable("Trigger only on change") protected boolean triggerOnChange = true; @Configurator.Configurable("Data to compare to") @@ -31,14 +25,14 @@ public abstract class DeviceTrigger implements HalTrigger, @Override public void preConfigurationAction(Configurator configurator, Object obj) { - HalAbstractDevice device = getDevice(deviceId); + HalAbstractDevice device = getDevice(); if (device != null) device.removeReportListener(this); reset(); } @Override public void postConfigurationAction(Configurator configurator, Object obj) { - HalAbstractDevice device = getDevice(deviceId); + HalAbstractDevice device = getDevice(); if (device != null) device.addReportListener(this); } @@ -67,5 +61,5 @@ public abstract class DeviceTrigger implements HalTrigger, - protected abstract HalAbstractDevice getDevice(long id); + protected abstract HalAbstractDevice getDevice(); } diff --git a/hal-core/src/se/hal/trigger/EventTrigger.java b/hal-core/src/se/hal/trigger/EventTrigger.java index 5f515fed..77a1f25d 100644 --- a/hal-core/src/se/hal/trigger/EventTrigger.java +++ b/hal-core/src/se/hal/trigger/EventTrigger.java @@ -1,31 +1,30 @@ package se.hal.trigger; -import se.hal.HalContext; import se.hal.struct.Event; +import se.hal.util.ConfigEventValueProvider; import zutil.log.LogUtil; +import zutil.ui.conf.Configurator; -import java.sql.SQLException; -import java.util.logging.Level; import java.util.logging.Logger; public class EventTrigger extends DeviceTrigger{ private static final Logger logger = LogUtil.getLogger(); + @Configurator.Configurable(value = "Event", valueProvider = ConfigEventValueProvider.class) + protected Event device; + + @Override - protected Event getDevice(long id) { - try { - if (id >= 0) - return Event.getEvent(HalContext.getDB(), id); - } catch (SQLException e){ logger.log(Level.SEVERE, null, e);} - return null; + protected Event getDevice() { + return device; } @Override public String toString(){ - Event event = getDevice(deviceId); + Event event = getDevice(); return "Trigger " + (triggerOnChange ? "on" : "when") + - " event: "+ deviceId +" ("+(event != null ? event.getName() : null) + ")" + - " == "+ expectedData; + " event: " + device.getId() + " (" + (event != null ? event.getName() : null) + ")" + + " == " + expectedData; } } diff --git a/hal-core/src/se/hal/trigger/SensorTrigger.java b/hal-core/src/se/hal/trigger/SensorTrigger.java index 2ca56c9b..b5ecfbd4 100644 --- a/hal-core/src/se/hal/trigger/SensorTrigger.java +++ b/hal-core/src/se/hal/trigger/SensorTrigger.java @@ -1,32 +1,30 @@ package se.hal.trigger; -import se.hal.HalContext; -import se.hal.struct.Event; import se.hal.struct.Sensor; +import se.hal.util.ConfigSensorValueProvider; import zutil.log.LogUtil; +import zutil.ui.conf.Configurator; -import java.sql.SQLException; -import java.util.logging.Level; import java.util.logging.Logger; -public class SensorTrigger extends DeviceTrigger{ +public class SensorTrigger extends DeviceTrigger { private static final Logger logger = LogUtil.getLogger(); + @Configurator.Configurable(value = "Sensor", valueProvider = ConfigSensorValueProvider.class) + protected Sensor device; + + @Override - protected Sensor getDevice(long id) { - try { - if (id >= 0) - return Sensor.getSensor(HalContext.getDB(), id); - } catch (SQLException e){ logger.log(Level.SEVERE, null, e);} - return null; + protected Sensor getDevice() { + return device; } @Override public String toString(){ - Sensor sensor = getDevice(deviceId); + Sensor sensor = getDevice(); return "Trigger " + (triggerOnChange ? "on" : "when") + - " sensor: "+ deviceId +" ("+(sensor != null ? sensor.getName() : null) + ")" + - " == "+ expectedData; + " sensor: " + sensor.getId() +" (" + (sensor != null ? sensor.getName() : null) + ")" + + " == " + expectedData; } } diff --git a/hal-core/src/se/hal/trigger/TimerTrigger.java b/hal-core/src/se/hal/trigger/TimerTrigger.java index 29b83945..e33f7743 100644 --- a/hal-core/src/se/hal/trigger/TimerTrigger.java +++ b/hal-core/src/se/hal/trigger/TimerTrigger.java @@ -2,7 +2,7 @@ package se.hal.trigger; import se.hal.intf.HalTrigger; import zutil.Timer; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; public class TimerTrigger implements HalTrigger { diff --git a/hal-core/src/se/hal/util/ConfigEventValueProvider.java b/hal-core/src/se/hal/util/ConfigEventValueProvider.java new file mode 100644 index 00000000..4b15882b --- /dev/null +++ b/hal-core/src/se/hal/util/ConfigEventValueProvider.java @@ -0,0 +1,55 @@ +package se.hal.util; + +import se.hal.HalContext; +import se.hal.struct.Event; +import zutil.db.DBConnection; +import zutil.ui.conf.Configurator; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * A value provider that will give all Enum values + */ +public class ConfigEventValueProvider implements Configurator.ConfigValueProvider { + private Event currentValue; + private Map events = new HashMap<>(); + + + public ConfigEventValueProvider(Class fieldType, Object fieldValue) { + this.currentValue = (Event) fieldValue; + + try { + DBConnection db = HalContext.getDB(); + + for (Event event : Event.getLocalEvents(db)) { + events.put(getValue(event), event); + } + } catch (SQLException e) { + throw new RuntimeException("Unable to collect Event objects.", e); + } + } + + + private String getValue(Event event) { + return event.getName() + " (id: " + event.getId() + ")"; + } + + @Override + public String getCurrentValue() { + return getValue(currentValue); + } + + @Override + public List getPossibleValues() { + return new ArrayList(events.keySet()); + } + + @Override + public Event getObject(String value) { + return events.get(value); + } +} \ No newline at end of file diff --git a/hal-core/src/se/hal/util/ConfigSensorValueProvider.java b/hal-core/src/se/hal/util/ConfigSensorValueProvider.java new file mode 100644 index 00000000..13f1f749 --- /dev/null +++ b/hal-core/src/se/hal/util/ConfigSensorValueProvider.java @@ -0,0 +1,55 @@ +package se.hal.util; + +import se.hal.HalContext; +import se.hal.struct.Sensor; +import zutil.db.DBConnection; +import zutil.ui.conf.Configurator; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * A value provider that will give all Enum values + */ +public class ConfigSensorValueProvider implements Configurator.ConfigValueProvider { + private Sensor currentValue; + private Map sensors = new HashMap<>(); + + + public ConfigSensorValueProvider(Class fieldType, Object fieldValue) { + this.currentValue = (Sensor) fieldValue; + + try { + DBConnection db = HalContext.getDB(); + + for (Sensor sensor : Sensor.getLocalSensors(db)) { + sensors.put(getValue(sensor), sensor); + } + } catch (SQLException e) { + throw new RuntimeException("Unable to collect Event objects.", e); + } + } + + + private String getValue(Sensor sensor) { + return sensor.getName() + " (id: " + sensor.getId() + ")"; + } + + @Override + public String getCurrentValue() { + return getValue(currentValue); + } + + @Override + public List getPossibleValues() { + return new ArrayList(sensors.keySet()); + } + + @Override + public Sensor getObject(String value) { + return sensors.get(value); + } +} \ No newline at end of file diff --git a/hal-core/src/se/hal/util/DeviceDataSqlResult.java b/hal-core/src/se/hal/util/DeviceDataSqlResult.java index 0e4ffdde..82b62389 100644 --- a/hal-core/src/se/hal/util/DeviceDataSqlResult.java +++ b/hal-core/src/se/hal/util/DeviceDataSqlResult.java @@ -1,7 +1,6 @@ package se.hal.util; import se.hal.intf.HalDeviceData; -import zutil.ClassUtil; import zutil.db.SQLResultHandler; import java.sql.ResultSet; diff --git a/hal-core/src/se/hal/util/HalDeviceChangeListener.java b/hal-core/src/se/hal/util/HalDeviceChangeListener.java index 1bf38be9..269aedf1 100644 --- a/hal-core/src/se/hal/util/HalDeviceChangeListener.java +++ b/hal-core/src/se/hal/util/HalDeviceChangeListener.java @@ -4,7 +4,7 @@ import se.hal.HalServer; import se.hal.intf.HalAbstractControllerManager; import se.hal.intf.HalAbstractDevice; import se.hal.intf.HalDeviceConfig; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; import java.util.ArrayList; import java.util.HashMap; diff --git a/hal-core/test/se/hal/SensorControllerManagerTest.java b/hal-core/test/se/hal/SensorControllerManagerTest.java index f9d67a26..3ab8744f 100644 --- a/hal-core/test/se/hal/SensorControllerManagerTest.java +++ b/hal-core/test/se/hal/SensorControllerManagerTest.java @@ -8,7 +8,8 @@ import se.hal.struct.devicedata.TemperatureSensorData; import java.util.Collections; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class SensorControllerManagerTest { diff --git a/hal-core/test/se/hal/TriggerManagerTest.java b/hal-core/test/se/hal/TriggerManagerTest.java index aa52b29d..aea4ca13 100644 --- a/hal-core/test/se/hal/TriggerManagerTest.java +++ b/hal-core/test/se/hal/TriggerManagerTest.java @@ -9,7 +9,8 @@ import se.hal.struct.TriggerFlow; import java.util.Collections; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * diff --git a/hal-core/test/se/hal/daemon/SensorDataAggregationDaemonTest.java b/hal-core/test/se/hal/daemon/SensorDataAggregationDaemonTest.java index 17126e78..dd6ccd3c 100644 --- a/hal-core/test/se/hal/daemon/SensorDataAggregationDaemonTest.java +++ b/hal-core/test/se/hal/daemon/SensorDataAggregationDaemonTest.java @@ -1,16 +1,15 @@ package se.hal.daemon; -import java.sql.PreparedStatement; - import org.junit.Before; import org.junit.Test; - import se.hal.HalContext; import se.hal.util.UTCTimeUtility; import zutil.db.DBConnection; import zutil.db.DBUpgradeHandler; import zutil.log.LogUtil; +import java.sql.PreparedStatement; + public class SensorDataAggregationDaemonTest { private static final String DEFAULT_DB_FILE = "resource/resource/hal-default.db"; diff --git a/hal-core/test/se/hal/test/TestDeviceConfig.java b/hal-core/test/se/hal/test/TestDeviceConfig.java index 879931ca..4e16d890 100644 --- a/hal-core/test/se/hal/test/TestDeviceConfig.java +++ b/hal-core/test/se/hal/test/TestDeviceConfig.java @@ -1,6 +1,9 @@ package se.hal.test; -import se.hal.intf.*; +import se.hal.intf.HalEventConfig; +import se.hal.intf.HalSensorConfig; +import se.hal.intf.HalSensorController; +import se.hal.intf.HalSensorData; import se.hal.struct.devicedata.TemperatureSensorData; /** diff --git a/hal-core/test/se/hal/util/TimePeriodTest.java b/hal-core/test/se/hal/util/TimePeriodTest.java index 426802a5..f13ecd21 100644 --- a/hal-core/test/se/hal/util/TimePeriodTest.java +++ b/hal-core/test/se/hal/util/TimePeriodTest.java @@ -4,7 +4,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - import se.hal.daemon.SensorDataAggregatorDaemon.AggregationPeriodLength; import java.util.Arrays; diff --git a/hal-core/test/se/hal/util/TimeUtilityTest.java b/hal-core/test/se/hal/util/TimeUtilityTest.java index d98bba27..124154f3 100644 --- a/hal-core/test/se/hal/util/TimeUtilityTest.java +++ b/hal-core/test/se/hal/util/TimeUtilityTest.java @@ -4,7 +4,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - import se.hal.daemon.SensorDataAggregatorDaemon.AggregationPeriodLength; import java.util.Arrays; @@ -18,8 +17,8 @@ import static org.junit.Assert.assertTrue; @RunWith(Parameterized.class) public class TimeUtilityTest { private final long currentTime_UTC; - - + + /** * Constructor * @param timestamp @@ -27,7 +26,7 @@ public class TimeUtilityTest { public TimeUtilityTest(long timestamp){ this.currentTime_UTC = timestamp; } - + @Parameters public static Collection data(){ return Arrays.asList(new Object[][] { @@ -50,15 +49,15 @@ public class TimeUtilityTest { {Long.MAX_VALUE-(60*UTCTimeUtility.WEEK_IN_MS)}, //max time - 60w }); } - + // Test flooring & ceiling UTC time to the closes year @Test - public void testYear_UTC(){ + public void testYear_UTC(){ System.out.println("Testing year with timestamp " + currentTime_UTC + " " + UTCTimeUtility.getDateString(currentTime_UTC)); long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.YEAR, currentTime_UTC); long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.YEAR, currentTime_UTC); - + //verify period start is correct System.out.println(" year start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt)); assertTrue("perdiod start is not before current time", thisPeriodStartedAt <= currentTime_UTC); @@ -80,18 +79,18 @@ public class TimeUtilityTest { assertEquals("period end day is wrong", 31, UTCTimeUtility.getDayOfMonthFromTimestamp(thisPeriodEndedAt)); assertEquals("period end month is wrong", Calendar.DECEMBER, UTCTimeUtility.getMonthOfYearFromTimestamp(thisPeriodEndedAt)); assertEquals("period end year is wrong", UTCTimeUtility.getYearFromTimestamp(currentTime_UTC), UTCTimeUtility.getYearFromTimestamp(thisPeriodEndedAt)); - + //verify that start and end values are reasonable assertTrue("start is zero", thisPeriodStartedAt != 0); assertTrue("end is zero", thisPeriodEndedAt != 0); assertTrue("start is not before end", thisPeriodStartedAt < thisPeriodEndedAt ); assertTrue("start and end are equal", thisPeriodStartedAt != thisPeriodEndedAt ); - + //verify that the period start and end is in the same period assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.YEAR, thisPeriodEndedAt)); assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.YEAR, thisPeriodStartedAt)); - } - + } + // Test flooring & ceiling UTC time to the closes month @Test public void testMonth_UTC(){ @@ -101,7 +100,7 @@ public class TimeUtilityTest { long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.MONTH, currentTime_UTC); long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.MONTH, currentTime_UTC); - + //verify period start is correct System.out.println(" month start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt)); assertTrue("perdiod start is not before current time", thisPeriodStartedAt <= currentTime_UTC); @@ -129,12 +128,12 @@ public class TimeUtilityTest { assertTrue("end is zero", thisPeriodEndedAt != 0); assertTrue("start is not before end", thisPeriodStartedAt < thisPeriodEndedAt ); assertTrue("start and end are equal", thisPeriodStartedAt != thisPeriodEndedAt ); - + //verify that the period start and end is in the same period assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.MONTH, thisPeriodEndedAt)); assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.MONTH, thisPeriodStartedAt)); - } - + } + // Test flooring & ceiling UTC time to the closes week @Test public void testWeek_UTC(){ @@ -142,7 +141,7 @@ public class TimeUtilityTest { long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.WEEK, currentTime_UTC); long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.WEEK, currentTime_UTC); - + //verify period start is correct System.out.println(" week start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt)); assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC); @@ -175,8 +174,8 @@ public class TimeUtilityTest { //verify that the period start and end is in the same period assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.WEEK, thisPeriodEndedAt)); assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.WEEK, thisPeriodStartedAt)); - } - + } + // Test flooring & ceiling UTC time to the closes day @Test public void testDay_UTC(){ @@ -184,7 +183,7 @@ public class TimeUtilityTest { long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.DAY, currentTime_UTC); long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.DAY, currentTime_UTC); - + //verify period start is correct System.out.println(" day start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt)); assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC); @@ -218,7 +217,7 @@ public class TimeUtilityTest { assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.DAY, thisPeriodEndedAt)); assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.DAY, thisPeriodStartedAt)); } - + // Test flooring & ceiling UTC time to the closes hour @Test public void testHour_UTC(){ @@ -226,7 +225,7 @@ public class TimeUtilityTest { long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.HOUR, currentTime_UTC); long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.HOUR, currentTime_UTC); - + //verify period start is correct System.out.println(" hour start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt)); assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC); @@ -260,7 +259,7 @@ public class TimeUtilityTest { assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.HOUR, thisPeriodEndedAt)); assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.HOUR, thisPeriodStartedAt)); } - + // Test flooring & ceiling UTC time to the closes 15-minute period @Test public void testFifteenMinute_UTC(){ @@ -268,7 +267,7 @@ public class TimeUtilityTest { long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIFTEEN_MINUTES, currentTime_UTC); long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.FIFTEEN_MINUTES, currentTime_UTC); - + //verify period start is correct System.out.println(" 15-min start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt)); assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC); @@ -305,15 +304,15 @@ public class TimeUtilityTest { assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIFTEEN_MINUTES, thisPeriodEndedAt)); assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.FIFTEEN_MINUTES, thisPeriodStartedAt)); } - + // Test flooring & ceiling UTC time to the closes 5-minute period @Test public void testFiveMinute_UTC(){ System.out.println("Testing 5-min with timestamp " + currentTime_UTC + " " + UTCTimeUtility.getDateString(currentTime_UTC)); - long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIVE_MINUTES, currentTime_UTC); + long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIVE_MINUTES, currentTime_UTC); long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.FIVE_MINUTES, currentTime_UTC); - + //verify period start is correct System.out.println(" 5-min start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt)); assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC); @@ -350,7 +349,7 @@ public class TimeUtilityTest { assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.FIVE_MINUTES, thisPeriodEndedAt)); assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.FIVE_MINUTES, thisPeriodStartedAt)); } - + // Test flooring & ceiling UTC time to the closes minute @Test public void testMinute_UTC(){ @@ -358,7 +357,7 @@ public class TimeUtilityTest { long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.MINUTE, currentTime_UTC); long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.MINUTE, currentTime_UTC); - + //verify period start is correct System.out.println(" minute start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt)); assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC); @@ -391,7 +390,7 @@ public class TimeUtilityTest { assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.MINUTE, thisPeriodEndedAt)); assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.MINUTE, thisPeriodStartedAt)); } - + // Test flooring & ceiling UTC time to the closes second @Test public void testSecond_UTC(){ @@ -399,7 +398,7 @@ public class TimeUtilityTest { long thisPeriodStartedAt = UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.SECOND, currentTime_UTC); long thisPeriodEndedAt = UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.SECOND, currentTime_UTC); - + //verify period start is correct System.out.println(" second start timestamp = " + thisPeriodStartedAt + " " + UTCTimeUtility.getDateString(thisPeriodStartedAt)); assertTrue("period start is not before current time", thisPeriodStartedAt <= currentTime_UTC); @@ -432,9 +431,9 @@ public class TimeUtilityTest { assertEquals("start and/or end timestamp is not in the same period", thisPeriodStartedAt, UTCTimeUtility.getTimestampPeriodStart(AggregationPeriodLength.SECOND, thisPeriodEndedAt)); assertEquals("start and/or end timestamp is not in the same period", thisPeriodEndedAt, UTCTimeUtility.getTimestampPeriodEnd(AggregationPeriodLength.SECOND, thisPeriodStartedAt)); } - + // Test printing converting milliseconds to text - @Test + @Test public void testMsToString(){ //low values assertEquals("00:00:00.000", UTCTimeUtility.timeInMsToString(0)); @@ -452,23 +451,23 @@ public class TimeUtilityTest { assertEquals("00:59:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.MINUTE_IN_MS*59)); assertEquals("23:00:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.HOUR_IN_MS*23)); assertEquals("52w+5d+00:00:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.DAY_IN_MS*369)); - + //high overflow values assertEquals("00:00:01.999", UTCTimeUtility.timeInMsToString(1999)); assertEquals("00:02:39.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.SECOND_IN_MS*159)); assertEquals("02:39:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.MINUTE_IN_MS*159)); assertEquals("5d+03:00:00.000", UTCTimeUtility.timeInMsToString(UTCTimeUtility.HOUR_IN_MS*123)); - + //combinations assertEquals("142w+5d+23:59:59.999", UTCTimeUtility.timeInMsToString((UTCTimeUtility.WEEK_IN_MS*142) + (UTCTimeUtility.DAY_IN_MS*5) + (UTCTimeUtility.HOUR_IN_MS*23) + (UTCTimeUtility.MINUTE_IN_MS*59) + (UTCTimeUtility.SECOND_IN_MS*59) + 999)); assertEquals("6d+23:59:59.999", UTCTimeUtility.timeInMsToString(UTCTimeUtility.WEEK_IN_MS-1)); } - + // Test printing converting milliseconds to text for a negative time @Test(expected=NumberFormatException.class) public void testMsToStringForNegativeArgument(){ //low values UTCTimeUtility.timeInMsToString(-1); } - + } diff --git a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomeImpl.java b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomeImpl.java index 7be52dad..687d5deb 100644 --- a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomeImpl.java +++ b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomeImpl.java @@ -16,11 +16,6 @@ package se.hal.plugin.assistant.google; -import java.sql.SQLException; -import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; - import com.google.actions.api.smarthome.*; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.GoogleCredentials; @@ -38,6 +33,11 @@ import zutil.db.DBConnection; import zutil.log.LogUtil; import zutil.net.http.page.oauth.OAuth2Registry.TokenRegistrationListener; +import java.sql.SQLException; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; + public class SmartHomeImpl extends SmartHomeApp implements TokenRegistrationListener { private static final Logger logger = LogUtil.getLogger(); diff --git a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomePage.java b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomePage.java index b2e1c6bb..8772bef7 100644 --- a/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomePage.java +++ b/plugins/hal-assistant-google/src/se/hal/plugin/assistant/google/SmartHomePage.java @@ -24,21 +24,17 @@ package se.hal.plugin.assistant.google; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.google.actions.api.smarthome.SmartHomeApp; -import se.hal.plugin.assistant.google.SmartHomeImpl; import zutil.io.IOUtil; import zutil.log.LogUtil; import zutil.net.http.HttpHeader; import zutil.net.http.HttpPage; import zutil.net.http.HttpPrintStream; +import java.io.IOException; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + /** * Handles Google SMartHome request received via HTTP POST. */ diff --git a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyController.java b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyController.java index c36a08ce..ba14d326 100644 --- a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyController.java +++ b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyController.java @@ -7,7 +7,8 @@ import se.hal.intf.*; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.*; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; public class DummyController implements HalSensorController, HalEventController, Runnable, HalDaemon { diff --git a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyHumiditySensor.java b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyHumiditySensor.java index 9b358fe3..0221241e 100644 --- a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyHumiditySensor.java +++ b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyHumiditySensor.java @@ -1,6 +1,9 @@ package se.hal.plugin.dummy; -import se.hal.intf.*; +import se.hal.intf.HalDeviceData; +import se.hal.intf.HalSensorConfig; +import se.hal.intf.HalSensorController; +import se.hal.intf.HalSensorData; import se.hal.struct.devicedata.HumiditySensorData; diff --git a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummySwitchEvent.java b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummySwitchEvent.java index ec0f6a51..18c0ec9d 100644 --- a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummySwitchEvent.java +++ b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummySwitchEvent.java @@ -1,6 +1,9 @@ package se.hal.plugin.dummy; -import se.hal.intf.*; +import se.hal.intf.HalDeviceData; +import se.hal.intf.HalEventConfig; +import se.hal.intf.HalEventController; +import se.hal.intf.HalEventData; import se.hal.struct.devicedata.OnOffEventData; public class DummySwitchEvent implements DummyDevice, HalEventConfig { diff --git a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyTemperatureSensor.java b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyTemperatureSensor.java index c92ea41d..54c55b6e 100644 --- a/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyTemperatureSensor.java +++ b/plugins/hal-dummy/src/se/hal/plugin/dummy/DummyTemperatureSensor.java @@ -1,6 +1,9 @@ package se.hal.plugin.dummy; -import se.hal.intf.*; +import se.hal.intf.HalDeviceData; +import se.hal.intf.HalSensorConfig; +import se.hal.intf.HalSensorController; +import se.hal.intf.HalSensorData; import se.hal.struct.devicedata.TemperatureSensorData; diff --git a/plugins/hal-mqtt/src/se/hal/plugin/mqtt/device/HalMqttDeviceConfig.java b/plugins/hal-mqtt/src/se/hal/plugin/mqtt/device/HalMqttDeviceConfig.java index 3e15f591..6baf96a4 100644 --- a/plugins/hal-mqtt/src/se/hal/plugin/mqtt/device/HalMqttDeviceConfig.java +++ b/plugins/hal-mqtt/src/se/hal/plugin/mqtt/device/HalMqttDeviceConfig.java @@ -48,7 +48,6 @@ package se.hal.plugin.mqtt.device; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventController; import se.hal.intf.HalEventData; diff --git a/plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java b/plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java index ae58092d..b4ef9811 100644 --- a/plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java +++ b/plugins/hal-netscan/src/se/hal/plugin/netscan/NetworkDevice.java @@ -1,11 +1,10 @@ package se.hal.plugin.netscan; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventController; import se.hal.intf.HalEventData; import se.hal.struct.devicedata.OnOffEventData; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; public class NetworkDevice implements HalEventConfig { diff --git a/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsController.java b/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsController.java index 8bf941c6..cd1ea141 100644 --- a/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsController.java +++ b/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsController.java @@ -49,7 +49,10 @@ package se.hal.plugin.nutups; import se.hal.HalContext; -import se.hal.intf.*; +import se.hal.intf.HalAutoScannableController; +import se.hal.intf.HalDeviceConfig; +import se.hal.intf.HalDeviceReportListener; +import se.hal.intf.HalSensorController; import zutil.log.LogUtil; import zutil.osal.linux.app.NutUPSClient; diff --git a/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java b/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java index 53be6f63..1d879f73 100644 --- a/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java +++ b/plugins/hal-nutups/src/se/hal/plugin/nutups/NutUpsDevice.java @@ -48,13 +48,12 @@ package se.hal.plugin.nutups; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalSensorConfig; import se.hal.intf.HalSensorController; import se.hal.intf.HalSensorData; import se.hal.struct.devicedata.PowerConsumptionSensorData; import zutil.osal.linux.app.NutUPSClient; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; public class NutUpsDevice implements HalSensorConfig{ diff --git a/plugins/hal-nvr/src/se/hal/plugin/nvr/rtsp/RTSPCameraConfig.java b/plugins/hal-nvr/src/se/hal/plugin/nvr/rtsp/RTSPCameraConfig.java index 7dd6a8db..7c638d9e 100644 --- a/plugins/hal-nvr/src/se/hal/plugin/nvr/rtsp/RTSPCameraConfig.java +++ b/plugins/hal-nvr/src/se/hal/plugin/nvr/rtsp/RTSPCameraConfig.java @@ -24,10 +24,9 @@ package se.hal.plugin.nvr.rtsp; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalDeviceData; -import se.hal.plugin.nvr.intf.HalCameraController; import se.hal.plugin.nvr.intf.HalCameraConfig; +import se.hal.plugin.nvr.intf.HalCameraController; public class RTSPCameraConfig implements HalCameraConfig { diff --git a/plugins/hal-nvr/src/se/hal/plugin/nvr/struct/Camera.java b/plugins/hal-nvr/src/se/hal/plugin/nvr/struct/Camera.java index da941411..9c9352da 100644 --- a/plugins/hal-nvr/src/se/hal/plugin/nvr/struct/Camera.java +++ b/plugins/hal-nvr/src/se/hal/plugin/nvr/struct/Camera.java @@ -25,9 +25,9 @@ package se.hal.plugin.nvr.struct; import se.hal.intf.HalAbstractController; +import se.hal.intf.HalAbstractDevice; import se.hal.plugin.nvr.intf.HalCameraConfig; import se.hal.plugin.nvr.intf.HalCameraData; -import se.hal.intf.HalAbstractDevice; import zutil.db.DBConnection; import zutil.db.bean.DBBean; diff --git a/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationClient.java b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationClient.java index b69bcde1..ec726a55 100644 --- a/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationClient.java +++ b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationClient.java @@ -25,18 +25,17 @@ package se.hal.plugin.powerchallenge.daemon; import se.hal.HalContext; +import se.hal.intf.HalDaemon; +import se.hal.page.HalAlertManager; import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationDaemon.PeerDataRspDTO; import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationDaemon.SensorDTO; import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationDaemon.SensorDataDTO; import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationDaemon.SensorDataListDTO; -import se.hal.intf.HalDaemon; -import se.hal.page.HalAlertManager; import se.hal.struct.Sensor; import se.hal.struct.User; import zutil.db.DBConnection; import zutil.log.LogUtil; import zutil.parser.json.JSONParser; -import zutil.ui.UserMessageManager; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; diff --git a/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationDaemon.java b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationDaemon.java index 9e5884c8..a40ef489 100644 --- a/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationDaemon.java +++ b/plugins/hal-powerchallenge/src/se/hal/plugin/powerchallenge/daemon/PCDataSynchronizationDaemon.java @@ -25,9 +25,9 @@ package se.hal.plugin.powerchallenge.daemon; import se.hal.HalContext; +import se.hal.intf.HalDaemon; import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationClient.PeerDataReqDTO; import se.hal.plugin.powerchallenge.daemon.PCDataSynchronizationClient.SensorDataReqDTO; -import se.hal.intf.HalDaemon; import se.hal.struct.Sensor; import se.hal.struct.User; import zutil.db.DBConnection; diff --git a/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiPowerConsumptionSensor.java b/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiPowerConsumptionSensor.java index ebe2d99a..8d9071c6 100644 --- a/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiPowerConsumptionSensor.java +++ b/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiPowerConsumptionSensor.java @@ -1,11 +1,10 @@ package se.hal.plugin.raspberry; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalSensorConfig; import se.hal.intf.HalSensorController; import se.hal.intf.HalSensorData; import se.hal.struct.devicedata.PowerConsumptionSensorData; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; public class RPiPowerConsumptionSensor implements HalSensorConfig { diff --git a/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiTemperatureSensor.java b/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiTemperatureSensor.java index f9285f5e..7c93a230 100644 --- a/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiTemperatureSensor.java +++ b/plugins/hal-raspberry/src/se/hal/plugin/raspberry/RPiTemperatureSensor.java @@ -1,11 +1,10 @@ package se.hal.plugin.raspberry; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalSensorConfig; import se.hal.intf.HalSensorController; import se.hal.intf.HalSensorData; import se.hal.struct.devicedata.TemperatureSensorData; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; public class RPiTemperatureSensor implements HalSensorConfig { diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java index 508c0d8f..a7f1364a 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearning.java @@ -22,7 +22,6 @@ package se.hal.plugin.tellstick.device; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventController; import se.hal.intf.HalEventData; @@ -31,7 +30,7 @@ import se.hal.plugin.tellstick.TellstickDeviceGroup; import se.hal.plugin.tellstick.TellstickSerialComm; import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol; import se.hal.struct.devicedata.OnOffEventData; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; /** * Created by Ziver on 2015-02-18. diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearningDimmer.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearningDimmer.java index 20463380..81066323 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearningDimmer.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/NexaSelfLearningDimmer.java @@ -22,7 +22,6 @@ package se.hal.plugin.tellstick.device; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventController; import se.hal.intf.HalEventData; @@ -30,7 +29,7 @@ import se.hal.plugin.tellstick.TellstickDevice; import se.hal.plugin.tellstick.TellstickSerialComm; import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol; import se.hal.struct.devicedata.DimmerEventData; -import zutil.ui.Configurator; +import zutil.ui.conf.Configurator; /** * Created by Ziver on 2015-02-18. diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java index c6ace72d..36815d64 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/device/Oregon0x1A2D.java @@ -1,6 +1,5 @@ package se.hal.plugin.tellstick.device; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalSensorConfig; import se.hal.intf.HalSensorController; import se.hal.intf.HalSensorData; @@ -12,7 +11,7 @@ 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; +import zutil.ui.conf.Configurator; import java.util.logging.Logger; diff --git a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java index f6c44457..945b70d1 100644 --- a/plugins/hal-tellstick/src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java +++ b/plugins/hal-tellstick/src/se/hal/plugin/tellstick/protocol/NexaSelfLearningProtocol.java @@ -24,9 +24,9 @@ package se.hal.plugin.tellstick.protocol; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventData; +import se.hal.plugin.tellstick.TellstickProtocol; import se.hal.plugin.tellstick.cmd.TellstickCmd; import se.hal.plugin.tellstick.cmd.TellstickCmdExtendedSend; -import se.hal.plugin.tellstick.TellstickProtocol; import se.hal.plugin.tellstick.device.NexaSelfLearning; import se.hal.plugin.tellstick.device.NexaSelfLearningDimmer; import se.hal.struct.devicedata.DimmerEventData; diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommEventTest.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommEventTest.java index 11c151bd..0ff6eaa7 100644 --- a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommEventTest.java +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommEventTest.java @@ -2,7 +2,9 @@ package se.hal.plugin.tellstick; import org.junit.Before; import org.junit.Test; -import se.hal.intf.*; +import se.hal.intf.HalDeviceReportListener; +import se.hal.intf.HalEventConfig; +import se.hal.intf.HalEventData; import se.hal.plugin.tellstick.test.TestEventDevice; import se.hal.plugin.tellstick.test.TestProtocol; diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommSensorTest.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommSensorTest.java index 05bc8d1d..81441213 100644 --- a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommSensorTest.java +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/TellstickSerialCommSensorTest.java @@ -2,7 +2,9 @@ package se.hal.plugin.tellstick; import org.junit.Before; import org.junit.Test; -import se.hal.intf.*; +import se.hal.intf.HalDeviceReportListener; +import se.hal.intf.HalSensorConfig; +import se.hal.intf.HalSensorData; import se.hal.plugin.tellstick.test.TestProtocol; import se.hal.plugin.tellstick.test.TestSensorDevice; diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestEventDevice.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestEventDevice.java index 1efad020..808f7421 100644 --- a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestEventDevice.java +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestEventDevice.java @@ -1,11 +1,9 @@ package se.hal.plugin.tellstick.test; -import se.hal.intf.HalDeviceConfig; import se.hal.intf.HalEventConfig; import se.hal.intf.HalEventController; import se.hal.intf.HalEventData; import se.hal.plugin.tellstick.TellstickDevice; -import se.hal.plugin.tellstick.TellstickSerialCommEventTest; public class TestEventDevice implements TellstickDevice, HalEventConfig { public int testData; diff --git a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestSensorDevice.java b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestSensorDevice.java index 1ed11fc2..790920d0 100644 --- a/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestSensorDevice.java +++ b/plugins/hal-tellstick/test/se/hal/plugin/tellstick/test/TestSensorDevice.java @@ -1,11 +1,9 @@ package se.hal.plugin.tellstick.test; -import se.hal.intf.HalDeviceConfig; 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.TellstickSerialCommSensorTest; public class TestSensorDevice implements HalSensorConfig, TellstickDevice { public int testData; diff --git a/plugins/hal-zigbee-deconz/src/se/hal/plugin/zigbee/deconz/zigbee/deconz/rest/DeConzRestRules.java b/plugins/hal-zigbee-deconz/src/se/hal/plugin/zigbee/deconz/zigbee/deconz/rest/DeConzRestRules.java index 912a8c46..3f286c88 100644 --- a/plugins/hal-zigbee-deconz/src/se/hal/plugin/zigbee/deconz/zigbee/deconz/rest/DeConzRestRules.java +++ b/plugins/hal-zigbee-deconz/src/se/hal/plugin/zigbee/deconz/zigbee/deconz/rest/DeConzRestRules.java @@ -3,7 +3,8 @@ package se.hal.plugin.zigbee.deconz.zigbee.deconz.rest; import zutil.net.ws.WSInterface.WSPath; import zutil.net.ws.WSInterface.WSRequestType; -import static zutil.net.ws.WSInterface.RequestType.*; +import static zutil.net.ws.WSInterface.RequestType.DELETE; +import static zutil.net.ws.WSInterface.RequestType.GET; /** * Rules provide the ability to trigger actions of lights or groups when a specific sensor condition is met. diff --git a/plugins/hal-zigbee-deconz/src/se/hal/plugin/zigbee/deconz/zigbee/deconz/rest/DeConzRestTouchlink.java b/plugins/hal-zigbee-deconz/src/se/hal/plugin/zigbee/deconz/zigbee/deconz/rest/DeConzRestTouchlink.java index 7c656890..8311391b 100644 --- a/plugins/hal-zigbee-deconz/src/se/hal/plugin/zigbee/deconz/zigbee/deconz/rest/DeConzRestTouchlink.java +++ b/plugins/hal-zigbee-deconz/src/se/hal/plugin/zigbee/deconz/zigbee/deconz/rest/DeConzRestTouchlink.java @@ -3,7 +3,8 @@ package se.hal.plugin.zigbee.deconz.zigbee.deconz.rest; import zutil.net.ws.WSInterface.WSPath; import zutil.net.ws.WSInterface.WSRequestType; -import static zutil.net.ws.WSInterface.RequestType.*; +import static zutil.net.ws.WSInterface.RequestType.GET; +import static zutil.net.ws.WSInterface.RequestType.POST; /** * The touchlink endpoint allows to communicate with near by located devices. diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/HalZigbeeController.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/HalZigbeeController.java index 4b94a456..f352d950 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/HalZigbeeController.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/HalZigbeeController.java @@ -2,7 +2,6 @@ package se.hal.plugin.zigbee; import com.zsmartsystems.zigbee.*; -import com.zsmartsystems.zigbee.app.basic.ZigBeeBasicServerExtension; import com.zsmartsystems.zigbee.app.discovery.ZigBeeDiscoveryExtension; import com.zsmartsystems.zigbee.app.iasclient.ZigBeeIasCieExtension; import com.zsmartsystems.zigbee.app.otaserver.ZigBeeOtaUpgradeExtension; @@ -12,20 +11,19 @@ import com.zsmartsystems.zigbee.dongle.xbee.ZigBeeDongleXBee; import com.zsmartsystems.zigbee.security.ZigBeeKey; import com.zsmartsystems.zigbee.serialization.DefaultDeserializer; import com.zsmartsystems.zigbee.serialization.DefaultSerializer; -import com.zsmartsystems.zigbee.transport.*; +import com.zsmartsystems.zigbee.transport.TransportConfig; +import com.zsmartsystems.zigbee.transport.TransportConfigOption; +import com.zsmartsystems.zigbee.transport.ZigBeePort; +import com.zsmartsystems.zigbee.transport.ZigBeeTransportTransmit; import com.zsmartsystems.zigbee.zcl.clusters.*; -import com.zsmartsystems.zigbee.zdo.command.NetworkAddressRequest; import com.zsmartsystems.zigbee.zdo.field.NodeDescriptor; import se.hal.HalContext; import se.hal.intf.*; -import se.hal.intf.HalAbstractDevice; import zutil.log.LogUtil; -import java.nio.channels.Channel; -import java.util.*; +import java.util.HashSet; +import java.util.List; import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** * diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigBeeJSerialCommPort.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigBeeJSerialCommPort.java index 5c91c598..05822bb1 100644 --- a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigBeeJSerialCommPort.java +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/ZigBeeJSerialCommPort.java @@ -24,12 +24,11 @@ package se.hal.plugin.zigbee; +import com.fazecast.jSerialComm.SerialPort; import com.zsmartsystems.zigbee.transport.ZigBeePort; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fazecast.jSerialComm.SerialPort; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; diff --git a/plugins/hal-zwave/src/se/hal/plugin/zwave/HalZWaveController.java b/plugins/hal-zwave/src/se/hal/plugin/zwave/HalZWaveController.java index 21262a85..63a9a529 100644 --- a/plugins/hal-zwave/src/se/hal/plugin/zwave/HalZWaveController.java +++ b/plugins/hal-zwave/src/se/hal/plugin/zwave/HalZWaveController.java @@ -3,7 +3,6 @@ package se.hal.plugin.zwave; import org.zwave4j.*; import se.hal.HalContext; import se.hal.intf.*; -import se.hal.intf.HalAbstractDevice; import zutil.log.LogUtil; import java.util.List; diff --git a/settings.gradle b/settings.gradle index 1443b8da..85f4ef96 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -import static groovy.io.FileType.* +import static groovy.io.FileType.DIRECTORIES rootProject.name = "Hal"