Fix Java and Jetty deprecations (#10349)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
580f293766
commit
fe0c35d22f
bundles
org.openhab.binding.autelis/src/main/java/org/openhab/binding/autelis/internal
org.openhab.binding.bticinosmarther/src/main/java/org/openhab/binding/bticinosmarther/internal/account
org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal
org.openhab.binding.coolmasternet/src/main/java/org/openhab/binding/coolmasternet/internal/handler
org.openhab.binding.daikin/src/main/java/org/openhab/binding/daikin/internal
org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/handler
org.openhab.binding.dmx/src/main/java/org/openhab/binding/dmx/internal/multiverse
org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal
org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/handler
org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal
org.openhab.binding.ihc/src/main/java/org/openhab/binding/ihc/internal
org.openhab.binding.innogysmarthome/src/main/java/org/openhab/binding/innogysmarthome/internal
org.openhab.binding.ism8/src/main/java/org/openhab/binding/ism8/server
org.openhab.binding.knx/src/main/java/org/openhab/binding/knx/internal/dpt
org.openhab.binding.lifx/src/main/java/org/openhab/binding/lifx/internal/handler
org.openhab.binding.nest/src/main/java/org/openhab/binding/nest/internal/handler
org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal
org.openhab.binding.paradoxalarm/src/test/java/main
org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/messages
org.openhab.binding.robonect/src
main/java/org/openhab/binding/robonect/internal
test/java/org/openhab/binding/robonect/internal/model
org.openhab.binding.seneye/src/main/java/org/openhab/binding/seneye/internal
org.openhab.binding.squeezebox/src/main/java/org/openhab/binding/squeezebox/internal/discovery
org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model
org.openhab.binding.tacmi/src/main/java/org/openhab/binding/tacmi/internal/schema
org.openhab.binding.tado/src/main/java/org/openhab/binding/tado/internal
org.openhab.binding.telegram/src/main/java/org/openhab/binding/telegram/internal/action
org.openhab.binding.tellstick/src/main/java/org/openhab/binding/tellstick/internal
core
live
local
org.openhab.binding.tibber/src/main/java/org/openhab/binding/tibber/internal/handler
org.openhab.binding.tradfri/src/test/java/org/openhab/binding/tradfri/internal/model
org.openhab.binding.unifi/src/main/java/org/openhab/binding/unifi/internal
org.openhab.binding.venstarthermostat/src/main/java/org/openhab/binding/venstarthermostat/internal/handler
org.openhab.binding.wifiled/src/main/java/org/openhab/binding/wifiled/internal/handler
org.openhab.binding.zway/src/main/java/org/openhab/binding/zway/internal/handler
org.openhab.io.imperihome/src/main/java/org/openhab/io/imperihome/internal/model/device
itests/org.openhab.binding.astro.tests/src/main/java/org/openhab/binding/astro/handler/test
@ -65,7 +65,7 @@ public class AutelisDiscoveryParticipant implements UpnpDiscoveryParticipant {
|
||||
properties.put("host", url.getHost());
|
||||
properties.put("user", "admin");
|
||||
properties.put("password", "admin");
|
||||
properties.put("port", new Integer(port));
|
||||
properties.put("port", Integer.valueOf(port));
|
||||
|
||||
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties).withLabel(label)
|
||||
.build();
|
||||
|
@ -13,6 +13,8 @@
|
||||
package org.openhab.binding.autelis.internal.handler;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -30,8 +32,6 @@ import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.openhab.binding.autelis.internal.AutelisBindingConstants;
|
||||
import org.openhab.binding.autelis.internal.config.AutelisConfiguration;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
@ -313,7 +313,8 @@ public class AutelisHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
baseURL = "http://" + host + ":" + port;
|
||||
basicAuthentication = "Basic " + B64Code.encode(username + ":" + password, StringUtil.__ISO_8859_1);
|
||||
basicAuthentication = "Basic "
|
||||
+ Base64.getEncoder().encodeToString((username + ":" + password).getBytes(StandardCharsets.ISO_8859_1));
|
||||
logger.debug("Autelius binding configured with base url {} and refresh period of {}", baseURL, refresh);
|
||||
|
||||
initPolling(0);
|
||||
|
@ -22,13 +22,13 @@ import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.util.ConcurrentHashSet;
|
||||
import org.openhab.binding.bticinosmarther.internal.api.dto.Notification;
|
||||
import org.openhab.binding.bticinosmarther.internal.api.dto.Sender;
|
||||
import org.openhab.binding.bticinosmarther.internal.api.exception.SmartherGatewayException;
|
||||
@ -61,7 +61,7 @@ public class SmartherAccountService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SmartherAccountService.class);
|
||||
|
||||
private final Set<SmartherAccountHandler> handlers = new ConcurrentHashSet<>();
|
||||
private final Set<SmartherAccountHandler> handlers = ConcurrentHashMap.newKeySet();
|
||||
|
||||
private @Nullable HttpService httpService;
|
||||
private @Nullable BundleContext bundleContext;
|
||||
|
2
bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/X10Interface.java
2
bundles/org.openhab.binding.cm11a/src/main/java/org/openhab/binding/cm11a/internal/X10Interface.java
@ -357,7 +357,7 @@ public class X10Interface extends Thread implements SerialPortEventListener {
|
||||
*/
|
||||
public static boolean validateAddress(String address) {
|
||||
return (!(address.length() < 2 || address.length() > 3
|
||||
|| !HOUSE_CODES.containsKey(new Character(address.charAt(0)))
|
||||
|| !HOUSE_CODES.containsKey(Character.valueOf(address.charAt(0)))
|
||||
|| !DEVICE_CODES.containsKey(Integer.parseInt(address.substring(1)))));
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class HVACHandler extends BaseThingHandler {
|
||||
if (command instanceof RefreshType) {
|
||||
final String currentTemp = query(controller, "a");
|
||||
if (currentTemp != null) {
|
||||
final Integer temp = new Integer(currentTemp);
|
||||
final Integer temp = Integer.parseInt(currentTemp);
|
||||
final QuantityType<?> value = new QuantityType<>(temp, controller.getUnit());
|
||||
updateState(CURRENT_TEMP, value);
|
||||
}
|
||||
@ -157,7 +157,7 @@ public class HVACHandler extends BaseThingHandler {
|
||||
if (command instanceof RefreshType) {
|
||||
final String setTemp = query(controller, "t");
|
||||
if (setTemp != null) {
|
||||
final Integer temp = new Integer(setTemp);
|
||||
final Integer temp = Integer.parseInt(setTemp);
|
||||
final QuantityType<?> value = new QuantityType<>(temp, controller.getUnit());
|
||||
updateState(SET_TEMP, value);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class DaikinHttpClientFactoryImpl implements DaikinHttpClientFactory {
|
||||
|
||||
private synchronized void initialize() {
|
||||
if (httpClient == null) {
|
||||
httpClient = new HttpClient(new SslContextFactory(true));
|
||||
httpClient = new HttpClient(new SslContextFactory.Client(true));
|
||||
try {
|
||||
httpClient.start();
|
||||
logger.debug("Daikin http client started");
|
||||
|
@ -15,6 +15,7 @@ package org.openhab.binding.digitalstrom.internal.handler;
|
||||
import static org.openhab.binding.digitalstrom.internal.DigitalSTROMBindingConstants.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -410,7 +411,7 @@ public class DeviceHandler extends BaseThingHandler implements DeviceStatusListe
|
||||
if (value <= 0 || max <= 0) {
|
||||
return 0;
|
||||
}
|
||||
int percentValue = new BigDecimal(value * ((float) 100 / max)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
int percentValue = new BigDecimal(value * ((float) 100 / max)).setScale(0, RoundingMode.HALF_UP).intValue();
|
||||
return percentValue < 0 ? 0 : percentValue > 100 ? 100 : percentValue;
|
||||
}
|
||||
|
||||
|
@ -95,9 +95,10 @@ public class BaseDmxChannel implements Comparable<BaseDmxChannel> {
|
||||
if (otherDmxChannel == null) {
|
||||
return -1;
|
||||
}
|
||||
int universeCompare = new Integer(getUniverseId()).compareTo(new Integer(otherDmxChannel.getUniverseId()));
|
||||
int universeCompare = Integer.valueOf(getUniverseId())
|
||||
.compareTo(Integer.valueOf(otherDmxChannel.getUniverseId()));
|
||||
if (universeCompare == 0) {
|
||||
return new Integer(getChannelId()).compareTo(new Integer(otherDmxChannel.getChannelId()));
|
||||
return Integer.valueOf(getChannelId()).compareTo(Integer.valueOf(otherDmxChannel.getChannelId()));
|
||||
} else {
|
||||
return universeCompare;
|
||||
}
|
||||
|
3
bundles/org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal/Commands.java
3
bundles/org.openhab.binding.feican/src/main/java/org/openhab/binding/feican/internal/Commands.java
@ -13,6 +13,7 @@
|
||||
package org.openhab.binding.feican.internal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.core.library.types.HSBType;
|
||||
@ -82,7 +83,7 @@ public class Commands {
|
||||
*/
|
||||
private byte convertColorPercentToByte(PercentType percent) {
|
||||
return percent.toBigDecimal().multiply(BigDecimal.valueOf(255))
|
||||
.divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).byteValue();
|
||||
.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).byteValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@ import static org.openhab.binding.gree.internal.GreeBindingConstants.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.DatagramSocket;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
@ -567,7 +568,7 @@ public class GreeHandler extends BaseThingHandler {
|
||||
|
||||
public static QuantityType<?> toQuantityType(Number value, int digits, Unit<?> unit) {
|
||||
BigDecimal bd = new BigDecimal(value.doubleValue());
|
||||
return new QuantityType<>(bd.setScale(digits, BigDecimal.ROUND_HALF_EVEN), unit);
|
||||
return new QuantityType<>(bd.setScale(digits, RoundingMode.HALF_EVEN), unit);
|
||||
}
|
||||
|
||||
private void stopRefreshTask() {
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.http.internal;
|
||||
|
||||
import static org.openhab.binding.http.internal.HttpBindingConstants.*;
|
||||
import static org.openhab.binding.http.internal.HttpBindingConstants.THING_TYPE_URL;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ -59,8 +59,8 @@ public class HttpHandlerFactory extends BaseThingHandlerFactory
|
||||
@Activate
|
||||
public HttpHandlerFactory(@Reference HttpClientFactory httpClientFactory,
|
||||
@Reference HttpDynamicStateDescriptionProvider httpDynamicStateDescriptionProvider) {
|
||||
this.secureClient = new HttpClient(new SslContextFactory());
|
||||
this.insecureClient = new HttpClient(new SslContextFactory(true));
|
||||
this.secureClient = new HttpClient(new SslContextFactory.Client());
|
||||
this.insecureClient = new HttpClient(new SslContextFactory.Client(true));
|
||||
try {
|
||||
this.secureClient.start();
|
||||
this.insecureClient.start();
|
||||
|
@ -202,7 +202,7 @@ public class ChannelUtils {
|
||||
ChannelUID channelUID = new ChannelUID(thing.getUID(), group + resourceId);
|
||||
ChannelTypeUID type = new ChannelTypeUID(BINDING_ID, channelType);
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.put(PARAM_RESOURCE_ID, new Integer(resourceId));
|
||||
configuration.put(PARAM_RESOURCE_ID, Integer.valueOf(resourceId));
|
||||
|
||||
Channel channel = ChannelBuilder.create(channelUID, acceptedItemType).withConfiguration(configuration)
|
||||
.withLabel(description).withType(type).build();
|
||||
|
@ -149,7 +149,7 @@ public class InnogyWebSocket {
|
||||
}
|
||||
|
||||
WebSocketClient startWebSocketClient() throws Exception {
|
||||
WebSocketClient client = new WebSocketClient(new SslContextFactory());
|
||||
WebSocketClient client = new WebSocketClient(new SslContextFactory.Client());
|
||||
client.setMaxIdleTimeout(this.maxIdleTimeout);
|
||||
client.start();
|
||||
return client;
|
||||
|
@ -85,6 +85,7 @@ public class Server extends Thread {
|
||||
* Starts the server
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
this.startRetries = 0;
|
||||
while (!this.isInterrupted()) {
|
||||
@ -132,7 +133,7 @@ public class Server extends Thread {
|
||||
|
||||
IDataPoint dp = DataPointFactory.createDataPoint(id, knxType, description);
|
||||
if (dp != null) {
|
||||
this.dataPoints.put(new Integer(id), dp);
|
||||
this.dataPoints.put(Integer.valueOf(id), dp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
package org.openhab.binding.knx.internal.dpt;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
@ -1017,6 +1018,6 @@ public class KNXCoreTypeMapper implements KNXTypeMapper {
|
||||
*/
|
||||
private int convertPercentToByte(PercentType percent) {
|
||||
return percent.toBigDecimal().multiply(BigDecimal.valueOf(255))
|
||||
.divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).intValue();
|
||||
}
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ public class LifxLightHandler extends BaseThingHandler {
|
||||
|
||||
Configuration configuration = channel.getConfiguration();
|
||||
Object speed = configuration.get(parameter);
|
||||
return speed == null ? null : new Double(speed.toString());
|
||||
return speed == null ? null : Double.valueOf(speed.toString());
|
||||
}
|
||||
|
||||
private LifxProduct getProduct() {
|
||||
@ -414,7 +414,7 @@ public class LifxLightHandler extends BaseThingHandler {
|
||||
// Without first conversion to double, on a very first thing creation from discovery inbox,
|
||||
// the product type is incorrectly parsed, as framework passed it as a floating point number
|
||||
// (e.g. 50.0 instead of 50)
|
||||
Double d = Double.parseDouble((String) propertyValue);
|
||||
Double d = Double.valueOf((String) propertyValue);
|
||||
long productID = d.longValue();
|
||||
return LifxProduct.getProductFromProductID(productID);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -71,7 +71,7 @@ public class NestRedirectUrlSupplier {
|
||||
* @see https://developers.nest.com/documentation/cloud/how-to-handle-redirects
|
||||
*/
|
||||
private String resolveRedirectUrl() throws FailedResolvingNestUrlException {
|
||||
HttpClient httpClient = new HttpClient(new SslContextFactory());
|
||||
HttpClient httpClient = new HttpClient(new SslContextFactory.Client());
|
||||
httpClient.setFollowRedirects(false);
|
||||
|
||||
Request request = httpClient.newRequest(NestBindingConstants.NEST_URL).method(HttpMethod.GET).timeout(30,
|
||||
|
@ -13,6 +13,7 @@
|
||||
package org.openhab.binding.netatmo.internal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
@ -83,7 +84,7 @@ public class ChannelTypeUtils {
|
||||
}
|
||||
|
||||
public static State toDecimalType(@Nullable BigDecimal decimal) {
|
||||
return decimal == null ? UnDefType.NULL : new DecimalType(decimal.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
return decimal == null ? UnDefType.NULL : new DecimalType(decimal.setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
public static State toDecimalType(@Nullable String textualDecimal) {
|
||||
|
@ -100,7 +100,7 @@ public class Main {
|
||||
ipAddress = parser.getIpAddress();
|
||||
logger.info("IP150 IP Address: {}", ipAddress);
|
||||
|
||||
port = new Integer(parser.getPort());
|
||||
port = Integer.parseInt(parser.getPort());
|
||||
logger.info("IP150 port: {}", port);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.Pac
|
||||
import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting2Message.Commands.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
|
||||
import org.openhab.binding.rfxcom.internal.exceptions.RFXComUnsupportedChannelException;
|
||||
@ -155,7 +156,7 @@ public class RFXComLighting2Message extends RFXComDeviceMessageImpl<RFXComLighti
|
||||
*/
|
||||
public static int getDimLevelFromPercentType(PercentType pt) {
|
||||
return pt.toBigDecimal().multiply(BigDecimal.valueOf(15))
|
||||
.divide(PercentType.HUNDRED.toBigDecimal(), 0, BigDecimal.ROUND_UP).intValue();
|
||||
.divide(PercentType.HUNDRED.toBigDecimal(), 0, RoundingMode.UP).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +169,7 @@ public class RFXComLighting2Message extends RFXComDeviceMessageImpl<RFXComLighti
|
||||
value = Math.min(value, 15);
|
||||
|
||||
return new PercentType(BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(100))
|
||||
.divide(BigDecimal.valueOf(15), 0, BigDecimal.ROUND_UP).intValue());
|
||||
.divide(BigDecimal.valueOf(15), 0, RoundingMode.UP).intValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@ import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte
|
||||
import static org.openhab.binding.rfxcom.internal.messages.RFXComLighting5Message.SubType.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -216,7 +217,7 @@ public class RFXComLighting5Message extends RFXComDeviceMessageImpl<RFXComLighti
|
||||
*/
|
||||
public static int getDimLevelFromPercentType(PercentType pt) {
|
||||
return pt.toBigDecimal().multiply(BigDecimal.valueOf(31))
|
||||
.divide(PercentType.HUNDRED.toBigDecimal(), 0, BigDecimal.ROUND_UP).intValue();
|
||||
.divide(PercentType.HUNDRED.toBigDecimal(), 0, RoundingMode.UP).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -229,7 +230,7 @@ public class RFXComLighting5Message extends RFXComDeviceMessageImpl<RFXComLighti
|
||||
value = Math.min(value, 31);
|
||||
|
||||
return new PercentType(BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(100))
|
||||
.divide(BigDecimal.valueOf(31), 0, BigDecimal.ROUND_UP).intValue());
|
||||
.divide(BigDecimal.valueOf(31), 0, RoundingMode.UP).intValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,8 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.rfxcom.internal.messages;
|
||||
|
||||
import static java.math.BigDecimal.*;
|
||||
import static java.math.RoundingMode.HALF_DOWN;
|
||||
import static java.math.RoundingMode.*;
|
||||
import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
|
||||
import static org.openhab.binding.rfxcom.internal.messages.ByteEnumUtil.fromByte;
|
||||
|
||||
@ -257,12 +256,12 @@ public class RFXComRFXSensorMessage extends RFXComDeviceMessageImpl<RFXComRFXSen
|
||||
BigDecimal supplyVoltage = ((DecimalType) referenceVoltageState).toBigDecimal();
|
||||
|
||||
// RH = (((A/D voltage / supply voltage) - 0.16) / 0.0062) / (1.0546 - 0.00216 * temperature)
|
||||
BigDecimal belowTheDivider = adVoltage.divide(supplyVoltage, 4, ROUND_HALF_DOWN)
|
||||
.subtract(HUMIDITY_VOLTAGE_SUBTRACTION).divide(HUMIDITY_VOLTAGE_DIVIDER, 4, ROUND_HALF_DOWN);
|
||||
BigDecimal belowTheDivider = adVoltage.divide(supplyVoltage, 4, HALF_DOWN)
|
||||
.subtract(HUMIDITY_VOLTAGE_SUBTRACTION).divide(HUMIDITY_VOLTAGE_DIVIDER, 4, HALF_DOWN);
|
||||
BigDecimal underTheDivider = HUMIDITY_TEMPERATURE_CORRECTION
|
||||
.subtract(HUMIDITY_TEMPERATURE_MULTIPLIER.multiply(temperature));
|
||||
|
||||
return new DecimalType(belowTheDivider.divide(underTheDivider, 4, ROUND_HALF_DOWN));
|
||||
return new DecimalType(belowTheDivider.divide(underTheDivider, 4, HALF_DOWN));
|
||||
}
|
||||
|
||||
private State handlePressure(DeviceState deviceState) {
|
||||
@ -277,14 +276,14 @@ public class RFXComRFXSensorMessage extends RFXComDeviceMessageImpl<RFXComRFXSen
|
||||
|
||||
// hPa = ((A/D voltage / supply voltage) + 0.095) / 0.0009
|
||||
return new DecimalType((adVoltage.divide(supplyVoltage, 4, HALF_DOWN).add(PRESSURE_ADDITION))
|
||||
.divide(PRESSURE_DIVIDER, 4, ROUND_HALF_DOWN));
|
||||
.divide(PRESSURE_DIVIDER, 4, HALF_DOWN));
|
||||
}
|
||||
|
||||
private BigDecimal getVoltage() {
|
||||
if (miliVoltageTimesTen == null) {
|
||||
return null;
|
||||
}
|
||||
return miliVoltageTimesTen.divide(ONE_HUNDRED, 100, ROUND_CEILING);
|
||||
return miliVoltageTimesTen.divide(ONE_HUNDRED, 100, CEILING);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,6 +14,7 @@ package org.openhab.binding.robonect.internal;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
@ -25,7 +26,6 @@ import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.openhab.binding.robonect.internal.model.ErrorList;
|
||||
import org.openhab.binding.robonect.internal.model.ModelParser;
|
||||
import org.openhab.binding.robonect.internal.model.MowerInfo;
|
||||
@ -177,8 +177,9 @@ public class RobonectClient {
|
||||
private void addPreemptiveAuthentication(HttpClient httpClient, RobonectEndpoint endpoint) {
|
||||
AuthenticationStore auth = httpClient.getAuthenticationStore();
|
||||
URI uri = URI.create(baseUrl);
|
||||
auth.addAuthenticationResult(new BasicResult(HttpHeader.AUTHORIZATION, uri, "Basic "
|
||||
+ B64Code.encode(endpoint.getUser() + ":" + endpoint.getPassword(), StandardCharsets.ISO_8859_1)));
|
||||
auth.addAuthenticationResult(
|
||||
new BasicResult(HttpHeader.AUTHORIZATION, uri, "Basic " + Base64.getEncoder().encodeToString(
|
||||
(endpoint.getUser() + ":" + endpoint.getPassword()).getBytes(StandardCharsets.ISO_8859_1))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
|
||||
/**
|
||||
* The goal of this class is to test the model parser to make sure the structures
|
||||
* returned from the module can be handled.
|
||||
*
|
||||
*
|
||||
* @author Marco Meyer - Initial contribution
|
||||
*/
|
||||
public class ModelParserTest {
|
||||
@ -48,12 +48,12 @@ public class ModelParserTest {
|
||||
String correctModel = "{\"successful\": false, \"error_code\": 7, \"error_message\": \"Automower already stopped\"}";
|
||||
RobonectAnswer answer = subject.parse(correctModel, RobonectAnswer.class);
|
||||
assertFalse(answer.isSuccessful());
|
||||
assertEquals(new Integer(7), answer.getErrorCode());
|
||||
assertEquals(Integer.valueOf(7), answer.getErrorCode());
|
||||
assertEquals("Automower already stopped", answer.getErrorMessage());
|
||||
|
||||
MowerInfo info = subject.parse(correctModel, MowerInfo.class);
|
||||
assertFalse(info.isSuccessful());
|
||||
assertEquals(new Integer(7), info.getErrorCode());
|
||||
assertEquals(Integer.valueOf(7), info.getErrorCode());
|
||||
assertEquals("Automower already stopped", info.getErrorMessage());
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ public class ModelParserTest {
|
||||
assertTrue(mowerInfo.getStatus().isStopped());
|
||||
assertNotNull(mowerInfo.getError());
|
||||
assertEquals("Mein Automower ist angehoben", mowerInfo.getError().getErrorMessage());
|
||||
assertEquals(new Integer(15), mowerInfo.getError().getErrorCode());
|
||||
assertEquals(Integer.valueOf(15), mowerInfo.getError().getErrorCode());
|
||||
assertEquals("02.05.2017", mowerInfo.getError().getDate());
|
||||
assertEquals("20:36:43", mowerInfo.getError().getTime());
|
||||
assertEquals("1493757403", mowerInfo.getError().getUnix());
|
||||
@ -155,7 +155,7 @@ public class ModelParserTest {
|
||||
ErrorList errorList = subject.parse(errorsListResponse, ErrorList.class);
|
||||
assertTrue(errorList.isSuccessful());
|
||||
assertEquals(10, errorList.getErrors().size());
|
||||
assertEquals(new Integer(15), errorList.getErrors().get(0).getErrorCode());
|
||||
assertEquals(Integer.valueOf(15), errorList.getErrors().get(0).getErrorCode());
|
||||
assertEquals("Grasi ist angehoben", errorList.getErrors().get(0).getErrorMessage());
|
||||
assertEquals("02.05.2017", errorList.getErrors().get(0).getDate());
|
||||
assertEquals("20:36:43", errorList.getErrors().get(0).getTime());
|
||||
|
@ -43,7 +43,7 @@ public class SeneyeService {
|
||||
public int seneyeType;
|
||||
private boolean isInitialized;
|
||||
private final Gson gson;
|
||||
private HttpClient httpClient = new HttpClient(new SslContextFactory());
|
||||
private HttpClient httpClient = new HttpClient(new SslContextFactory.Client());
|
||||
private ScheduledFuture<?> scheduledJob;
|
||||
|
||||
public SeneyeService(SeneyeConfigurationParameters config) throws CommunicationException {
|
||||
|
@ -84,8 +84,8 @@ public class SqueezeBoxServerDiscoveryParticipant implements UpnpDiscoveryPartic
|
||||
|
||||
String representationPropertyName = "ipAddress";
|
||||
properties.put(representationPropertyName, host);
|
||||
properties.put("webport", new Integer(webPort));
|
||||
properties.put("cliPort", new Integer(cliPort));
|
||||
properties.put("webport", Integer.valueOf(webPort));
|
||||
properties.put("cliPort", Integer.valueOf(cliPort));
|
||||
|
||||
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
|
||||
.withRepresentationProperty(representationPropertyName).withLabel(label).build();
|
||||
|
@ -13,6 +13,7 @@
|
||||
package org.openhab.binding.systeminfo.internal.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@ -316,14 +317,14 @@ public class OSHISysteminfo implements SysteminfoInterface {
|
||||
@Override
|
||||
public @Nullable DecimalType getSensorsCpuTemperature() {
|
||||
BigDecimal cpuTemp = new BigDecimal(sensors.getCpuTemperature());
|
||||
cpuTemp = cpuTemp.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_HALF_UP);
|
||||
cpuTemp = cpuTemp.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
|
||||
return cpuTemp.signum() == 1 ? new DecimalType(cpuTemp) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable DecimalType getSensorsCpuVoltage() {
|
||||
BigDecimal cpuVoltage = new BigDecimal(sensors.getCpuVoltage());
|
||||
cpuVoltage = cpuVoltage.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_HALF_UP);
|
||||
cpuVoltage = cpuVoltage.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
|
||||
return cpuVoltage.signum() == 1 ? new DecimalType(cpuVoltage) : null;
|
||||
}
|
||||
|
||||
@ -464,13 +465,13 @@ public class OSHISysteminfo implements SysteminfoInterface {
|
||||
|
||||
private BigDecimal getPercentsValue(double decimalFraction) {
|
||||
BigDecimal result = new BigDecimal(decimalFraction * 100);
|
||||
result = result.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_HALF_UP);
|
||||
result = result.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
|
||||
return result;
|
||||
}
|
||||
|
||||
private BigDecimal getTimeInMinutes(double timeInSeconds) {
|
||||
BigDecimal timeInMinutes = new BigDecimal(timeInSeconds / 60);
|
||||
timeInMinutes = timeInMinutes.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_UP);
|
||||
timeInMinutes = timeInMinutes.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.UP);
|
||||
return timeInMinutes;
|
||||
}
|
||||
|
||||
@ -525,7 +526,7 @@ public class OSHISysteminfo implements SysteminfoInterface {
|
||||
}
|
||||
double processorLoads[] = cpu.getSystemLoadAverage(index + 1);
|
||||
BigDecimal result = new BigDecimal(processorLoads[index]);
|
||||
result = result.setScale(PRECISION_AFTER_DECIMAL_SIGN, BigDecimal.ROUND_HALF_UP);
|
||||
result = result.setScale(PRECISION_AFTER_DECIMAL_SIGN, RoundingMode.HALF_UP);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ package org.openhab.binding.tacmi.internal.schema;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -36,7 +37,6 @@ import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.openhab.binding.tacmi.internal.TACmiChannelTypeProvider;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.library.types.StringType;
|
||||
@ -109,8 +109,8 @@ public class TACmiSchemaHandler extends BaseThingHandler {
|
||||
this.online = false;
|
||||
updateStatus(ThingStatus.UNKNOWN);
|
||||
|
||||
this.authHeader = "Basic "
|
||||
+ B64Code.encode(config.username + ":" + config.password, StandardCharsets.ISO_8859_1);
|
||||
this.authHeader = "Basic " + Base64.getEncoder()
|
||||
.encodeToString((config.username + ":" + config.password).getBytes(StandardCharsets.ISO_8859_1));
|
||||
|
||||
final String serverBase = "http://" + config.host + "/";
|
||||
this.serverBase = serverBase;
|
||||
|
@ -13,6 +13,7 @@
|
||||
package org.openhab.binding.tado.internal.adapter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
import org.openhab.binding.tado.internal.TadoBindingConstants.HvacMode;
|
||||
@ -48,7 +49,7 @@ import org.openhab.core.types.UnDefType;
|
||||
*
|
||||
* @author Dennis Frommknecht - Initial contribution
|
||||
* @author Andrew Fiddian-Green - Added Low Battery Alarm, A/C Power and Open Window channels
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TadoZoneStateAdapter {
|
||||
private ZoneState zoneState;
|
||||
@ -199,7 +200,7 @@ public class TadoZoneStateAdapter {
|
||||
}
|
||||
|
||||
private static DecimalType toDecimalType(double value) {
|
||||
BigDecimal decimal = new BigDecimal(value).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal decimal = new BigDecimal(value).setScale(2, RoundingMode.HALF_UP);
|
||||
return new DecimalType(decimal);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public abstract class BaseHomeThingHandler extends BaseThingHandler {
|
||||
|
||||
public Long getHomeId() {
|
||||
TadoHomeHandler handler = getHomeHandler();
|
||||
return handler != null ? handler.getHomeId() : new Long(0);
|
||||
return handler != null ? handler.getHomeId() : Long.valueOf(0);
|
||||
}
|
||||
|
||||
protected TadoHomeHandler getHomeHandler() {
|
||||
|
@ -36,7 +36,6 @@ import org.eclipse.jetty.client.api.Request;
|
||||
import org.eclipse.jetty.client.util.FutureResponseListener;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.util.B64Code;
|
||||
import org.openhab.binding.telegram.internal.TelegramHandler;
|
||||
import org.openhab.core.automation.annotation.ActionInput;
|
||||
import org.openhab.core.automation.annotation.RuleAction;
|
||||
@ -314,7 +313,8 @@ public class TelegramActions implements ThingActions {
|
||||
AuthenticationStore auth = client.getAuthenticationStore();
|
||||
URI uri = URI.create(photoURL);
|
||||
auth.addAuthenticationResult(new BasicResult(HttpHeader.AUTHORIZATION, uri,
|
||||
"Basic " + B64Code.encode(username + ":" + password, StandardCharsets.ISO_8859_1)));
|
||||
"Basic " + Base64.getEncoder().encodeToString(
|
||||
(username + ":" + password).getBytes(StandardCharsets.ISO_8859_1))));
|
||||
}
|
||||
try {
|
||||
// API has 10mb limit to jpg file size, without this it can only accept 2mb
|
||||
|
@ -13,6 +13,7 @@
|
||||
package org.openhab.binding.tellstick.internal.core;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Collections;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
@ -119,7 +120,7 @@ public class TelldusCoreDeviceController implements DeviceChangeListener, Sensor
|
||||
case JNA.CLibrary.TELLSTICK_DIM:
|
||||
dimValue = new BigDecimal(((TellstickDevice) device).getData());
|
||||
dimValue = dimValue.multiply(new BigDecimal(100));
|
||||
dimValue = dimValue.divide(new BigDecimal(255), 0, BigDecimal.ROUND_HALF_UP);
|
||||
dimValue = dimValue.divide(new BigDecimal(255), 0, RoundingMode.HALF_UP);
|
||||
break;
|
||||
default:
|
||||
logger.warn("Could not handle {} for {}", ((TellstickDevice) device).getStatus(), device);
|
||||
|
@ -13,6 +13,7 @@
|
||||
package org.openhab.binding.tellstick.internal.live;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -248,7 +249,7 @@ public class TelldusLiveDeviceController implements DeviceChangeListener, Sensor
|
||||
case JNA.CLibrary.TELLSTICK_DIM:
|
||||
dimValue = new BigDecimal(((TellstickNetDevice) device).getStatevalue());
|
||||
dimValue = dimValue.multiply(new BigDecimal(100));
|
||||
dimValue = dimValue.divide(new BigDecimal(255), 0, BigDecimal.ROUND_HALF_UP);
|
||||
dimValue = dimValue.divide(new BigDecimal(255), 0, RoundingMode.HALF_UP);
|
||||
break;
|
||||
default:
|
||||
logger.warn("Could not handle {} for {}", (((TellstickNetDevice) device).getState()), device);
|
||||
|
@ -13,6 +13,7 @@
|
||||
package org.openhab.binding.tellstick.internal.local;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@ -221,7 +222,7 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
|
||||
case JNA.CLibrary.TELLSTICK_DIM:
|
||||
dimValue = new BigDecimal(((TellstickLocalDeviceDTO) device).getStatevalue());
|
||||
dimValue = dimValue.multiply(new BigDecimal(100));
|
||||
dimValue = dimValue.divide(new BigDecimal(255), 0, BigDecimal.ROUND_HALF_UP);
|
||||
dimValue = dimValue.divide(new BigDecimal(255), 0, RoundingMode.HALF_UP);
|
||||
break;
|
||||
default:
|
||||
logger.warn("Could not handle {} for {}", (((TellstickLocalDeviceDTO) device).getState()), device);
|
||||
|
@ -69,7 +69,7 @@ public class TibberHandler extends BaseThingHandler {
|
||||
private static final int REQUEST_TIMEOUT = (int) TimeUnit.SECONDS.toMillis(20);
|
||||
private final Logger logger = LoggerFactory.getLogger(TibberHandler.class);
|
||||
private final Properties httpHeader = new Properties();
|
||||
private final SslContextFactory sslContextFactory = new SslContextFactory(true);
|
||||
private final SslContextFactory sslContextFactory = new SslContextFactory.Client(true);
|
||||
private final Executor websocketExecutor = ThreadPoolManager.getPool("tibber.websocket");
|
||||
private TibberConfiguration tibberConfig = new TibberConfiguration();
|
||||
private @Nullable TibberWebSocketListener socket;
|
||||
|
@ -72,7 +72,7 @@ public class TradfriVersionTest {
|
||||
assertTrue(VERSION.equals(new TradfriVersion(VERSION_STRING)));
|
||||
|
||||
assertFalse(VERSION.equals((TradfriVersion) null));
|
||||
assertFalse(VERSION.equals(new Integer("1")));
|
||||
assertFalse(VERSION.equals(Integer.valueOf("1")));
|
||||
assertFalse(VERSION.equals(new TradfriVersion("1.2.5")));
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class UniFiThingHandlerFactory extends BaseThingHandlerFactory {
|
||||
public UniFiThingHandlerFactory(@Reference final HttpClientFactory httpClientFactory) {
|
||||
// [wip] mgb: disabled due to missing common name attributes with certs
|
||||
// this.httpClient = httpClientFactory.getCommonHttpClient();
|
||||
httpClient = new HttpClient(new SslContextFactory(true));
|
||||
httpClient = new HttpClient(new SslContextFactory.Client(true));
|
||||
try {
|
||||
httpClient.start();
|
||||
} catch (Exception e) {
|
||||
|
@ -106,7 +106,7 @@ public class VenstarThermostatHandler extends ConfigStatusThingHandler {
|
||||
|
||||
public VenstarThermostatHandler(Thing thing) {
|
||||
super(thing);
|
||||
httpClient = new HttpClient(new SslContextFactory(true));
|
||||
httpClient = new HttpClient(new SslContextFactory.Client(true));
|
||||
gson = new GsonBuilder().registerTypeAdapter(VenstarSystemState.class, new VenstarSystemStateSerializer())
|
||||
.registerTypeAdapter(VenstarSystemMode.class, new VenstarSystemModeSerializer()).create();
|
||||
|
||||
|
@ -16,6 +16,7 @@ import static java.lang.Math.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
import org.openhab.core.library.types.HSBType;
|
||||
@ -92,13 +93,13 @@ public class LEDStateDTO {
|
||||
PercentType b = new PercentType(new BigDecimal(hsv[2]).multiply(new BigDecimal(100.0)));
|
||||
HSBType hsbType = new HSBType(h, s, b);
|
||||
|
||||
PercentType w = new PercentType(new BigDecimal(white).divide(new BigDecimal(255.0), 3, BigDecimal.ROUND_HALF_UP)
|
||||
PercentType w = new PercentType(new BigDecimal(white).divide(new BigDecimal(255.0), 3, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal(100.0)));
|
||||
PercentType w2 = new PercentType(new BigDecimal(white2).divide(new BigDecimal(255.0), 3, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal(100.0)));
|
||||
PercentType w2 = new PercentType(new BigDecimal(white2)
|
||||
.divide(new BigDecimal(255.0), 3, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100.0)));
|
||||
|
||||
// Range: 0x00 .. 0x1F. Speed is inversed
|
||||
BigDecimal ps = new BigDecimal(programSpeed).divide(new BigDecimal(0x1f), 2, BigDecimal.ROUND_HALF_UP)
|
||||
BigDecimal ps = new BigDecimal(programSpeed).divide(new BigDecimal(0x1f), 2, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal(100.0));
|
||||
PercentType e = new PercentType(new BigDecimal(100.0).subtract(ps));
|
||||
|
||||
|
@ -181,7 +181,7 @@ public class ZWayZAutomationDeviceHandler extends ZWayDeviceHandler {
|
||||
}
|
||||
|
||||
Calendar lastUpdateOfDevice = Calendar.getInstance();
|
||||
lastUpdateOfDevice.setTimeInMillis(new Long(device.getUpdateTime()) * 1000);
|
||||
lastUpdateOfDevice.setTimeInMillis(Long.valueOf(device.getUpdateTime()) * 1000);
|
||||
|
||||
if (lastUpdate == null || lastUpdateOfDevice.after(lastUpdate)) {
|
||||
lastUpdate = lastUpdateOfDevice;
|
||||
|
@ -211,7 +211,8 @@ public class ZWayZWaveDeviceHandler extends ZWayDeviceHandler {
|
||||
}
|
||||
|
||||
Calendar lastUpdateOfDevice = Calendar.getInstance();
|
||||
lastUpdateOfDevice.setTimeInMillis(new Long(zwaveDevice.getData().getLastReceived().getUpdateTime()) * 1000);
|
||||
lastUpdateOfDevice
|
||||
.setTimeInMillis(Long.valueOf(zwaveDevice.getData().getLastReceived().getUpdateTime()) * 1000);
|
||||
|
||||
if (lastUpdate == null || lastUpdateOfDevice.after(lastUpdate)) {
|
||||
lastUpdate = lastUpdateOfDevice;
|
||||
|
@ -13,6 +13,7 @@
|
||||
package org.openhab.io.imperihome.internal.model.device;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openhab.core.items.Item;
|
||||
@ -84,6 +85,6 @@ public class RgbLightDevice extends AbstractEnergyLinkDevice {
|
||||
|
||||
private int convertPercentToByte(PercentType percent) {
|
||||
return percent.toBigDecimal().multiply(BigDecimal.valueOf(255))
|
||||
.divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_HALF_UP).intValue();
|
||||
.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).intValue();
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class AstroValidConfigurationTest {
|
||||
public void testIfTheIntervalForASunThingIsLessThan1_theThingStatusBecomesOFFLINE() {
|
||||
Configuration thingConfiguration = new Configuration();
|
||||
thingConfiguration.put(GEOLOCATION_PROPERTY, GEOLOCATION_VALUE);
|
||||
thingConfiguration.put(INTERVAL_PROPERTY, new Integer(0));
|
||||
thingConfiguration.put(INTERVAL_PROPERTY, Integer.valueOf(0));
|
||||
assertThingStatus(thingConfiguration, ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class AstroValidConfigurationTest {
|
||||
public void testIfTheIntervalForAMoonThingIsLessThan1_theThingStatusBecomesOFFLINE() {
|
||||
Configuration thingConfiguration = new Configuration();
|
||||
thingConfiguration.put(GEOLOCATION_PROPERTY, GEOLOCATION_VALUE);
|
||||
thingConfiguration.put(INTERVAL_PROPERTY, new Integer(0));
|
||||
thingConfiguration.put(INTERVAL_PROPERTY, Integer.valueOf(0));
|
||||
assertThingStatus(thingConfiguration, ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ public class AstroValidConfigurationTest {
|
||||
public void testIfTheIntervalForASunThingIsGreaterThan86400_theThingStatusBecomesOFFLINE() {
|
||||
Configuration thingConfiguration = new Configuration();
|
||||
thingConfiguration.put(GEOLOCATION_PROPERTY, GEOLOCATION_VALUE);
|
||||
thingConfiguration.put(INTERVAL_PROPERTY, new Integer(86401));
|
||||
thingConfiguration.put(INTERVAL_PROPERTY, Integer.valueOf(86401));
|
||||
assertThingStatus(thingConfiguration, ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public class AstroValidConfigurationTest {
|
||||
public void testIfTheIntervalForAMoonThingIsGreaterThan86400_theThingStatusBecomesOFFLINE() {
|
||||
Configuration thingConfiguration = new Configuration();
|
||||
thingConfiguration.put(GEOLOCATION_PROPERTY, GEOLOCATION_VALUE);
|
||||
thingConfiguration.put(INTERVAL_PROPERTY, new Integer(86401));
|
||||
thingConfiguration.put(INTERVAL_PROPERTY, Integer.valueOf(86401));
|
||||
assertThingStatus(thingConfiguration, ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user