added migrated 2.x add-ons
Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.UpdateStatus;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.ConditionHandlerExtension;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.unit.SIUnits;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
|
||||
/**
|
||||
* The {@link ConditionHandlerTest} Test Condition Handler updates
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class ConditionHandlerTest {
|
||||
|
||||
@Test
|
||||
public void testValidNoPressureUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
ConditionHandlerExtension condHandler = new ConditionHandlerExtension(t);
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = condHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.OK, result);
|
||||
assertEquals("Temperature", QuantityType.valueOf(22.7, SIUnits.CELSIUS), condHandler.getTemperature());
|
||||
assertEquals("Humidity", QuantityType.valueOf(61.0, SmartHomeUnits.PERCENT), condHandler.getHumidity());
|
||||
assertEquals("Pressure", QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressure());
|
||||
assertEquals("Pressure Sea", QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressureSea());
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidWithPressureUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
ConditionHandlerExtension condHandler = new ConditionHandlerExtension(t);
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/condition-result-plus-pressure.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = condHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.OK, result);
|
||||
assertEquals("Temperature", QuantityType.valueOf(21.5, SIUnits.CELSIUS), condHandler.getTemperature());
|
||||
assertEquals("Humidity", QuantityType.valueOf(58.5, SmartHomeUnits.PERCENT), condHandler.getHumidity());
|
||||
assertEquals("Pressure", QuantityType.valueOf(100200.0, SIUnits.PASCAL), condHandler.getPressure());
|
||||
assertEquals("Pressure Sea", QuantityType.valueOf(101968.7, SIUnits.PASCAL), condHandler.getPressureSea());
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
ConditionHandlerExtension condHandler = new ConditionHandlerExtension(t);
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/noise-result.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = condHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_ERROR, result);
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
ConditionHandlerExtension condHandler = new ConditionHandlerExtension(t);
|
||||
UpdateStatus result = condHandler.updateChannels("[]");
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_EMPTY, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
ConditionHandlerExtension condHandler = new ConditionHandlerExtension(t);
|
||||
UpdateStatus result = condHandler.updateChannels(null);
|
||||
assertEquals("Valid update", UpdateStatus.CONNECTION_ERROR, result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.dto.SensorData;
|
||||
import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* The {@link DTOTest} Data Transfer Object - test conversions
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class DTOTest {
|
||||
|
||||
@Test
|
||||
public void testConditions() {
|
||||
String result = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
|
||||
Gson gson = new Gson();
|
||||
SensorData[] valueArray = gson.fromJson(result, SensorData[].class);
|
||||
// System.out.println(valueArray.length);
|
||||
assertEquals("Array size", 2, valueArray.length);
|
||||
|
||||
SensorData d = valueArray[0];
|
||||
// Assure latest data is taken
|
||||
String dateStr = d.getTimeStamp();
|
||||
if (dateStr.equals("2020-06-09 06:38:08")) {
|
||||
// take newer one
|
||||
d = valueArray[1];
|
||||
}
|
||||
List<SensorDataValue> sensorDataVaueList = d.getSensorDataValues();
|
||||
assertNotNull(d);
|
||||
sensorDataVaueList.forEach(v -> {
|
||||
if (v.getValueType().equals(HTTPHandler.TEMPERATURE)) {
|
||||
assertEquals("Temperature", "22.70", v.getValue());
|
||||
} else if (v.getValueType().equals(HTTPHandler.HUMIDITY)) {
|
||||
assertEquals("Humidity", "61.00", v.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecoding() {
|
||||
String result = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
|
||||
Gson gson = new Gson();
|
||||
SensorData[] valueArray = gson.fromJson(result, SensorData[].class);
|
||||
// System.out.println(valueArray.length);
|
||||
assertEquals("Array size", 2, valueArray.length);
|
||||
|
||||
SensorData d = valueArray[0];
|
||||
// Assure latest data is taken
|
||||
String dateStr = d.getTimeStamp();
|
||||
if (dateStr.equals("2020-06-09 06:38:08")) {
|
||||
// take newer one
|
||||
d = valueArray[1];
|
||||
}
|
||||
|
||||
// test decoding a small part
|
||||
String json = gson.toJson(d);
|
||||
// System.out.println(json);
|
||||
// check if correct timestamp is included
|
||||
assertTrue(json.contains("\"timestamp\":\"2020-06-09 06:40:34\""));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
|
||||
/**
|
||||
* The {@link HTTPHandlerEvalTest} test all evaluations on SensorDataValues
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class HTTPHandlerEvalTest {
|
||||
|
||||
private @Nullable List<SensorDataValue> conditions;
|
||||
private @Nullable List<SensorDataValue> particulate;
|
||||
private @Nullable List<SensorDataValue> noise;
|
||||
private HTTPHandler http = new HTTPHandler();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
String conditionsStr = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
|
||||
assertNotNull(conditionsStr);
|
||||
conditions = http.getLatestValues(conditionsStr);
|
||||
|
||||
String particulateStr = FileReader.readFileInString("src/test/resources/pm-result.json");
|
||||
assertNotNull(particulateStr);
|
||||
particulate = http.getLatestValues(particulateStr);
|
||||
|
||||
String noiseStr = FileReader.readFileInString("src/test/resources/noise-result.json");
|
||||
assertNotNull(noiseStr);
|
||||
noise = http.getLatestValues(noiseStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsCondition() {
|
||||
assertTrue(http.isCondition(conditions));
|
||||
assertFalse(http.isCondition(particulate));
|
||||
assertFalse(http.isCondition(noise));
|
||||
assertFalse(http.isCondition(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsParticulate() {
|
||||
assertFalse(http.isParticulate(conditions));
|
||||
assertTrue(http.isParticulate(particulate));
|
||||
assertFalse(http.isParticulate(noise));
|
||||
assertFalse(http.isParticulate(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNoise() {
|
||||
assertFalse(http.isNoise(conditions));
|
||||
assertFalse(http.isNoise(particulate));
|
||||
assertTrue(http.isNoise(noise));
|
||||
assertFalse(http.isNoise(null));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
|
||||
/**
|
||||
* The {@link HTTPHandlerValueTest} test values decoding of HTTPHandler
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class HTTPHandlerValueTest {
|
||||
private HTTPHandler http = new HTTPHandler();
|
||||
|
||||
/**
|
||||
* test if really the latest values are returned
|
||||
* resource1 is json with ordering according to time while resource2 the entries flipped
|
||||
*/
|
||||
@Test
|
||||
public void testValueDecoding() {
|
||||
String resource1 = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
|
||||
assertNotNull(resource1);
|
||||
List<SensorDataValue> l = http.getLatestValues(resource1);
|
||||
assertNotNull(l);
|
||||
l.forEach(sd -> {
|
||||
testSensorValue(sd);
|
||||
});
|
||||
|
||||
String resource2 = FileReader
|
||||
.readFileInString("src/test/resources/condition-result-no-pressure-flipped-values.json");
|
||||
assertNotNull(resource2);
|
||||
l = http.getLatestValues(resource2);
|
||||
assertNotNull(l);
|
||||
l.forEach(sd -> {
|
||||
testSensorValue(sd);
|
||||
});
|
||||
}
|
||||
|
||||
private void testSensorValue(SensorDataValue s) {
|
||||
if (s.getValueType().equals(HTTPHandler.TEMPERATURE)) {
|
||||
assertEquals("Temperature resource 1", "22.70", s.getValue());
|
||||
} else if (s.getValueType().equals(HTTPHandler.HUMIDITY)) {
|
||||
assertEquals("Humidity resource 1", "61.00", s.getValue());
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
// System.out.println(s.getValue_type() + ":" + s.getValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.UpdateStatus;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.NoiseHandlerExtension;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
|
||||
/**
|
||||
* The {@link NoiseHandlerTest} Test Noise Handler updates
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class NoiseHandlerTest {
|
||||
|
||||
@Test
|
||||
public void testValidUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
NoiseHandlerExtension noiseHandler = new NoiseHandlerExtension(t);
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/noise-result.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = noiseHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.OK, result);
|
||||
assertEquals("Noise EQ", QuantityType.valueOf(51.0, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseEQCache());
|
||||
assertEquals("Noise Min", QuantityType.valueOf(47.2, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseMinCache());
|
||||
assertEquals("Noise Max", QuantityType.valueOf(57.0, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseMaxCache());
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
NoiseHandlerExtension noiseHandler = new NoiseHandlerExtension(t);
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = noiseHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_ERROR, result);
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseEQCache());
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseMinCache());
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseMaxCache());
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
NoiseHandlerExtension noiseHandler = new NoiseHandlerExtension(t);
|
||||
UpdateStatus result = noiseHandler.updateChannels("[]");
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_EMPTY, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
NoiseHandlerExtension noiseHandler = new NoiseHandlerExtension(t);
|
||||
UpdateStatus result = noiseHandler.updateChannels(null);
|
||||
assertEquals("Valid update", UpdateStatus.CONNECTION_ERROR, result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.utils.NumberUtils;
|
||||
|
||||
/**
|
||||
* The {@link NumberTest} Test rounding and converting Numbers
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class NumberTest {
|
||||
|
||||
@Test
|
||||
public void testRoundingUp() {
|
||||
double d1 = 1.95;
|
||||
double d1r2 = NumberUtils.round(d1, 2);
|
||||
assertEquals("Double 1.95, 2 places ", "1.95", Double.toString(d1r2));
|
||||
// System.out.println("D1R2 " + d1r2);
|
||||
double d1r1 = NumberUtils.round(d1, 1);
|
||||
// System.out.println("D1R1 " + d1r1);
|
||||
assertEquals("Double 1.95, 1 place ", "2.0", Double.toString(d1r1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoundingDown() {
|
||||
double d1 = 1.94;
|
||||
double d1r2 = NumberUtils.round(d1, 2);
|
||||
assertEquals("Double 1.94, 2 places ", "1.94", Double.toString(d1r2));
|
||||
// System.out.println("D1R2 " + d1r2);
|
||||
double d1r1 = NumberUtils.round(d1, 1);
|
||||
// System.out.println("D1R1 " + d1r1);
|
||||
assertEquals("Double 1.94, 1 place ", "1.9", Double.toString(d1r1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringNumbers() {
|
||||
String d1 = "1.94";
|
||||
double d1r2 = NumberUtils.round(d1, 2);
|
||||
assertEquals("Double 1.94, 2 places ", "1.94", Double.toString(d1r2));
|
||||
// System.out.println("D1R2 " + d1r2);
|
||||
double d1r1 = NumberUtils.round(d1, 1);
|
||||
// System.out.println("D1R1 " + d1r1);
|
||||
assertEquals("Double 1.94, 1 place ", "1.9", Double.toString(d1r1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.ConfigStatus;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.LifecycleStatus;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.UpdateStatus;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.PMHandlerExtension;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
import org.openhab.core.library.types.QuantityType;
|
||||
import org.openhab.core.library.unit.SmartHomeUnits;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The {@link PMHandlerTest} Test Particualte Matter Handler - Config and updates
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class PMHandlerTest {
|
||||
private Logger logger = LoggerFactory.getLogger(PMHandlerTest.class);
|
||||
|
||||
@Test
|
||||
public void testValidConfigStatus() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
PMHandlerExtension pmHandler = new PMHandlerExtension(t);
|
||||
pmHandler.initialize();
|
||||
logger.info("LC status: {}", pmHandler.getLifecycleStatus());
|
||||
int retryCount = 0; // Test shall fail after max 10 seconds
|
||||
while (pmHandler.getLifecycleStatus() != LifecycleStatus.RUNNING && retryCount < 20) {
|
||||
try {
|
||||
logger.info("LC running not reached - wait");
|
||||
Thread.sleep(500);
|
||||
retryCount++;
|
||||
} catch (InterruptedException e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Test if config status is 0 = CONFIG_OK for valid configuration. Take real int for comparison instead of
|
||||
* BaseHandler constants - in case of change test needs to be adapted
|
||||
*/
|
||||
assertEquals("Handler Configuration status", ConfigStatus.OK, pmHandler.getConfigStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidConfigStatus() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", -1);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
PMHandlerExtension pmHandler = new PMHandlerExtension(t);
|
||||
pmHandler.initialize();
|
||||
logger.info("LC status: {}", pmHandler.getLifecycleStatus());
|
||||
int retryCount = 0; // Test shall fail after max 10 seconds
|
||||
while (pmHandler.getLifecycleStatus() != LifecycleStatus.RUNNING && retryCount < 20) {
|
||||
try {
|
||||
logger.info("LC running not reached - wait");
|
||||
Thread.sleep(500);
|
||||
retryCount++;
|
||||
} catch (InterruptedException e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Test if config status is 3 = CONFIG_SENSOR_NUMBER for invalid configuration with non-number sensorid. Take
|
||||
* real int for comparison instead of BaseHandler constants - in case of change test needs to be adapted
|
||||
*/
|
||||
assertEquals("Handler Configuration status", ConfigStatus.SENSOR_ID_NEGATIVE, pmHandler.getConfigStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
PMHandlerExtension pmHandler = new PMHandlerExtension(t);
|
||||
pmHandler.initialize();
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/pm-result.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = pmHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.OK, result);
|
||||
assertEquals("PM25", QuantityType.valueOf(2.9, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
|
||||
pmHandler.getPM25Cache());
|
||||
assertEquals("PM100", QuantityType.valueOf(5.2, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
|
||||
pmHandler.getPM100Cache());
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
PMHandlerExtension pmHandler = new PMHandlerExtension(t);
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/noise-result.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = pmHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_ERROR, result);
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
|
||||
pmHandler.getPM25Cache());
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
|
||||
pmHandler.getPM100Cache());
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
PMHandlerExtension pmHandler = new PMHandlerExtension(t);
|
||||
UpdateStatus result = pmHandler.updateChannels("[]");
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_EMPTY, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullUpdate() {
|
||||
ThingMock t = new ThingMock();
|
||||
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
// String sensorid taken from thing-types.xml
|
||||
properties.put("sensorid", 12345);
|
||||
t.setConfiguration(properties);
|
||||
|
||||
PMHandlerExtension pmHandler = new PMHandlerExtension(t);
|
||||
UpdateStatus result = pmHandler.updateChannels(null);
|
||||
assertEquals("Valid update", UpdateStatus.CONNECTION_ERROR, result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal.mock;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.ConditionHandler;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
/**
|
||||
* The {@link NoiseHandlerExtension} Test Noise Handler Extension with additonal state queries
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class ConditionHandlerExtension extends ConditionHandler {
|
||||
|
||||
public ConditionHandlerExtension(Thing thing) {
|
||||
super(thing);
|
||||
}
|
||||
|
||||
public ConfigStatus getConfigStatus() {
|
||||
return configStatus;
|
||||
}
|
||||
|
||||
public UpdateStatus getUpdateStatus() {
|
||||
return lastUpdateStatus;
|
||||
}
|
||||
|
||||
public @Nullable State getTemperature() {
|
||||
return temperatureCache;
|
||||
}
|
||||
|
||||
public @Nullable State getHumidity() {
|
||||
return humidityCache;
|
||||
}
|
||||
|
||||
public @Nullable State getPressure() {
|
||||
return pressureCache;
|
||||
}
|
||||
|
||||
public @Nullable State getPressureSea() {
|
||||
return pressureSeaCache;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal.mock;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.NoiseHandler;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
/**
|
||||
* The {@link NoiseHandlerExtension} Test Noise Handler Extension with additonal state queries
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class NoiseHandlerExtension extends NoiseHandler {
|
||||
|
||||
public NoiseHandlerExtension(Thing thing) {
|
||||
super(thing);
|
||||
}
|
||||
|
||||
public ConfigStatus getConfigStatus() {
|
||||
return configStatus;
|
||||
}
|
||||
|
||||
public UpdateStatus getUpdateStatus() {
|
||||
return lastUpdateStatus;
|
||||
}
|
||||
|
||||
public @Nullable State getNoiseEQCache() {
|
||||
return noiseEQCache;
|
||||
}
|
||||
|
||||
public @Nullable State getNoiseMinCache() {
|
||||
return noiseMinCache;
|
||||
}
|
||||
|
||||
public @Nullable State getNoiseMaxCache() {
|
||||
return noiseMaxCache;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal.mock;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.PMHandler;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.types.State;
|
||||
|
||||
/**
|
||||
* The {@link PMHandlerExtension} Test Particualte Matter Handler Extension with additonal state queries
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class PMHandlerExtension extends PMHandler {
|
||||
|
||||
public PMHandlerExtension(Thing thing) {
|
||||
super(thing);
|
||||
}
|
||||
|
||||
public ConfigStatus getConfigStatus() {
|
||||
return configStatus;
|
||||
}
|
||||
|
||||
public UpdateStatus getUpdateStatus() {
|
||||
return lastUpdateStatus;
|
||||
}
|
||||
|
||||
public @Nullable State getPM25Cache() {
|
||||
return pm25Cache;
|
||||
}
|
||||
|
||||
public @Nullable State getPM100Cache() {
|
||||
return pm100Cache;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal.mock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.core.config.core.Configuration;
|
||||
import org.openhab.core.thing.Channel;
|
||||
import org.openhab.core.thing.ChannelUID;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingStatus;
|
||||
import org.openhab.core.thing.ThingStatusDetail;
|
||||
import org.openhab.core.thing.ThingStatusInfo;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
import org.openhab.core.thing.ThingUID;
|
||||
import org.openhab.core.thing.binding.ThingHandler;
|
||||
|
||||
/**
|
||||
* The {@link ThingMock} Thing Mock
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class ThingMock implements Thing {
|
||||
private Configuration config = new Configuration();
|
||||
|
||||
@Override
|
||||
public @Nullable String getLabel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLabel(@Nullable String label) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Channel> getChannels() {
|
||||
return new ArrayList<Channel>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Channel> getChannelsOfGroup(String channelGroupId) {
|
||||
return new ArrayList<Channel>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Channel getChannel(String channelId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Channel getChannel(ChannelUID channelUID) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThingStatus getStatus() {
|
||||
return ThingStatus.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThingStatusInfo getStatusInfo() {
|
||||
return new ThingStatusInfo(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatusInfo(ThingStatusInfo status) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHandler(@Nullable ThingHandler thingHandler) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ThingHandler getHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ThingUID getBridgeUID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBridgeUID(@Nullable ThingUID bridgeUID) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfiguration(Map<String, Object> m) {
|
||||
config = new Configuration(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThingUID getUID() {
|
||||
return new ThingUID("", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThingTypeUID getThingTypeUID() {
|
||||
return new ThingTypeUID("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getProperties() {
|
||||
return new HashMap<String, String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String setProperty(String name, @Nullable String value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(Map<String, String> properties) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(@Nullable String location) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.utils.DateTimeUtils;
|
||||
|
||||
/**
|
||||
* The {@link DateTimeTest} Test DateTimeFormatter provided in utils package
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class DateTimeTest {
|
||||
|
||||
@Test
|
||||
public void testJSonTime() {
|
||||
String jsonDateString = "2020-08-14 14:53:21";
|
||||
try {
|
||||
LocalDateTime dt = LocalDateTime.from(DateTimeUtils.DTF.parse(jsonDateString));
|
||||
assertEquals("Day ", 14, dt.getDayOfMonth());
|
||||
assertEquals("Month ", 8, dt.getMonthValue());
|
||||
assertEquals("Year ", 2020, dt.getYear());
|
||||
|
||||
String s = dt.format(DateTimeUtils.DTF);
|
||||
assertEquals("String ", jsonDateString, s);
|
||||
} catch (DateTimeParseException e) {
|
||||
assertFalse(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2020 Contributors to the openHAB project
|
||||
*
|
||||
* See the NOTICE file(s) distributed with this work for additional
|
||||
* information.
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal.util;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The {@link FileReader} Helper Util to read test resource files
|
||||
*
|
||||
* @author Bernd Weymann - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class FileReader {
|
||||
|
||||
public static @Nullable String readFileInString(String filename) {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "CP1252"));) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
String sCurrentLine;
|
||||
|
||||
while ((sCurrentLine = br.readLine()) != null) {
|
||||
buf.append(sCurrentLine);
|
||||
}
|
||||
return buf.toString();
|
||||
} catch (IOException e) {
|
||||
// fail if file cannot be read
|
||||
assertTrue(false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
[
|
||||
{
|
||||
"id": 731117559,
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"id": 1573660194,
|
||||
"value_type": "temperature",
|
||||
"value": "22.70"
|
||||
},
|
||||
{
|
||||
"id": 1573660195,
|
||||
"value_type": "humidity",
|
||||
"value": "61.00"
|
||||
}
|
||||
],
|
||||
"timestamp": "2020-06-09 06:40:34",
|
||||
"sampling_rate": null,
|
||||
"location": {
|
||||
"id": 11447,
|
||||
"country": "DE",
|
||||
"altitude": "151.5",
|
||||
"latitude": "50.562",
|
||||
"longitude": "8.504",
|
||||
"indoor": 0,
|
||||
"exact_location": 0
|
||||
},
|
||||
"sensor": {
|
||||
"id": 22562,
|
||||
"pin": "7",
|
||||
"sensor_type": {
|
||||
"id": 9,
|
||||
"manufacturer": "various",
|
||||
"name": "DHT22"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 731094694,
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"id": 1573610869,
|
||||
"value_type": "temperature",
|
||||
"value": "22.50"
|
||||
},
|
||||
{
|
||||
"id": 1573610870,
|
||||
"value_type": "humidity",
|
||||
"value": "62.00"
|
||||
}
|
||||
],
|
||||
"timestamp": "2020-06-09 06:38:08",
|
||||
"sampling_ra
|
||||
te": null,
|
||||
"location": {
|
||||
"id": 11447,
|
||||
"country": "DE",
|
||||
"altitude": "151.5",
|
||||
"latitude": "50.562",
|
||||
"longitude": "8.504",
|
||||
"indoor": 0,
|
||||
"exact_location": 0
|
||||
},
|
||||
"sensor": {
|
||||
"id": 22562,
|
||||
"pin": "7",
|
||||
"sensor_type": {
|
||||
"id": 9,
|
||||
"manufacturer": "various",
|
||||
"name": "DHT22"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,72 @@
|
||||
[
|
||||
{
|
||||
"id": 731094694,
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"id": 1573610869,
|
||||
"value_type": "temperature",
|
||||
"value": "22.50"
|
||||
},
|
||||
{
|
||||
"id": 1573610870,
|
||||
"value_type": "humidity",
|
||||
"value": "62.00"
|
||||
}
|
||||
],
|
||||
"timestamp": "2020-06-09 06:38:08",
|
||||
"sampling_rate": null,
|
||||
"location": {
|
||||
"id": 11447,
|
||||
"country": "DE",
|
||||
"altitude": "151.5",
|
||||
"latitude": "50.562",
|
||||
"longitude": "8.504",
|
||||
"indoor": 0,
|
||||
"exact_location": 0
|
||||
},
|
||||
"sensor": {
|
||||
"id": 22562,
|
||||
"pin": "7",
|
||||
"sensor_type": {
|
||||
"id": 9,
|
||||
"manufacturer": "various",
|
||||
"name": "DHT22"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 731117559,
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"id": 1573660194,
|
||||
"value_type": "temperature",
|
||||
"value": "22.70"
|
||||
},
|
||||
{
|
||||
"id": 1573660195,
|
||||
"value_type": "humidity",
|
||||
"value": "61.00"
|
||||
}
|
||||
],
|
||||
"timestamp": "2020-06-09 06:40:34",
|
||||
"sampling_rate": null,
|
||||
"location": {
|
||||
"id": 11447,
|
||||
"country": "DE",
|
||||
"altitude": "151.5",
|
||||
"latitude": "50.562",
|
||||
"longitude": "8.504",
|
||||
"indoor": 0,
|
||||
"exact_location": 0
|
||||
},
|
||||
"sensor": {
|
||||
"id": 22562,
|
||||
"pin": "7",
|
||||
"sensor_type": {
|
||||
"id": 9,
|
||||
"manufacturer": "various",
|
||||
"name": "DHT22"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,90 @@
|
||||
[
|
||||
{
|
||||
"id": 1038856661,
|
||||
"sensor": {
|
||||
"id": 28843,
|
||||
"sensor_type": {
|
||||
"id": 17,
|
||||
"manufacturer": "Bosch",
|
||||
"name": "BME280"
|
||||
},
|
||||
"pin": "11"
|
||||
},
|
||||
"timestamp": "2020-07-03 09:39:46",
|
||||
"sampling_rate": null,
|
||||
"location": {
|
||||
"id": 15975,
|
||||
"altitude": "151.2",
|
||||
"longitude": "8.49543571448",
|
||||
"exact_location": 1,
|
||||
"latitude": "50.55591005174",
|
||||
"indoor": 0,
|
||||
"country": "DE"
|
||||
},
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"id": 2237770681,
|
||||
"value_type": "temperature",
|
||||
"value": "21.52"
|
||||
},
|
||||
{
|
||||
"id": 2237770683,
|
||||
"value_type": "pressure",
|
||||
"value": "100199.97"
|
||||
},
|
||||
{
|
||||
"id": 2237770684,
|
||||
"value_type": "humidity",
|
||||
"value": "58.51"
|
||||
},
|
||||
{
|
||||
"value_type": "pressure_at_sealevel",
|
||||
"value": 101968.66
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1038834126,
|
||||
"sensor": {
|
||||
"id": 28843,
|
||||
"sensor_type": {
|
||||
"id": 17,
|
||||
"manufacturer": "Bosch",
|
||||
"name": "BME280"
|
||||
},
|
||||
"pin": "11"
|
||||
},
|
||||
"timestamp": "2020-07-03 09:37:21",
|
||||
"sampling_rate": null,
|
||||
"location": {
|
||||
"id": 15975,
|
||||
"altitude": "151.2",
|
||||
"longitude": "8.49543571448",
|
||||
"exact_location": 1,
|
||||
"latitude": "50.55591005174",
|
||||
"indoor": 0,
|
||||
"country": "DE"
|
||||
},
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"id": 2237722004,
|
||||
"value_type": "temperature",
|
||||
"value": "21.45"
|
||||
},
|
||||
{
|
||||
"id": 2237722008,
|
||||
"value_type": "pressure",
|
||||
"value": "100205.09"
|
||||
},
|
||||
{
|
||||
"id": 2237722009,
|
||||
"value_type": "humidity",
|
||||
"value": "58.79"
|
||||
},
|
||||
{
|
||||
"value_type": "pressure_at_sealevel",
|
||||
"value": 101974.29
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,82 @@
|
||||
[
|
||||
{
|
||||
"timestamp": "2020-06-11 09:39:51",
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"value": "50.95",
|
||||
"id": 1629930130,
|
||||
"value_type": "noise_LAeq"
|
||||
},
|
||||
{
|
||||
"value": "47.20",
|
||||
"id": 1629930131,
|
||||
"value_type": "noise_LA_min"
|
||||
},
|
||||
{
|
||||
"value": "56.95",
|
||||
"id": 1629930132,
|
||||
"value_type": "noise_LA_max"
|
||||
}
|
||||
],
|
||||
"sampling_rate": null,
|
||||
"location": {
|
||||
"exact_location": 1,
|
||||
"latitude": "50.88827895000",
|
||||
"country": "DE",
|
||||
"altitude": "294.9",
|
||||
"indoor": 0,
|
||||
"longitude": "7.87451286686",
|
||||
"id": 25429
|
||||
},
|
||||
"id": 757217220,
|
||||
"sensor": {
|
||||
"sensor_type": {
|
||||
"id": 29,
|
||||
"manufacturer": "Luftdaten.info",
|
||||
"name": "Laerm"
|
||||
},
|
||||
"pin": "15",
|
||||
"id": 39745
|
||||
}
|
||||
},
|
||||
{
|
||||
"timestamp": "2020-06-11 09:37:25",
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"value": "52.02",
|
||||
"id": 1629881984,
|
||||
"value_type": "noise_LAeq"
|
||||
},
|
||||
{
|
||||
"value": "45.98",
|
||||
"id": 1629881986,
|
||||
"value_type": "noise_LA_min"
|
||||
},
|
||||
{
|
||||
"value": "69.28",
|
||||
"id": 1629881987,
|
||||
"value_type": "noise_LA_max"
|
||||
}
|
||||
],
|
||||
"sampling_rate": null,
|
||||
"location": {
|
||||
"exact_location": 1,
|
||||
"latitude": "50.88827895000",
|
||||
"country": "DE",
|
||||
"altitude": "294.9",
|
||||
"indoor": 0,
|
||||
"longitude": "7.87451286686",
|
||||
"id": 25429
|
||||
},
|
||||
"id": 757194885,
|
||||
"sensor": {
|
||||
"sensor_type": {
|
||||
"id": 29,
|
||||
"manufacturer": "Luftdaten.info",
|
||||
"name": "Laerm"
|
||||
},
|
||||
"pin": "15",
|
||||
"id": 39745
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,72 @@
|
||||
[
|
||||
{
|
||||
"timestamp": "2020-06-11 09:40:41",
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"value": "5.15",
|
||||
"id": 1629948185,
|
||||
"value_type": "P1"
|
||||
},
|
||||
{
|
||||
"value": "2.87",
|
||||
"id": 1629948191,
|
||||
"value_type": "P2"
|
||||
}
|
||||
],
|
||||
"sampling_rate": null,
|
||||
"location": {
|
||||
"exact_location": 1,
|
||||
"latitude": "50.55591005174",
|
||||
"country": "DE",
|
||||
"altitude": "151.2",
|
||||
"indoor": 0,
|
||||
"longitude": "8.49543571448",
|
||||
"id": 15975
|
||||
},
|
||||
"id": 757225623,
|
||||
"sensor": {
|
||||
"sensor_type": {
|
||||
"id": 14,
|
||||
"manufacturer": "Nova Fitness",
|
||||
"name": "SDS011"
|
||||
},
|
||||
"pin": "1",
|
||||
"id": 28842
|
||||
}
|
||||
},
|
||||
{
|
||||
"timestamp": "2020-06-11 09:38:16",
|
||||
"sensordatavalues": [
|
||||
{
|
||||
"value": "2.20",
|
||||
"id": 1629900061,
|
||||
"value_type": "P1"
|
||||
},
|
||||
{
|
||||
"value": "2.00",
|
||||
"id": 1629900063,
|
||||
"value_type": "P2"
|
||||
}
|
||||
],
|
||||
"sampling_rate": null,
|
||||
"location": {
|
||||
"exact_location": 1,
|
||||
"latitude": "50.55591005174",
|
||||
"country": "DE",
|
||||
"altitude": "151.2",
|
||||
"indoor": 0,
|
||||
"longitude": "8.49543571448",
|
||||
"id": 15975
|
||||
},
|
||||
"id": 757203291,
|
||||
"sensor": {
|
||||
"sensor_type": {
|
||||
"id": 14,
|
||||
"manufacturer": "Nova Fitness",
|
||||
"name": "SDS011"
|
||||
},
|
||||
"pin": "1",
|
||||
"id": 28842
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user