Improved MQTT Unkown device printout
This commit is contained in:
parent
2d2a79470d
commit
dd0cc96d58
2 changed files with 16 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ subprojects {
|
||||||
apply plugin: 'java-library'
|
apply plugin: 'java-library'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'se.koc:zutil:1.0.313'
|
implementation 'se.koc:zutil:1.0.314'
|
||||||
//implementation 'se.koc:zutil:1.0.0-SNAPSHOT'
|
//implementation 'se.koc:zutil:1.0.0-SNAPSHOT'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,22 @@ package se.hal.plugin.mqtt.device;
|
||||||
import se.hal.intf.HalDeviceData;
|
import se.hal.intf.HalDeviceData;
|
||||||
import se.hal.intf.HalEventController;
|
import se.hal.intf.HalEventController;
|
||||||
import se.hal.plugin.mqtt.HalMqttController;
|
import se.hal.plugin.mqtt.HalMqttController;
|
||||||
|
import se.hal.struct.devicedata.TemperatureSensorData;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a unknown device data type
|
* Represents an unknown device data type
|
||||||
*/
|
*/
|
||||||
public class HalMqttUnknownDeviceConfig extends HalMqttDeviceConfig {
|
public class HalMqttUnknownDeviceConfig extends HalMqttDeviceConfig {
|
||||||
|
|
||||||
|
/** Save data so it can be provided to user for analysis, the data will not be used in any other way */
|
||||||
|
transient String data;
|
||||||
|
|
||||||
public HalMqttUnknownDeviceConfig(String topic) {
|
|
||||||
|
public HalMqttUnknownDeviceConfig(String topic, byte[] data) {
|
||||||
setTopic(topic);
|
setTopic(topic);
|
||||||
|
this.data = new String(data, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
|
@ -49,7 +56,7 @@ public class HalMqttUnknownDeviceConfig extends HalMqttDeviceConfig {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends HalDeviceData> getDeviceDataClass() {
|
public Class<? extends HalDeviceData> getDeviceDataClass() {
|
||||||
return null;
|
return TemperatureSensorData.class; // Just return any data class just so we do not get so many error logs
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -61,4 +68,9 @@ public class HalMqttUnknownDeviceConfig extends HalMqttDeviceConfig {
|
||||||
public AggregationMethod getAggregationMethod() {
|
public AggregationMethod getAggregationMethod() {
|
||||||
return AggregationMethod.AVERAGE;
|
return AggregationMethod.AVERAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Topic: " + getTopic() + ", Data: " + data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue