[infrastructure] add external null-annotations (#8848)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
This commit is contained in:
parent
47d05055db
commit
bd664ff0c8
|
@ -14,6 +14,7 @@ package org.openhab.binding.airquality.internal.json;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
@ -40,8 +41,6 @@ public class AirQualityJsonCity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGeo() {
|
public String getGeo() {
|
||||||
List<String> list = new ArrayList<>();
|
return geo.stream().map(Object::toString).collect(Collectors.joining(", "));
|
||||||
geo.forEach(item -> list.add(item.toString()));
|
|
||||||
return String.join(",", list);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
@ -82,9 +83,8 @@ public class AirQualityJsonData {
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
public String getAttributions() {
|
public String getAttributions() {
|
||||||
List<String> list = new ArrayList<>();
|
String attributionsString = attributions.stream().map(Attribute::getName).collect(Collectors.joining(", "));
|
||||||
attributions.forEach(item -> list.add(item.getName()));
|
return "Attributions : " + attributionsString;
|
||||||
return "Attributions : " + String.join(", ", list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDominentPol() {
|
public String getDominentPol() {
|
||||||
|
|
|
@ -368,7 +368,7 @@ public abstract class ADBridgeHandler extends BaseBridgeHandler {
|
||||||
private static class MessageParseException extends Exception {
|
private static class MessageParseException extends Exception {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public MessageParseException(String msg) {
|
public MessageParseException(@Nullable String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -697,9 +697,10 @@ public class AccountServlet extends HttpServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void returnError(HttpServletResponse resp, String errorMessage) {
|
void returnError(HttpServletResponse resp, @Nullable String errorMessage) {
|
||||||
try {
|
try {
|
||||||
resp.getWriter().write("<html>" + StringEscapeUtils.escapeHtml(errorMessage) + "<br><a href='" + servletUrl
|
String message = errorMessage != null ? errorMessage : "null";
|
||||||
|
resp.getWriter().write("<html>" + StringEscapeUtils.escapeHtml(message) + "<br><a href='" + servletUrl
|
||||||
+ "'>Try again</a></html>");
|
+ "'>Try again</a></html>");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.info("Returning error message failed", e);
|
logger.info("Returning error message failed", e);
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.amazonechocontrol.internal.Connection;
|
import org.openhab.binding.amazonechocontrol.internal.Connection;
|
||||||
import org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler;
|
import org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler;
|
||||||
import org.openhab.binding.amazonechocontrol.internal.handler.SmartHomeDeviceHandler;
|
import org.openhab.binding.amazonechocontrol.internal.handler.SmartHomeDeviceHandler;
|
||||||
|
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeCapabilities;
|
||||||
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.DriverIdentity;
|
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.DriverIdentity;
|
||||||
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.SmartHomeDevice;
|
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.SmartHomeDevice;
|
||||||
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeGroups.SmartHomeGroup;
|
import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeGroups.SmartHomeGroup;
|
||||||
|
@ -171,7 +172,8 @@ public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Stream.of(shd.capabilities).noneMatch(capability -> capability != null
|
JsonSmartHomeCapabilities.SmartHomeCapability[] capabilities = shd.capabilities;
|
||||||
|
if (capabilities == null || Stream.of(capabilities).noneMatch(capability -> capability != null
|
||||||
&& Constants.SUPPORTED_INTERFACES.contains(capability.interfaceName))) {
|
&& Constants.SUPPORTED_INTERFACES.contains(capability.interfaceName))) {
|
||||||
// No supported interface found
|
// No supported interface found
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -109,7 +109,8 @@ public class SmartHomeDeviceHandler extends BaseThingHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
Collection<ChannelInfo> required = handler.initialize(this, capabilities.get(interfaceName));
|
Collection<ChannelInfo> required = handler.initialize(this,
|
||||||
|
capabilities.getOrDefault(interfaceName, Collections.emptyList()));
|
||||||
for (ChannelInfo channelInfo : required) {
|
for (ChannelInfo channelInfo : required) {
|
||||||
unusedChannels.remove(channelInfo.channelId);
|
unusedChannels.remove(channelInfo.channelId);
|
||||||
if (addChannelToDevice(thingBuilder, channelInfo.channelId, channelInfo.itemType,
|
if (addChannelToDevice(thingBuilder, channelInfo.channelId, channelInfo.itemType,
|
||||||
|
|
|
@ -62,12 +62,10 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
|
||||||
private ScheduledFuture<?> validateKeysJob;
|
private ScheduledFuture<?> validateKeysJob;
|
||||||
|
|
||||||
// Application key is granted only by request from developer
|
// Application key is granted only by request from developer
|
||||||
@Nullable
|
private String applicationKey = "";
|
||||||
private String applicationKey;
|
|
||||||
|
|
||||||
// API key assigned to user in ambientweather.net dashboard
|
// API key assigned to user in ambientweather.net dashboard
|
||||||
@Nullable
|
private String apiKey = "";
|
||||||
private String apiKey;
|
|
||||||
|
|
||||||
// Used Ambient Weather real-time API to retrieve weather data
|
// Used Ambient Weather real-time API to retrieve weather data
|
||||||
// for weather stations assigned to an API key
|
// for weather stations assigned to an API key
|
||||||
|
@ -151,8 +149,9 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThingOfflineWithCommError(String errorDetail, String statusDescription) {
|
public void setThingOfflineWithCommError(@Nullable String errorDetail, @Nullable String statusDescription) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, statusDescription);
|
String status = statusDescription != null ? statusDescription : "null";
|
||||||
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -213,11 +212,11 @@ public class AmbientWeatherBridgeHandler extends BaseBridgeHandler {
|
||||||
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
|
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable String getApplicationKey() {
|
public String getApplicationKey() {
|
||||||
return applicationKey;
|
return applicationKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable String getApiKey() {
|
public String getApiKey() {
|
||||||
return apiKey;
|
return apiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,6 @@ public class RemoteSensor {
|
||||||
*/
|
*/
|
||||||
private String convertSoilMoistureToString(double soilMoisture) {
|
private String convertSoilMoistureToString(double soilMoisture) {
|
||||||
Double key = soilMoistureMap.ceilingKey(soilMoisture);
|
Double key = soilMoistureMap.ceilingKey(soilMoisture);
|
||||||
return key == null ? "UNKNOWN" : soilMoistureMap.get(key);
|
return key == null ? "UNKNOWN" : soilMoistureMap.getOrDefault(key, "UNKNOWN");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ package org.openhab.binding.automower.internal.rest.exceptions;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An exception that occurred while communicating with an automower or an automower bridge
|
* An exception that occurred while communicating with an automower or an automower bridge
|
||||||
|
@ -57,8 +58,9 @@ public class AutomowerCommunicationException extends IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public @Nullable String getMessage() {
|
||||||
return "Rest call failed: statusCode=" + statusCode + ", message=" + super.getMessage();
|
String message = super.getMessage();
|
||||||
|
return message == null ? null : "Rest call failed: statusCode=" + statusCode + ", message=" + message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -100,11 +100,7 @@ public enum EirDataType {
|
||||||
initMapping();
|
initMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codeMapping.get(eirDataType) == null) {
|
return codeMapping.getOrDefault(eirDataType, UNKNOWN);
|
||||||
return UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return codeMapping.get(eirDataType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -75,11 +75,7 @@ public enum EirFlags {
|
||||||
initMapping();
|
initMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codeMapping.get(eirFlag) == null) {
|
return codeMapping.getOrDefault(eirFlag, UNKNOWN);
|
||||||
return UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return codeMapping.get(eirFlag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,7 +56,10 @@ public class RoamingBluetoothDevice extends DelegateBluetoothDevice {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeBluetoothDevice(BluetoothDevice device) {
|
public void removeBluetoothDevice(BluetoothDevice device) {
|
||||||
device.removeListener(devices.remove(device));
|
BluetoothDeviceListener listener = devices.remove(device);
|
||||||
|
if (listener != null) {
|
||||||
|
device.removeListener(listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -197,7 +197,8 @@ public class SmartherApiConnector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
future.completeExceptionally(e.getCause());
|
Throwable cause = e.getCause();
|
||||||
|
future.completeExceptionally(cause != null ? cause : e);
|
||||||
} catch (SmartherGatewayException e) {
|
} catch (SmartherGatewayException e) {
|
||||||
future.completeExceptionally(e);
|
future.completeExceptionally(e);
|
||||||
} catch (RuntimeException | TimeoutException e) {
|
} catch (RuntimeException | TimeoutException e) {
|
||||||
|
|
|
@ -243,9 +243,12 @@ public class Enums {
|
||||||
|
|
||||||
public static <E extends Enum<E> & TypeWithIntProperty> E lookup(Class<E> en, int value)
|
public static <E extends Enum<E> & TypeWithIntProperty> E lookup(Class<E> en, int value)
|
||||||
throws SmartherIllegalPropertyValueException {
|
throws SmartherIllegalPropertyValueException {
|
||||||
for (E constant : en.getEnumConstants()) {
|
E[] constants = en.getEnumConstants();
|
||||||
if (constant.getValue() == value) {
|
if (constants != null) {
|
||||||
return constant;
|
for (E constant : constants) {
|
||||||
|
if (constant.getValue() == value) {
|
||||||
|
return constant;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new SmartherIllegalPropertyValueException(en.getSimpleName(), String.valueOf(value));
|
throw new SmartherIllegalPropertyValueException(en.getSimpleName(), String.valueOf(value));
|
||||||
|
@ -257,9 +260,12 @@ public class Enums {
|
||||||
|
|
||||||
public static <E extends Enum<E> & TypeWithStringProperty> E lookup(Class<E> en, String value)
|
public static <E extends Enum<E> & TypeWithStringProperty> E lookup(Class<E> en, String value)
|
||||||
throws SmartherIllegalPropertyValueException {
|
throws SmartherIllegalPropertyValueException {
|
||||||
for (E constant : en.getEnumConstants()) {
|
E[] constants = en.getEnumConstants();
|
||||||
if (constant.getValue().equals(value)) {
|
if (constants != null) {
|
||||||
return constant;
|
for (E constant : constants) {
|
||||||
|
if (constant.getValue().equals(value)) {
|
||||||
|
return constant;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new SmartherIllegalPropertyValueException(en.getSimpleName(), value);
|
throw new SmartherIllegalPropertyValueException(en.getSimpleName(), value);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.bticinosmarther.internal.api.exception;
|
package org.openhab.binding.bticinosmarther.internal.api.exception;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals that a generic OAuth2 authorization issue with API gateway has occurred.
|
* Signals that a generic OAuth2 authorization issue with API gateway has occurred.
|
||||||
|
@ -30,7 +31,7 @@ public class SmartherAuthorizationException extends SmartherGatewayException {
|
||||||
* @param message
|
* @param message
|
||||||
* the error message returned from the API gateway
|
* the error message returned from the API gateway
|
||||||
*/
|
*/
|
||||||
public SmartherAuthorizationException(String message) {
|
public SmartherAuthorizationException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ public class SmartherAuthorizationException extends SmartherGatewayException {
|
||||||
* @param cause
|
* @param cause
|
||||||
* the cause (a null value is permitted, and indicates that the cause is nonexistent or unknown)
|
* the cause (a null value is permitted, and indicates that the cause is nonexistent or unknown)
|
||||||
*/
|
*/
|
||||||
public SmartherAuthorizationException(String message, Throwable cause) {
|
public SmartherAuthorizationException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ package org.openhab.binding.bticinosmarther.internal.api.exception;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals that a generic communication issue with API gateway has occurred.
|
* Signals that a generic communication issue with API gateway has occurred.
|
||||||
|
@ -32,7 +33,7 @@ public class SmartherGatewayException extends IOException {
|
||||||
* @param message
|
* @param message
|
||||||
* the error message returned from the API gateway
|
* the error message returned from the API gateway
|
||||||
*/
|
*/
|
||||||
public SmartherGatewayException(String message) {
|
public SmartherGatewayException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ public class SmartherGatewayException extends IOException {
|
||||||
* @param cause
|
* @param cause
|
||||||
* the cause (a null value is permitted, and indicates that the cause is nonexistent or unknown)
|
* the cause (a null value is permitted, and indicates that the cause is nonexistent or unknown)
|
||||||
*/
|
*/
|
||||||
public SmartherGatewayException(String message, Throwable cause) {
|
public SmartherGatewayException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ public class SmartherGatewayException extends IOException {
|
||||||
* @param cause
|
* @param cause
|
||||||
* the cause (a null value is permitted, and indicates that the cause is nonexistent or unknown)
|
* the cause (a null value is permitted, and indicates that the cause is nonexistent or unknown)
|
||||||
*/
|
*/
|
||||||
public SmartherGatewayException(Throwable cause) {
|
public SmartherGatewayException(@Nullable Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.bticinosmarther.internal.api.exception;
|
package org.openhab.binding.bticinosmarther.internal.api.exception;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals that an "invalid response" messaging issue with API gateway has occurred.
|
* Signals that an "invalid response" messaging issue with API gateway has occurred.
|
||||||
|
@ -30,7 +31,7 @@ public class SmartherInvalidResponseException extends SmartherGatewayException {
|
||||||
* @param message
|
* @param message
|
||||||
* the error message returned from the API gateway
|
* the error message returned from the API gateway
|
||||||
*/
|
*/
|
||||||
public SmartherInvalidResponseException(String message) {
|
public SmartherInvalidResponseException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
@ -45,6 +46,9 @@ public final class DateUtil {
|
||||||
* if the string cannot be parsed to a local date
|
* if the string cannot be parsed to a local date
|
||||||
*/
|
*/
|
||||||
public static LocalDate parseDate(@Nullable String str, String pattern) {
|
public static LocalDate parseDate(@Nullable String str, String pattern) {
|
||||||
|
if (str == null) {
|
||||||
|
throw new DateTimeParseException("date string is null", "<null>", 0);
|
||||||
|
}
|
||||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
|
||||||
return LocalDate.parse(str, dtf);
|
return LocalDate.parse(str, dtf);
|
||||||
}
|
}
|
||||||
|
@ -63,6 +67,9 @@ public final class DateUtil {
|
||||||
* if the string cannot be parsed to a local date and time
|
* if the string cannot be parsed to a local date and time
|
||||||
*/
|
*/
|
||||||
public static LocalDateTime parseLocalTime(@Nullable String str, String pattern) {
|
public static LocalDateTime parseLocalTime(@Nullable String str, String pattern) {
|
||||||
|
if (str == null) {
|
||||||
|
throw new DateTimeParseException("time string is null", "<null>", 0);
|
||||||
|
}
|
||||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
|
||||||
return LocalDateTime.parse(str, dtf);
|
return LocalDateTime.parse(str, dtf);
|
||||||
}
|
}
|
||||||
|
@ -81,6 +88,9 @@ public final class DateUtil {
|
||||||
* if the string cannot be parsed to a date and time with timezone
|
* if the string cannot be parsed to a date and time with timezone
|
||||||
*/
|
*/
|
||||||
public static ZonedDateTime parseZonedTime(@Nullable String str, String pattern) {
|
public static ZonedDateTime parseZonedTime(@Nullable String str, String pattern) {
|
||||||
|
if (str == null) {
|
||||||
|
throw new DateTimeParseException("zoned string is null", "<null>", 0);
|
||||||
|
}
|
||||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
|
||||||
return ZonedDateTime.parse(str, dtf);
|
return ZonedDateTime.parse(str, dtf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.buienradar.internal.buienradarapi;
|
package org.openhab.binding.buienradar.internal.buienradarapi;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An exception thrown when a result from Buienradar could not be correctly parsed.
|
* An exception thrown when a result from Buienradar could not be correctly parsed.
|
||||||
|
@ -28,19 +29,19 @@ public class BuienradarParseException extends Exception {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuienradarParseException(String message) {
|
public BuienradarParseException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuienradarParseException(Throwable cause) {
|
public BuienradarParseException(@Nullable Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuienradarParseException(String message, Throwable cause) {
|
public BuienradarParseException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuienradarParseException(String message, Throwable cause, boolean enableSuppression,
|
public BuienradarParseException(@Nullable String message, @Nullable Throwable cause, boolean enableSuppression,
|
||||||
boolean writableStackTrace) {
|
boolean writableStackTrace) {
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,8 @@ public class BuienradarPredictionAPI implements PredictionAPI {
|
||||||
actual = Optional.of(prediction.getActualDateTime());
|
actual = Optional.of(prediction.getActualDateTime());
|
||||||
predictions.add(prediction);
|
predictions.add(prediction);
|
||||||
} catch (BuienradarParseException e) {
|
} catch (BuienradarParseException e) {
|
||||||
errors.add(e.getMessage());
|
String error = e.getMessage();
|
||||||
|
errors.add(error != null ? error : "null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!errors.isEmpty()) {
|
if (!errors.isEmpty()) {
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class CaddxMessage {
|
||||||
logger.debug("Message does not contain property [{}]", property);
|
logger.debug("Message does not contain property [{}]", property);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return propertyMap.get(property);
|
return propertyMap.getOrDefault(property, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPropertyById(String id) {
|
public String getPropertyById(String id) {
|
||||||
|
@ -204,7 +204,7 @@ public class CaddxMessage {
|
||||||
logger.debug("Message does not contain id [{}]", id);
|
logger.debug("Message does not contain id [{}]", id);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return idMap.get(id);
|
return idMap.getOrDefault(id, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int @Nullable [] getReplyMessageNumbers() {
|
public int @Nullable [] getReplyMessageNumbers() {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.darksky.internal.connection;
|
package org.openhab.binding.darksky.internal.connection;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link DarkSkyCommunicationException} is a communication exception for the connections to Dark Sky API.
|
* The {@link DarkSkyCommunicationException} is a communication exception for the connections to Dark Sky API.
|
||||||
|
@ -36,7 +37,7 @@ public class DarkSkyCommunicationException extends RuntimeException {
|
||||||
*
|
*
|
||||||
* @param message Detail message
|
* @param message Detail message
|
||||||
*/
|
*/
|
||||||
public DarkSkyCommunicationException(String message) {
|
public DarkSkyCommunicationException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ public class DarkSkyCommunicationException extends RuntimeException {
|
||||||
*
|
*
|
||||||
* @param cause The cause
|
* @param cause The cause
|
||||||
*/
|
*/
|
||||||
public DarkSkyCommunicationException(Throwable cause) {
|
public DarkSkyCommunicationException(@Nullable Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public class DarkSkyCommunicationException extends RuntimeException {
|
||||||
* @param message Detail message
|
* @param message Detail message
|
||||||
* @param cause The cause
|
* @param cause The cause
|
||||||
*/
|
*/
|
||||||
public DarkSkyCommunicationException(String message, Throwable cause) {
|
public DarkSkyCommunicationException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.darksky.internal.connection;
|
package org.openhab.binding.darksky.internal.connection;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link DarkSkyConfigurationException} is a configuration exception for the connections to Dark Sky API.
|
* The {@link DarkSkyConfigurationException} is a configuration exception for the connections to Dark Sky API.
|
||||||
|
@ -36,7 +37,7 @@ public class DarkSkyConfigurationException extends IllegalArgumentException {
|
||||||
*
|
*
|
||||||
* @param message Detail message
|
* @param message Detail message
|
||||||
*/
|
*/
|
||||||
public DarkSkyConfigurationException(String message) {
|
public DarkSkyConfigurationException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ public class DarkSkyConfigurationException extends IllegalArgumentException {
|
||||||
*
|
*
|
||||||
* @param cause The cause
|
* @param cause The cause
|
||||||
*/
|
*/
|
||||||
public DarkSkyConfigurationException(Throwable cause) {
|
public DarkSkyConfigurationException(@Nullable Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public class DarkSkyConfigurationException extends IllegalArgumentException {
|
||||||
* @param message Detail message
|
* @param message Detail message
|
||||||
* @param cause The cause
|
* @param cause The cause
|
||||||
*/
|
*/
|
||||||
public DarkSkyConfigurationException(String message, Throwable cause) {
|
public DarkSkyConfigurationException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class DarkSkyConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildURL(String url, Map<String, String> requestParams) {
|
private String buildURL(String url, Map<String, String> requestParams) {
|
||||||
return requestParams.keySet().stream().map(key -> key + "=" + encodeParam(requestParams.get(key)))
|
return requestParams.entrySet().stream().map(e -> e.getKey() + "=" + encodeParam(e.getValue()))
|
||||||
.collect(joining("&", url + "?", ""));
|
.collect(joining("&", url + "?", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,8 +105,10 @@ public class LightThingHandler extends DeconzBaseThingHandler<LightMessage> {
|
||||||
|| thing.getThingTypeUID().equals(THING_TYPE_EXTENDED_COLOR_LIGHT)) {
|
|| thing.getThingTypeUID().equals(THING_TYPE_EXTENDED_COLOR_LIGHT)) {
|
||||||
try {
|
try {
|
||||||
Map<String, String> properties = thing.getProperties();
|
Map<String, String> properties = thing.getProperties();
|
||||||
ctMax = Integer.parseInt(properties.get(PROPERTY_CT_MAX));
|
String ctMaxString = properties.get(PROPERTY_CT_MAX);
|
||||||
ctMin = Integer.parseInt(properties.get(PROPERTY_CT_MIN));
|
ctMax = ctMaxString == null ? ZCL_CT_MAX : Integer.parseInt(ctMaxString);
|
||||||
|
String ctMinString = properties.get(PROPERTY_CT_MIN);
|
||||||
|
ctMin = ctMinString == null ? ZCL_CT_MIN : Integer.parseInt(ctMinString);
|
||||||
|
|
||||||
// minimum and maximum are inverted due to mired/kelvin conversion!
|
// minimum and maximum are inverted due to mired/kelvin conversion!
|
||||||
StateDescription stateDescription = StateDescriptionFragmentBuilder.create()
|
StateDescription stateDescription = StateDescriptionFragmentBuilder.create()
|
||||||
|
|
|
@ -1280,22 +1280,27 @@ public class DeviceStatusManagerImpl implements DeviceStatusManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(EventItem eventItem) {
|
public void handleEvent(EventItem eventItem) {
|
||||||
if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName())
|
try {
|
||||||
|| EventNames.DEVICE_BINARY_INPUT_EVENT.equals(eventItem.getName())) {
|
if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName())
|
||||||
logger.debug("Detect {} eventItem = {}", eventItem.getName(), eventItem.toString());
|
|| EventNames.DEVICE_BINARY_INPUT_EVENT.equals(eventItem.getName())) {
|
||||||
Device dev = getDeviceOfEvent(eventItem);
|
logger.debug("Detect {} eventItem = {}", eventItem.getName(), eventItem.toString());
|
||||||
if (dev != null) {
|
Device dev = getDeviceOfEvent(eventItem);
|
||||||
if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName())) {
|
if (dev != null) {
|
||||||
dev.setDeviceSensorByEvent(eventItem);
|
if (EventNames.DEVICE_SENSOR_VALUE.equals(eventItem.getName())) {
|
||||||
} else {
|
dev.setDeviceSensorByEvent(eventItem);
|
||||||
DeviceBinarayInputEnum binaryInputType = DeviceBinarayInputEnum.getdeviceBinarayInput(
|
} else {
|
||||||
Short.parseShort(eventItem.getProperties().get(EventResponseEnum.INPUT_TYPE)));
|
DeviceBinarayInputEnum binaryInputType = DeviceBinarayInputEnum.getdeviceBinarayInput(Short
|
||||||
Short newState = Short.parseShort(eventItem.getProperties().get(EventResponseEnum.INPUT_STATE));
|
.parseShort(eventItem.getProperties().getOrDefault(EventResponseEnum.INPUT_TYPE, "")));
|
||||||
if (binaryInputType != null) {
|
Short newState = Short
|
||||||
dev.setBinaryInputState(binaryInputType, newState);
|
.parseShort(eventItem.getProperties().getOrDefault(EventResponseEnum.INPUT_STATE, ""));
|
||||||
|
if (binaryInputType != null) {
|
||||||
|
dev.setBinaryInputState(binaryInputType, newState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
logger.debug("Unexpected missing or invalid number while handling event", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,54 +284,64 @@ public class TemperatureControlManager implements EventHandler, TemperatureContr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(EventItem eventItem) {
|
public void handleEvent(EventItem eventItem) {
|
||||||
logger.debug("detect event: {}", eventItem.toString());
|
try {
|
||||||
if (eventItem.getName().equals(EventNames.ZONE_SENSOR_VALUE)) {
|
logger.debug("detect event: {}", eventItem.toString());
|
||||||
if (zoneTemperationControlListenerMap != null) {
|
if (eventItem.getName().equals(EventNames.ZONE_SENSOR_VALUE)) {
|
||||||
if (SensorEnum.ROOM_TEMPERATURE_SET_POINT.getSensorType().toString()
|
if (zoneTemperationControlListenerMap != null) {
|
||||||
.equals(eventItem.getProperties().get(EventResponseEnum.SENSOR_TYPE))) {
|
if (SensorEnum.ROOM_TEMPERATURE_SET_POINT.getSensorType().toString()
|
||||||
Integer zoneID = Integer.parseInt(eventItem.getSource().get(EventResponseEnum.ZONEID));
|
.equals(eventItem.getProperties().get(EventResponseEnum.SENSOR_TYPE))) {
|
||||||
if (zoneTemperationControlListenerMap.get(zoneID) != null) {
|
Integer zoneID = Integer
|
||||||
Float newValue = Float
|
.parseInt(eventItem.getSource().getOrDefault(EventResponseEnum.ZONEID, ""));
|
||||||
.parseFloat(eventItem.getProperties().get(EventResponseEnum.SENSOR_VALUE_FLOAT));
|
if (zoneTemperationControlListenerMap.get(zoneID) != null) {
|
||||||
if (!isEcho(zoneID, SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE, newValue)) {
|
|
||||||
zoneTemperationControlListenerMap.get(zoneID).onTargetTemperatureChanged(newValue);
|
Float newValue = Float.parseFloat(
|
||||||
|
eventItem.getProperties().getOrDefault(EventResponseEnum.SENSOR_VALUE_FLOAT, ""));
|
||||||
|
if (!isEcho(zoneID, SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE, newValue)) {
|
||||||
|
zoneTemperationControlListenerMap.get(zoneID).onTargetTemperatureChanged(newValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE.getSensorType().toString()
|
||||||
if (SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE.getSensorType().toString()
|
.equals(eventItem.getProperties().get(EventResponseEnum.SENSOR_TYPE))) {
|
||||||
.equals(eventItem.getProperties().get(EventResponseEnum.SENSOR_TYPE))) {
|
Integer zoneID = Integer
|
||||||
Integer zoneID = Integer.parseInt(eventItem.getSource().get(EventResponseEnum.ZONEID));
|
.parseInt(eventItem.getSource().getOrDefault(EventResponseEnum.ZONEID, ""));
|
||||||
if (zoneTemperationControlListenerMap.get(zoneID) != null) {
|
if (zoneTemperationControlListenerMap.get(zoneID) != null) {
|
||||||
Float newValue = Float
|
Float newValue = Float.parseFloat(
|
||||||
.parseFloat(eventItem.getProperties().get(EventResponseEnum.SENSOR_VALUE_FLOAT));
|
eventItem.getProperties().getOrDefault(EventResponseEnum.SENSOR_VALUE_FLOAT, ""));
|
||||||
if (!isEcho(zoneID, SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE, newValue)) {
|
if (!isEcho(zoneID, SensorEnum.ROOM_TEMPERATURE_CONTROL_VARIABLE, newValue)) {
|
||||||
zoneTemperationControlListenerMap.get(zoneID).onControlValueChanged(newValue.intValue());
|
zoneTemperationControlListenerMap.get(zoneID)
|
||||||
|
.onControlValueChanged(newValue.intValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (eventItem.getName().equals(EventNames.HEATING_CONTROL_OPERATION_MODE)) {
|
if (eventItem.getName().equals(EventNames.HEATING_CONTROL_OPERATION_MODE)) {
|
||||||
if (EVALUATE_REAL_ACTIVE_MODE.equals(eventItem.getProperties().get(EventResponseEnum.ACTIONS))) {
|
if (EVALUATE_REAL_ACTIVE_MODE.equals(eventItem.getProperties().get(EventResponseEnum.ACTIONS))) {
|
||||||
Integer zoneID = Integer.parseInt(eventItem.getProperties().get(EventResponseEnum.ZONEID));
|
Integer zoneID = Integer
|
||||||
TemperatureControlStatus temperationControlStatus = dSapi
|
.parseInt(eventItem.getProperties().getOrDefault(EventResponseEnum.ZONEID, ""));
|
||||||
.getZoneTemperatureControlStatus(connectionMananager.getSessionToken(), zoneID, null);
|
TemperatureControlStatus temperationControlStatus = dSapi
|
||||||
if (temperationControlStatus != null) {
|
.getZoneTemperatureControlStatus(connectionMananager.getSessionToken(), zoneID, null);
|
||||||
addTemperatureControlStatus(temperationControlStatus);
|
if (temperationControlStatus != null) {
|
||||||
|
addTemperatureControlStatus(temperationControlStatus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (eventItem.getName().equals(EventNames.STATE_CHANGED)) {
|
if (eventItem.getName().equals(EventNames.STATE_CHANGED)) {
|
||||||
if (STATE_NAME_HEATING_WATER_SYSTEM.equals(eventItem.getProperties().get(EventResponseEnum.STATE_NAME))) {
|
if (STATE_NAME_HEATING_WATER_SYSTEM
|
||||||
currentHeatingWaterSystemStage = eventItem.getProperties().get(EventResponseEnum.STATE);
|
.equals(eventItem.getProperties().get(EventResponseEnum.STATE_NAME))) {
|
||||||
logger.debug("heating water system state changed to {}", currentHeatingWaterSystemStage);
|
currentHeatingWaterSystemStage = eventItem.getProperties().get(EventResponseEnum.STATE);
|
||||||
if (systemStateChangeListener != null) {
|
logger.debug("heating water system state changed to {}", currentHeatingWaterSystemStage);
|
||||||
systemStateChangeListener.onSystemStateChanged(STATE_NAME_HEATING_WATER_SYSTEM,
|
if (systemStateChangeListener != null) {
|
||||||
currentHeatingWaterSystemStage);
|
systemStateChangeListener.onSystemStateChanged(STATE_NAME_HEATING_WATER_SYSTEM,
|
||||||
|
currentHeatingWaterSystemStage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
logger.debug("Unexpected missing or invalid number while handling event", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,20 +87,24 @@ public class DeviceSensorValue {
|
||||||
* Creates a new {@link DeviceSensorValue} through the properties of a digitalSTROM
|
* Creates a new {@link DeviceSensorValue} through the properties of a digitalSTROM
|
||||||
* {@link EventNames#DEVICE_SENSOR_VALUE} event.
|
* {@link EventNames#DEVICE_SENSOR_VALUE} event.
|
||||||
*
|
*
|
||||||
* @param eventPropertie must not be null
|
* @param eventProperties must not be null
|
||||||
*/
|
*/
|
||||||
public DeviceSensorValue(Map<EventResponseEnum, String> eventPropertie) {
|
public DeviceSensorValue(Map<EventResponseEnum, String> eventProperties) {
|
||||||
if (eventPropertie.get(EventResponseEnum.SENSOR_VALUE_FLOAT) != null) {
|
String strVal = eventProperties.get(EventResponseEnum.SENSOR_VALUE_FLOAT);
|
||||||
floatValue = Float.parseFloat(eventPropertie.get(EventResponseEnum.SENSOR_VALUE_FLOAT));
|
if (strVal != null) {
|
||||||
|
floatValue = Float.parseFloat(strVal);
|
||||||
}
|
}
|
||||||
if (eventPropertie.get(EventResponseEnum.SENSOR_TYPE) != null) {
|
strVal = eventProperties.get(EventResponseEnum.SENSOR_TYPE);
|
||||||
sensorType = SensorEnum.getSensor(Short.parseShort(eventPropertie.get(EventResponseEnum.SENSOR_TYPE)));
|
if (strVal != null) {
|
||||||
|
sensorType = SensorEnum.getSensor(Short.parseShort(strVal));
|
||||||
}
|
}
|
||||||
if (eventPropertie.get(EventResponseEnum.SENSOR_VALUE) != null) {
|
strVal = eventProperties.get(EventResponseEnum.SENSOR_VALUE);
|
||||||
dsValue = Integer.parseInt(eventPropertie.get(EventResponseEnum.SENSOR_VALUE));
|
if (strVal != null) {
|
||||||
|
dsValue = Integer.parseInt(strVal);
|
||||||
}
|
}
|
||||||
if (eventPropertie.get(EventResponseEnum.SENSOR_INDEX) != null) {
|
strVal = eventProperties.get(EventResponseEnum.SENSOR_INDEX);
|
||||||
sensorIndex = Short.parseShort(eventPropertie.get(EventResponseEnum.SENSOR_INDEX));
|
if (strVal != null) {
|
||||||
|
sensorIndex = Short.parseShort(strVal);
|
||||||
}
|
}
|
||||||
timestamp = Date.from(Instant.ofEpochMilli(System.currentTimeMillis()));
|
timestamp = Date.from(Instant.ofEpochMilli(System.currentTimeMillis()));
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.draytonwiser.internal.api;
|
package org.openhab.binding.draytonwiser.internal.api;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown in case of api problems.
|
* Exception thrown in case of api problems.
|
||||||
|
@ -24,11 +25,11 @@ public class DraytonWiserApiException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public DraytonWiserApiException(final String message) {
|
public DraytonWiserApiException(final @Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DraytonWiserApiException(final String message, final Throwable cause) {
|
public DraytonWiserApiException(final @Nullable String message, final @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,44 +106,49 @@ public class CosemObjectFactory {
|
||||||
|
|
||||||
logger.trace("Received obisIdString {}, obisId: {}, values: {}", obisIdString, obisId, cosemStringValues);
|
logger.trace("Received obisIdString {}, obisId: {}, values: {}", obisIdString, obisId, cosemStringValues);
|
||||||
|
|
||||||
CosemObject cosemObject = null;
|
CosemObjectType objectType = obisLookupTableFixed.get(reducedObisId);
|
||||||
|
if (objectType != null) {
|
||||||
if (obisLookupTableFixed.containsKey(reducedObisId)) {
|
|
||||||
cosemObject = getCosemObjectInternal(obisLookupTableFixed.get(reducedObisId), obisId, cosemStringValues);
|
|
||||||
logger.trace("Found obisId {} in the fixed lookup table", reducedObisId);
|
logger.trace("Found obisId {} in the fixed lookup table", reducedObisId);
|
||||||
} else if (obisLookupTableMultipleFixed.containsKey(reducedObisId)) {
|
return getCosemObjectInternal(objectType, obisId, cosemStringValues);
|
||||||
for (CosemObjectType cosemObjectType : obisLookupTableMultipleFixed.get(reducedObisId)) {
|
}
|
||||||
cosemObject = getCosemObjectInternal(cosemObjectType, obisId, cosemStringValues);
|
|
||||||
|
List<CosemObjectType> objectTypeList = obisLookupTableMultipleFixed.get(reducedObisId);
|
||||||
|
if (objectTypeList != null) {
|
||||||
|
for (CosemObjectType cosemObjectType : objectTypeList) {
|
||||||
|
CosemObject cosemObject = getCosemObjectInternal(cosemObjectType, obisId, cosemStringValues);
|
||||||
if (cosemObject != null) {
|
if (cosemObject != null) {
|
||||||
logger.trace("Found obisId {} in the fixed lookup table", reducedObisId);
|
logger.trace("Found obisId {} in the fixed lookup table", reducedObisId);
|
||||||
break;
|
return cosemObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (obisLookupTableDynamic.containsKey(reducedObisId)) {
|
}
|
||||||
|
|
||||||
|
objectType = obisLookupTableDynamic.get(reducedObisId);
|
||||||
|
if (objectType != null) {
|
||||||
logger.trace("Found obisId {} in the dynamic lookup table", reducedObisId);
|
logger.trace("Found obisId {} in the dynamic lookup table", reducedObisId);
|
||||||
cosemObject = getCosemObjectInternal(obisLookupTableDynamic.get(reducedObisId), obisId, cosemStringValues);
|
return getCosemObjectInternal(objectType, obisId, cosemStringValues);
|
||||||
} else if (obisLookupTableFixed.containsKey(reducedObisIdGroupE)) {
|
}
|
||||||
cosemObject = getCosemObjectInternal(obisLookupTableFixed.get(reducedObisIdGroupE), obisId,
|
|
||||||
cosemStringValues);
|
objectType = obisLookupTableFixed.get(reducedObisIdGroupE);
|
||||||
} else {
|
if (objectType != null) {
|
||||||
for (CosemObjectType obisMsgType : obisWildcardCosemTypeList) {
|
return getCosemObjectInternal(objectType, obisId, cosemStringValues);
|
||||||
if (obisMsgType.obisId.equalsWildCard(reducedObisId)) {
|
}
|
||||||
cosemObject = getCosemObjectInternal(obisMsgType, obisId, cosemStringValues);
|
|
||||||
if (cosemObject != null) {
|
for (CosemObjectType obisMsgType : obisWildcardCosemTypeList) {
|
||||||
logger.trace("Searched reducedObisId {} in the wild card type list, result: {}", reducedObisId,
|
if (obisMsgType.obisId.equalsWildCard(reducedObisId)) {
|
||||||
cosemObject);
|
CosemObject cosemObject = getCosemObjectInternal(obisMsgType, obisId, cosemStringValues);
|
||||||
obisLookupTableDynamic.put(reducedObisId, obisMsgType);
|
if (cosemObject != null) {
|
||||||
break;
|
logger.trace("Searched reducedObisId {} in the wild card type list, result: {}", reducedObisId,
|
||||||
}
|
cosemObject);
|
||||||
|
obisLookupTableDynamic.put(reducedObisId, obisMsgType);
|
||||||
|
return cosemObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cosemObject == null) {
|
logger.debug("Received unknown Cosem Object(OBIS id: {})", obisId);
|
||||||
logger.debug("Received unknown Cosem Object(OBIS id: {})", obisId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cosemObject;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -147,9 +147,9 @@ public class DSMRMeterDiscoveryService extends DSMRDiscoveryService implements P
|
||||||
.map(Thing::getHandler)
|
.map(Thing::getHandler)
|
||||||
.filter(DSMRMeterHandler.class::isInstance)
|
.filter(DSMRMeterHandler.class::isInstance)
|
||||||
.map(DSMRMeterHandler.class::cast)
|
.map(DSMRMeterHandler.class::cast)
|
||||||
.map(DSMRMeterHandler::getMeterDescriptor)
|
.map(h -> h == null ? null : h.getMeterDescriptor())
|
||||||
|
.map(d -> d == null ? null : d.getMeterType())
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(h -> h.getMeterType())
|
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
// Create list of all configured meters that are not in the detected list. If not empty meters might not be
|
// Create list of all configured meters that are not in the detected list. If not empty meters might not be
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.enturno.internal.connection;
|
package org.openhab.binding.enturno.internal.connection;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link EnturCommunicationException} is a communication exception for the connections to Entur API.
|
* The {@link EnturCommunicationException} is a communication exception for the connections to Entur API.
|
||||||
|
@ -24,11 +25,11 @@ public class EnturCommunicationException extends RuntimeException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public EnturCommunicationException(String message) {
|
public EnturCommunicationException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnturCommunicationException(String message, Throwable cause) {
|
public EnturCommunicationException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,6 +422,7 @@ public class ExecHandler extends BaseThingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getOperatingSystemName() {
|
public static String getOperatingSystemName() {
|
||||||
return System.getProperty("os.name");
|
String osname = System.getProperty("os.name");
|
||||||
|
return osname != null ? osname : "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class Client {
|
||||||
}
|
}
|
||||||
private static final NamespaceContext NAMESPACE_CONTEXT = new NamespaceContext() {
|
private static final NamespaceContext NAMESPACE_CONTEXT = new NamespaceContext() {
|
||||||
@Override
|
@Override
|
||||||
public String getNamespaceURI(@Nullable String prefix) {
|
public @Nullable String getNamespaceURI(@Nullable String prefix) {
|
||||||
return NAMESPACES.get(prefix);
|
return NAMESPACES.get(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.foobot.internal;
|
package org.openhab.binding.foobot.internal;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when problems occur with obtaining data for the foobot api.
|
* Exception thrown when problems occur with obtaining data for the foobot api.
|
||||||
|
@ -24,7 +25,7 @@ public class FoobotApiException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public FoobotApiException(final int status, final String message) {
|
public FoobotApiException(final int status, final @Nullable String message) {
|
||||||
super(String.format("%s (code: %s)", message, status));
|
super(String.format("%s (code: %s)", message, status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,7 @@ package org.openhab.binding.foobot.internal.handler;
|
||||||
import static org.openhab.binding.foobot.internal.FoobotBindingConstants.*;
|
import static org.openhab.binding.foobot.internal.FoobotBindingConstants.*;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
|
@ -35,20 +35,20 @@ public class GreeException extends Exception {
|
||||||
private static final long serialVersionUID = -2337258558995287405L;
|
private static final long serialVersionUID = -2337258558995287405L;
|
||||||
private static String EX_NONE = "none";
|
private static String EX_NONE = "none";
|
||||||
|
|
||||||
public GreeException(Exception exception) {
|
public GreeException(@Nullable Exception exception) {
|
||||||
super(exception);
|
super(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GreeException(String message) {
|
public GreeException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GreeException(String message, Exception exception) {
|
public GreeException(@Nullable String message, @Nullable Exception exception) {
|
||||||
super(message, exception);
|
super(message, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public @Nullable String getMessage() {
|
||||||
return isEmpty() ? "" : nonNullString(super.getMessage());
|
return isEmpty() ? "" : nonNullString(super.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class GreeDeviceFinder {
|
||||||
deviceTable.put(newDevice.getId(), newDevice);
|
deviceTable.put(newDevice.getId(), newDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GreeAirDevice getDevice(String id) {
|
public @Nullable GreeAirDevice getDevice(String id) {
|
||||||
return deviceTable.get(id);
|
return deviceTable.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,11 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getShadeId() throws NumberFormatException {
|
private int getShadeId() throws NumberFormatException {
|
||||||
return Integer.parseInt(getConfigAs(HDPowerViewShadeConfiguration.class).id);
|
String str = getConfigAs(HDPowerViewShadeConfiguration.class).id;
|
||||||
|
if (str == null) {
|
||||||
|
throw new NumberFormatException("null input string");
|
||||||
|
}
|
||||||
|
return Integer.parseInt(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopShade() {
|
private void stopShade() {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.heliosventilation.internal;
|
package org.openhab.binding.heliosventilation.internal;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link HeliosPropertiesFormatException} class defines an exception to describe parsing format errors
|
* The {@link HeliosPropertiesFormatException} class defines an exception to describe parsing format errors
|
||||||
|
@ -41,7 +42,7 @@ public class HeliosPropertiesFormatException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public @Nullable String getMessage() {
|
||||||
return "Cannot parse '" + fullSpec + "' for datapoint '" + channelName + "': " + reason;
|
return "Cannot parse '" + fullSpec + "' for datapoint '" + channelName + "': " + reason;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,10 @@ public class HPServerResult<result> {
|
||||||
private final @Nullable result data;
|
private final @Nullable result data;
|
||||||
private final String errorMessage;
|
private final String errorMessage;
|
||||||
|
|
||||||
public HPServerResult(RequestStatus status, String errorMessage) {
|
public HPServerResult(RequestStatus status, @Nullable String errorMessage) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.data = null;
|
this.data = null;
|
||||||
this.errorMessage = errorMessage;
|
this.errorMessage = errorMessage != null ? errorMessage : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public HPServerResult(result data) {
|
public HPServerResult(result data) {
|
||||||
|
|
|
@ -221,9 +221,12 @@ public class HueBridge {
|
||||||
ArrayList<T> lightList = new ArrayList<>();
|
ArrayList<T> lightList = new ArrayList<>();
|
||||||
|
|
||||||
for (String id : lightMap.keySet()) {
|
for (String id : lightMap.keySet()) {
|
||||||
|
@Nullable
|
||||||
T light = lightMap.get(id);
|
T light = lightMap.get(id);
|
||||||
light.setId(id);
|
if (light != null) {
|
||||||
lightList.add(light);
|
light.setId(id);
|
||||||
|
lightList.add(light);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lightList;
|
return lightList;
|
||||||
|
|
|
@ -144,7 +144,8 @@ public class Scene {
|
||||||
if (getGroupId() == null) {
|
if (getGroupId() == null) {
|
||||||
return getLightIds().stream().allMatch(id -> group.getLightIds().contains(id));
|
return getLightIds().stream().allMatch(id -> group.getLightIds().contains(id));
|
||||||
} else {
|
} else {
|
||||||
return group.getId().contentEquals(getGroupId());
|
String groupId = getGroupId();
|
||||||
|
return groupId != null ? group.getId().contentEquals(groupId) : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ public class DeviceStructureManager {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Device getBridgeDevice() {
|
public @Nullable Device getBridgeDevice() {
|
||||||
return getDeviceMap().get(bridgeDeviceId);
|
return getDeviceMap().get(bridgeDeviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,8 +291,8 @@ public abstract class CommandHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getRampLevel(InsteonChannelConfiguration conf, int defaultValue) {
|
private int getRampLevel(InsteonChannelConfiguration conf, int defaultValue) {
|
||||||
Map<String, @Nullable String> params = conf.getParameters();
|
String str = conf.getParameters().get("ramplevel");
|
||||||
return params.containsKey("ramplevel") ? Integer.parseInt(params.get("ramplevel")) : defaultValue;
|
return str != null ? Integer.parseInt(str) : defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,8 +642,8 @@ public abstract class CommandHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double getRampTime(InsteonChannelConfiguration conf, double defaultValue) {
|
protected double getRampTime(InsteonChannelConfiguration conf, double defaultValue) {
|
||||||
Map<String, @Nullable String> params = conf.getParameters();
|
String str = conf.getParameters().get("ramptime");
|
||||||
return params.containsKey("ramptime") ? Double.parseDouble(params.get("ramptime")) : defaultValue;
|
return str != null ? Double.parseDouble(str) : defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,9 +159,8 @@ public abstract class MessageHandler {
|
||||||
*/
|
*/
|
||||||
protected double getDoubleParameter(String key, double def) {
|
protected double getDoubleParameter(String key, double def) {
|
||||||
try {
|
try {
|
||||||
if (parameters.get(key) != null) {
|
String str = parameters.get(key);
|
||||||
return Double.parseDouble(parameters.get(key));
|
return str != null ? Double.parseDouble(str) : def;
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
logger.warn("malformed int parameter in message handler: {}", key);
|
logger.warn("malformed int parameter in message handler: {}", key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,9 @@ public class ReadByteBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
int b = Math.min(len, remaining());
|
int b = Math.min(len, remaining());
|
||||||
System.arraycopy(buf, index, bytes, off, b);
|
if (bytes != null) {
|
||||||
|
System.arraycopy(buf, index, bytes, off, b);
|
||||||
|
}
|
||||||
index += b;
|
index += b;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,12 +280,13 @@ public class Msg {
|
||||||
* @param len the length to copy from the src byte array
|
* @param len the length to copy from the src byte array
|
||||||
*/
|
*/
|
||||||
private void initialize(byte[] newData, int offset, int len) {
|
private void initialize(byte[] newData, int offset, int len) {
|
||||||
data = new byte[len];
|
byte[] data = new byte[len];
|
||||||
if (offset >= 0 && offset < newData.length) {
|
if (offset >= 0 && offset < newData.length) {
|
||||||
System.arraycopy(newData, offset, data, 0, len);
|
System.arraycopy(newData, offset, data, 0, len);
|
||||||
} else {
|
} else {
|
||||||
logger.warn("intialize(): Offset out of bounds!");
|
logger.warn("intialize(): Offset out of bounds!");
|
||||||
}
|
}
|
||||||
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -344,7 +345,10 @@ public class Msg {
|
||||||
throw new FieldException("data index out of bounds!");
|
throw new FieldException("data index out of bounds!");
|
||||||
}
|
}
|
||||||
byte[] section = new byte[numBytes];
|
byte[] section = new byte[numBytes];
|
||||||
System.arraycopy(data, offset, section, 0, numBytes);
|
byte[] data = this.data;
|
||||||
|
if (data != null) {
|
||||||
|
System.arraycopy(data, offset, section, 0, numBytes);
|
||||||
|
}
|
||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.core.thing.Channel;
|
import org.openhab.core.thing.Channel;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -35,8 +36,8 @@ public class KM200Utils {
|
||||||
* Translates a service name to a service path (Replaces # through /)
|
* Translates a service name to a service path (Replaces # through /)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static String translatesNameToPath(String name) {
|
public static @Nullable String translatesNameToPath(@Nullable String name) {
|
||||||
return name.replace("#", "/");
|
return name == null ? null : name.replace("#", "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -436,10 +436,10 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
|
||||||
if (null != tmpSerObjekt) {
|
if (null != tmpSerObjekt) {
|
||||||
if (parent == null || parent.equals(tmpSerObjekt.getParent())) {
|
if (parent == null || parent.equals(tmpSerObjekt.getParent())) {
|
||||||
synchronized (sendMap) {
|
synchronized (sendMap) {
|
||||||
if (sendMap.containsKey(actChannel)) {
|
JsonObject obj = sendMap.get(actChannel);
|
||||||
state = dataHandler.parseJSONData(sendMap.get(actChannel),
|
if (obj != null) {
|
||||||
tmpSerObjekt.getServiceType(), tmpService, actChTypes,
|
state = dataHandler.parseJSONData(obj, tmpSerObjekt.getServiceType(), tmpService,
|
||||||
KM200Utils.getChannelConfigurationStrings(actChannel));
|
actChTypes, KM200Utils.getChannelConfigurationStrings(actChannel));
|
||||||
} else {
|
} else {
|
||||||
state = dataHandler.getProvidersState(tmpService, actChTypes,
|
state = dataHandler.getProvidersState(tmpService, actChTypes,
|
||||||
KM200Utils.getChannelConfigurationStrings(actChannel));
|
KM200Utils.getChannelConfigurationStrings(actChannel));
|
||||||
|
@ -548,10 +548,10 @@ public class KM200GatewayHandler extends BaseBridgeHandler {
|
||||||
synchronized (sendMap) {
|
synchronized (sendMap) {
|
||||||
KM200ServiceObject serObjekt = remoteDevice.getServiceObject(service);
|
KM200ServiceObject serObjekt = remoteDevice.getServiceObject(service);
|
||||||
if (null != serObjekt) {
|
if (null != serObjekt) {
|
||||||
if (sendMap.containsKey(channel)) {
|
JsonObject obj = sendMap.get(channel);
|
||||||
state = dataHandler.parseJSONData(sendMap.get(channel),
|
if (obj != null) {
|
||||||
serObjekt.getServiceType(), service, chTypes,
|
state = dataHandler.parseJSONData(obj, serObjekt.getServiceType(), service,
|
||||||
KM200Utils.getChannelConfigurationStrings(channel));
|
chTypes, KM200Utils.getChannelConfigurationStrings(channel));
|
||||||
} else {
|
} else {
|
||||||
state = dataHandler.getProvidersState(service, chTypes,
|
state = dataHandler.getProvidersState(service, chTypes,
|
||||||
KM200Utils.getChannelConfigurationStrings(channel));
|
KM200Utils.getChannelConfigurationStrings(channel));
|
||||||
|
|
|
@ -467,7 +467,10 @@ public class KM200ThingHandler extends BaseThingHandler {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Search for new services in sub path */
|
/* Search for new services in sub path */
|
||||||
addChannels(serObj.serviceTreeMap.get(subKey), thing, subChannels, subKey + "_");
|
KM200ServiceObject obj = serObj.serviceTreeMap.get(subKey);
|
||||||
|
if (obj != null) {
|
||||||
|
addChannels(obj, thing, subChannels, subKey + "_");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DATA_TYPE_ERROR_LIST:
|
case DATA_TYPE_ERROR_LIST:
|
||||||
if ("nbrErrors".equals(subKey) || "error".equals(subKey)) {
|
if ("nbrErrors".equals(subKey) || "error".equals(subKey)) {
|
||||||
|
|
|
@ -213,8 +213,9 @@ public abstract class AbstractKNXClient implements NetworkLinkListener, KNXClien
|
||||||
private void disconnect(@Nullable Exception e) {
|
private void disconnect(@Nullable Exception e) {
|
||||||
releaseConnection();
|
releaseConnection();
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
|
String message = e.getLocalizedMessage();
|
||||||
statusUpdateCallback.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
statusUpdateCallback.updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||||
e.getLocalizedMessage());
|
message != null ? message : "");
|
||||||
} else {
|
} else {
|
||||||
statusUpdateCallback.updateStatus(ThingStatus.OFFLINE);
|
statusUpdateCallback.updateStatus(ThingStatus.OFFLINE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,9 +92,10 @@ public class KostalInverterFactory extends BaseThingHandlerFactory {
|
||||||
return new WebscrapeHandler(thing);
|
return new WebscrapeHandler(thing);
|
||||||
}
|
}
|
||||||
// third generation
|
// third generation
|
||||||
if (SUPPORTED_THIRD_GENERATION_THING_TYPES_UIDS.containsKey(thing.getThingTypeUID())) {
|
ThirdGenerationInverterTypes inverterType = SUPPORTED_THIRD_GENERATION_THING_TYPES_UIDS
|
||||||
return new ThirdGenerationHandler(thing, httpClient,
|
.get(thing.getThingTypeUID());
|
||||||
SUPPORTED_THIRD_GENERATION_THING_TYPES_UIDS.get(thing.getThingTypeUID()));
|
if (inverterType != null) {
|
||||||
|
return new ThirdGenerationHandler(thing, httpClient, inverterType);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,8 @@ public class ConnectionStateMachine extends AbstractStateMachine<ConnectionState
|
||||||
public void handleConnectionFailed(@Nullable Throwable e) {
|
public void handleConnectionFailed(@Nullable Throwable e) {
|
||||||
if (!(state instanceof ConnectionStateShutdown)) {
|
if (!(state instanceof ConnectionStateShutdown)) {
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
connection.getCallback().onOffline(e.getMessage());
|
String message = e.getMessage();
|
||||||
|
connection.getCallback().onOffline(message != null ? message : "");
|
||||||
} else {
|
} else {
|
||||||
connection.getCallback().onOffline("");
|
connection.getCallback().onOffline("");
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,8 @@ public class LGWebOSTVMouseSocket {
|
||||||
|
|
||||||
@OnWebSocketError
|
@OnWebSocketError
|
||||||
public void onError(Throwable cause) {
|
public void onError(Throwable cause) {
|
||||||
Optional.ofNullable(this.listener).ifPresent(l -> l.onError(cause.getMessage()));
|
String message = cause.getMessage();
|
||||||
|
Optional.ofNullable(this.listener).ifPresent(l -> l.onError(message != null ? message : ""));
|
||||||
logger.debug("Connection Error.", cause);
|
logger.debug("Connection Error.", cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,8 @@ public class LGWebOSTVSocket {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional.ofNullable(this.listener).ifPresent(l -> l.onError(cause.getMessage()));
|
String message = cause.getMessage();
|
||||||
|
Optional.ofNullable(this.listener).ifPresent(l -> l.onError(message != null ? message : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnWebSocketClose
|
@OnWebSocketClose
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.net.HttpCookie;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -125,8 +126,8 @@ public class EnedisHttpApi {
|
||||||
|
|
||||||
AuthData authData = gson.fromJson(result.getContentAsString(), AuthData.class);
|
AuthData authData = gson.fromJson(result.getContentAsString(), AuthData.class);
|
||||||
if (authData.callbacks.size() < 2 || authData.callbacks.get(0).input.size() == 0
|
if (authData.callbacks.size() < 2 || authData.callbacks.get(0).input.size() == 0
|
||||||
|| authData.callbacks.get(1).input.size() == 0
|
|| authData.callbacks.get(1).input.size() == 0 || !config.username
|
||||||
|| !config.username.contentEquals(authData.callbacks.get(0).input.get(0).valueAsString())) {
|
.equals(Objects.requireNonNull(authData.callbacks.get(0).input.get(0)).valueAsString())) {
|
||||||
throw new LinkyException("Authentication error, the authentication_cookie is probably wrong");
|
throw new LinkyException("Authentication error, the authentication_cookie is probably wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link LogReaderHandler} is responsible for handling commands, which are
|
* The {@link LogHandler} is responsible for handling commands, which are
|
||||||
* sent to one of the channels.
|
* sent to one of the channels.
|
||||||
*
|
*
|
||||||
* @author Miika Jukka - Initial contribution
|
* @author Miika Jukka - Initial contribution
|
||||||
|
@ -80,10 +80,15 @@ public class LogHandler extends BaseThingHandler implements FileReaderListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
configuration = getConfigAs(LogReaderConfiguration.class);
|
String logDir = System.getProperty("openhab.logdir");
|
||||||
|
if (logDir == null) {
|
||||||
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||||
|
"Cannot determine system log directory.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
configuration.filePath = configuration.filePath.replaceFirst("\\$\\{OPENHAB_LOGDIR\\}",
|
configuration = getConfigAs(LogReaderConfiguration.class);
|
||||||
System.getProperty("openhab.logdir"));
|
configuration.filePath = configuration.filePath.replaceFirst("\\$\\{OPENHAB_LOGDIR\\}", logDir);
|
||||||
|
|
||||||
logger.debug("Using configuration: {}", configuration);
|
logger.debug("Using configuration: {}", configuration);
|
||||||
|
|
||||||
|
|
|
@ -531,8 +531,17 @@ public class LxServerHandler extends BaseThingHandler implements LxServerHandler
|
||||||
channels.addAll(getThing().getChannels());
|
channels.addAll(getThing().getChannels());
|
||||||
}
|
}
|
||||||
channels.sort((c1, c2) -> {
|
channels.sort((c1, c2) -> {
|
||||||
String label = c1.getLabel();
|
String label1 = c1.getLabel();
|
||||||
return label == null ? 1 : label.compareTo(c2.getLabel());
|
String label2 = c2.getLabel();
|
||||||
|
if (label1 == null && label2 != null) {
|
||||||
|
return 1;
|
||||||
|
} else if (label1 != null && label2 == null) {
|
||||||
|
return -1;
|
||||||
|
} else if (label1 == null && label2 == null) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return label1.compareTo(label2);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ThingBuilder builder = editThing();
|
ThingBuilder builder = editThing();
|
||||||
builder.withChannels(channels);
|
builder.withChannels(channels);
|
||||||
|
|
|
@ -50,7 +50,11 @@ public class DbXmlInfoReader {
|
||||||
xstream = new XStream(driver);
|
xstream = new XStream(driver);
|
||||||
|
|
||||||
configureSecurity(xstream);
|
configureSecurity(xstream);
|
||||||
setClassLoader(Project.class.getClassLoader());
|
ClassLoader classLoader = Project.class.getClassLoader();
|
||||||
|
if (classLoader == null) {
|
||||||
|
throw new UnknownError("Cannot find classloader");
|
||||||
|
}
|
||||||
|
setClassLoader(classLoader);
|
||||||
registerAliases(xstream);
|
registerAliases(xstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,12 +63,13 @@ public class MeteoAlerteHandler extends BaseThingHandler {
|
||||||
+ "facet=etat_vent&facet=etat_pluie_inondation&facet=etat_orage&facet=etat_inondation&facet=etat_neige&facet=etat_canicule&"
|
+ "facet=etat_vent&facet=etat_pluie_inondation&facet=etat_orage&facet=etat_inondation&facet=etat_neige&facet=etat_canicule&"
|
||||||
+ "facet=etat_grand_froid&facet=etat_avalanches&refine.nom_dept=";
|
+ "facet=etat_grand_froid&facet=etat_avalanches&refine.nom_dept=";
|
||||||
private static final int TIMEOUT_MS = 30000;
|
private static final int TIMEOUT_MS = 30000;
|
||||||
|
private static final String UNKNOWN_COLOR = "b3b3b3";
|
||||||
private static final Map<AlertLevel, String> ALERT_COLORS = Map.ofEntries(
|
private static final Map<AlertLevel, String> ALERT_COLORS = Map.ofEntries(
|
||||||
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.GREEN, "00ff00"),
|
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.GREEN, "00ff00"),
|
||||||
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.YELLOW, "ffff00"),
|
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.YELLOW, "ffff00"),
|
||||||
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.ORANGE, "ff6600"),
|
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.ORANGE, "ff6600"),
|
||||||
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.RED, "ff0000"),
|
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.RED, "ff0000"),
|
||||||
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.UNKNOWN, "b3b3b3"));
|
new AbstractMap.SimpleEntry<AlertLevel, String>(AlertLevel.UNKNOWN, UNKNOWN_COLOR));
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(MeteoAlerteHandler.class);
|
private final Logger logger = LoggerFactory.getLogger(MeteoAlerteHandler.class);
|
||||||
// Time zone provider representing time zone configured in openHAB configuration
|
// Time zone provider representing time zone configured in openHAB configuration
|
||||||
|
@ -169,7 +170,7 @@ public class MeteoAlerteHandler extends BaseThingHandler {
|
||||||
if (isLinked(channelIcon)) {
|
if (isLinked(channelIcon)) {
|
||||||
String resource = getResource(String.format("picto/%s.svg", channelId));
|
String resource = getResource(String.format("picto/%s.svg", channelId));
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
resource = resource.replaceAll(ALERT_COLORS.get(AlertLevel.UNKNOWN), ALERT_COLORS.get(value));
|
resource = resource.replaceAll(UNKNOWN_COLOR, ALERT_COLORS.getOrDefault(value, UNKNOWN_COLOR));
|
||||||
}
|
}
|
||||||
updateState(channelIcon,
|
updateState(channelIcon,
|
||||||
resource != null ? new RawType(resource.getBytes(), "image/svg+xml") : UnDefType.UNDEF);
|
resource != null ? new RawType(resource.getBytes(), "image/svg+xml") : UnDefType.UNDEF);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.miio.internal;
|
package org.openhab.binding.miio.internal;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will be thrown instead of the many possible errors in the crypto module
|
* Will be thrown instead of the many possible errors in the crypto module
|
||||||
|
@ -31,11 +32,11 @@ public class MiIoCryptoException extends Exception {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MiIoCryptoException(String message) {
|
public MiIoCryptoException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MiIoCryptoException(String message, Exception e) {
|
public MiIoCryptoException(@Nullable String message, @Nullable Exception e) {
|
||||||
super(message, e);
|
super(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.miio.internal.cloud;
|
package org.openhab.binding.miio.internal.cloud;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will be thrown for cloud errors
|
* Will be thrown for cloud errors
|
||||||
|
@ -30,11 +31,11 @@ public class MiCloudException extends Exception {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MiCloudException(String message) {
|
public MiCloudException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MiCloudException(String message, Exception e) {
|
public MiCloudException(@Nullable String message, @Nullable Exception e) {
|
||||||
super(message, e);
|
super(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,8 +278,9 @@ public abstract class MiIoAbstractHandler extends BaseThingHandler implements Mi
|
||||||
disconnected("No Response from device");
|
disconnected("No Response from device");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void disconnected(String message) {
|
protected void disconnected(@Nullable String message) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, message);
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
|
||||||
|
message != null ? message : "");
|
||||||
final MiIoAsyncCommunication miioCom = this.miioCom;
|
final MiIoAsyncCommunication miioCom = this.miioCom;
|
||||||
if (miioCom != null) {
|
if (miioCom != null) {
|
||||||
lastId = miioCom.getId();
|
lastId = miioCom.getId();
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Map;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.miio.internal.Utils;
|
import org.openhab.binding.miio.internal.Utils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -358,7 +359,11 @@ public class RRMapFileParser {
|
||||||
return sw.toString();
|
return sw.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printAreaDetails(ArrayList<float[]> areas, PrintWriter pw) {
|
private void printAreaDetails(@Nullable ArrayList<float[]> areas, PrintWriter pw) {
|
||||||
|
if (areas == null) {
|
||||||
|
pw.println("null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
areas.forEach(area -> {
|
areas.forEach(area -> {
|
||||||
pw.print("\tArea coordinates:");
|
pw.print("\tArea coordinates:");
|
||||||
for (int i = 0; i < area.length; i++) {
|
for (int i = 0; i < area.length; i++) {
|
||||||
|
@ -368,7 +373,11 @@ public class RRMapFileParser {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printObstacleDetails(ArrayList<int[]> obstacle, PrintWriter pw) {
|
private void printObstacleDetails(@Nullable ArrayList<int[]> obstacle, PrintWriter pw) {
|
||||||
|
if (obstacle == null) {
|
||||||
|
pw.println("null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
obstacle.forEach(area -> {
|
obstacle.forEach(area -> {
|
||||||
pw.print("\tObstacle coordinates:");
|
pw.print("\tObstacle coordinates:");
|
||||||
for (int i = 0; i < area.length; i++) {
|
for (int i = 0; i < area.length; i++) {
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class MilightV6SessionManager implements Runnable, Closeable {
|
||||||
public CompletableFuture<DatagramSocket> start() {
|
public CompletableFuture<DatagramSocket> start() {
|
||||||
if (willbeclosed) {
|
if (willbeclosed) {
|
||||||
CompletableFuture<DatagramSocket> f = new CompletableFuture<>();
|
CompletableFuture<DatagramSocket> f = new CompletableFuture<>();
|
||||||
f.completeExceptionally(null);
|
f.completeExceptionally(new IllegalStateException("will be closed"));
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
if (sessionThread.isAlive()) {
|
if (sessionThread.isAlive()) {
|
||||||
|
|
|
@ -339,8 +339,11 @@ public class HeliosEasyControlsHandler extends BaseThingHandler {
|
||||||
try {
|
try {
|
||||||
writeValue(channelId, v);
|
writeValue(channelId, v);
|
||||||
if (variableMap != null) {
|
if (variableMap != null) {
|
||||||
updateState(variableMap.get(channelId), v);
|
HeliosVariable variable = variableMap.get(channelId);
|
||||||
updateStatus(ThingStatus.ONLINE);
|
if (variable != null) {
|
||||||
|
updateState(variable, v);
|
||||||
|
updateStatus(ThingStatus.ONLINE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (HeliosException e) {
|
} catch (HeliosException e) {
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||||
|
|
|
@ -18,6 +18,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.measure.Unit;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler;
|
import org.openhab.binding.modbus.handler.ModbusEndpointThingHandler;
|
||||||
|
@ -38,6 +40,7 @@ import org.openhab.core.thing.ThingTypeUID;
|
||||||
import org.openhab.core.thing.binding.BaseThingHandler;
|
import org.openhab.core.thing.binding.BaseThingHandler;
|
||||||
import org.openhab.core.thing.binding.ThingHandler;
|
import org.openhab.core.thing.binding.ThingHandler;
|
||||||
import org.openhab.core.types.Command;
|
import org.openhab.core.types.Command;
|
||||||
|
import org.openhab.core.types.State;
|
||||||
import org.openhab.core.types.UnDefType;
|
import org.openhab.core.types.UnDefType;
|
||||||
import org.openhab.io.transport.modbus.AsyncModbusFailure;
|
import org.openhab.io.transport.modbus.AsyncModbusFailure;
|
||||||
import org.openhab.io.transport.modbus.ModbusCommunicationInterface;
|
import org.openhab.io.transport.modbus.ModbusCommunicationInterface;
|
||||||
|
@ -304,8 +307,10 @@ public class StuderHandler extends BaseThingHandler {
|
||||||
Float quantity = parser.hexToFloat(hexString);
|
Float quantity = parser.hexToFloat(hexString);
|
||||||
if (quantity != null) {
|
if (quantity != null) {
|
||||||
if (type.equals(THING_TYPE_BSP)) {
|
if (type.equals(THING_TYPE_BSP)) {
|
||||||
updateState(CHANNELS_BSP.get(registerNumber),
|
Unit<?> unit = UNIT_CHANNELS_BSP.get(registerNumber);
|
||||||
new QuantityType<>(quantity, UNIT_CHANNELS_BSP.get(registerNumber)));
|
if (unit != null) {
|
||||||
|
internalUpdateState(CHANNELS_BSP.get(registerNumber), new QuantityType<>(quantity, unit));
|
||||||
|
}
|
||||||
} else if (type.equals(THING_TYPE_XTENDER)) {
|
} else if (type.equals(THING_TYPE_XTENDER)) {
|
||||||
handlePolledDataXtender(registerNumber, quantity);
|
handlePolledDataXtender(registerNumber, quantity);
|
||||||
} else if (type.equals(THING_TYPE_VARIOTRACK)) {
|
} else if (type.equals(THING_TYPE_VARIOTRACK)) {
|
||||||
|
@ -329,18 +334,20 @@ public class StuderHandler extends BaseThingHandler {
|
||||||
case CHANNEL_PV2_OPERATING_MODE:
|
case CHANNEL_PV2_OPERATING_MODE:
|
||||||
VSMode vsmode = StuderParser.getVSModeByCode(quantity.intValue());
|
VSMode vsmode = StuderParser.getVSModeByCode(quantity.intValue());
|
||||||
if (vsmode == VSMode.UNKNOWN) {
|
if (vsmode == VSMode.UNKNOWN) {
|
||||||
updateState(CHANNELS_VARIOSTRING.get(registerNumber), UnDefType.UNDEF);
|
internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), UnDefType.UNDEF);
|
||||||
} else {
|
} else {
|
||||||
updateState(CHANNELS_VARIOSTRING.get(registerNumber), new StringType(vsmode.name()));
|
internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), new StringType(vsmode.name()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHANNEL_STATE_VARIOSTRING:
|
case CHANNEL_STATE_VARIOSTRING:
|
||||||
OnOffType vsstate = StuderParser.getStateByCode(quantity.intValue());
|
OnOffType vsstate = StuderParser.getStateByCode(quantity.intValue());
|
||||||
updateState(CHANNELS_VARIOSTRING.get(registerNumber), vsstate);
|
internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), vsstate);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
updateState(CHANNELS_VARIOSTRING.get(registerNumber),
|
Unit<?> unit = UNIT_CHANNELS_VARIOSTRING.get(registerNumber);
|
||||||
new QuantityType<>(quantity, UNIT_CHANNELS_VARIOSTRING.get(registerNumber)));
|
if (unit != null) {
|
||||||
|
internalUpdateState(CHANNELS_VARIOSTRING.get(registerNumber), new QuantityType<>(quantity, unit));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,28 +361,30 @@ public class StuderHandler extends BaseThingHandler {
|
||||||
case CHANNEL_MODEL_VARIOTRACK:
|
case CHANNEL_MODEL_VARIOTRACK:
|
||||||
VTType type = StuderParser.getVTTypeByCode(quantity.intValue());
|
VTType type = StuderParser.getVTTypeByCode(quantity.intValue());
|
||||||
if (type == VTType.UNKNOWN) {
|
if (type == VTType.UNKNOWN) {
|
||||||
updateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF);
|
internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF);
|
||||||
} else {
|
} else {
|
||||||
updateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(type.name()));
|
internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(type.name()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHANNEL_OPERATING_MODE:
|
case CHANNEL_OPERATING_MODE:
|
||||||
VTMode vtmode = StuderParser.getVTModeByCode(quantity.intValue());
|
VTMode vtmode = StuderParser.getVTModeByCode(quantity.intValue());
|
||||||
if (vtmode == VTMode.UNKNOWN) {
|
if (vtmode == VTMode.UNKNOWN) {
|
||||||
updateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF);
|
internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), UnDefType.UNDEF);
|
||||||
} else {
|
} else {
|
||||||
updateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(vtmode.name()));
|
internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), new StringType(vtmode.name()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHANNEL_STATE_VARIOTRACK:
|
case CHANNEL_STATE_VARIOTRACK:
|
||||||
OnOffType vtstate = StuderParser.getStateByCode(quantity.intValue());
|
OnOffType vtstate = StuderParser.getStateByCode(quantity.intValue());
|
||||||
updateState(CHANNELS_VARIOTRACK.get(registerNumber), vtstate);
|
internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), vtstate);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
updateState(CHANNELS_VARIOTRACK.get(registerNumber),
|
Unit<?> unit = UNIT_CHANNELS_VARIOTRACK.get(registerNumber);
|
||||||
new QuantityType<>(quantity, UNIT_CHANNELS_VARIOTRACK.get(registerNumber)));
|
if (unit != null) {
|
||||||
|
internalUpdateState(CHANNELS_VARIOTRACK.get(registerNumber), new QuantityType<>(quantity, unit));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,18 +398,20 @@ public class StuderHandler extends BaseThingHandler {
|
||||||
case CHANNEL_OPERATING_STATE:
|
case CHANNEL_OPERATING_STATE:
|
||||||
ModeXtender mode = StuderParser.getModeXtenderByCode(quantity.intValue());
|
ModeXtender mode = StuderParser.getModeXtenderByCode(quantity.intValue());
|
||||||
if (mode == ModeXtender.UNKNOWN) {
|
if (mode == ModeXtender.UNKNOWN) {
|
||||||
updateState(CHANNELS_XTENDER.get(registerNumber), UnDefType.UNDEF);
|
internalUpdateState(CHANNELS_XTENDER.get(registerNumber), UnDefType.UNDEF);
|
||||||
} else {
|
} else {
|
||||||
updateState(CHANNELS_XTENDER.get(registerNumber), new StringType(mode.name()));
|
internalUpdateState(CHANNELS_XTENDER.get(registerNumber), new StringType(mode.name()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CHANNEL_STATE_INVERTER:
|
case CHANNEL_STATE_INVERTER:
|
||||||
OnOffType xtstate = StuderParser.getStateByCode(quantity.intValue());
|
OnOffType xtstate = StuderParser.getStateByCode(quantity.intValue());
|
||||||
updateState(CHANNELS_XTENDER.get(registerNumber), xtstate);
|
internalUpdateState(CHANNELS_XTENDER.get(registerNumber), xtstate);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
updateState(CHANNELS_XTENDER.get(registerNumber),
|
Unit<?> unit = UNIT_CHANNELS_XTENDER.get(registerNumber);
|
||||||
new QuantityType<>(quantity, UNIT_CHANNELS_XTENDER.get(registerNumber)));
|
if (unit != null) {
|
||||||
|
internalUpdateState(CHANNELS_XTENDER.get(registerNumber), new QuantityType<>(quantity, unit));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,4 +450,10 @@ public class StuderHandler extends BaseThingHandler {
|
||||||
updateStatus(ThingStatus.ONLINE);
|
updateStatus(ThingStatus.ONLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void internalUpdateState(@Nullable String channelUID, @Nullable State state) {
|
||||||
|
if (channelUID != null && state != null) {
|
||||||
|
super.updateState(channelUID, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.openhab.binding.modbus.sunspec.internal.parser.CommonModelParser;
|
||||||
import org.openhab.core.config.discovery.DiscoveryResult;
|
import org.openhab.core.config.discovery.DiscoveryResult;
|
||||||
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
|
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
|
||||||
import org.openhab.core.library.types.DecimalType;
|
import org.openhab.core.library.types.DecimalType;
|
||||||
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
import org.openhab.core.thing.ThingUID;
|
import org.openhab.core.thing.ThingUID;
|
||||||
import org.openhab.io.transport.modbus.AsyncModbusFailure;
|
import org.openhab.io.transport.modbus.AsyncModbusFailure;
|
||||||
import org.openhab.io.transport.modbus.ModbusBitUtilities;
|
import org.openhab.io.transport.modbus.ModbusBitUtilities;
|
||||||
|
@ -282,8 +283,12 @@ public class SunspecDiscoveryProcess {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThingUID thingUID = new ThingUID(SUPPORTED_THING_TYPES_UIDS.get(block.moduleID), handler.getUID(),
|
ThingTypeUID thingTypeUID = SUPPORTED_THING_TYPES_UIDS.get(block.moduleID);
|
||||||
Integer.toString(block.address));
|
if (thingTypeUID == null) {
|
||||||
|
logger.warn("Found model block but no corresponding thing type UID present: {}", block.moduleID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ThingUID thingUID = new ThingUID(thingTypeUID, handler.getUID(), Integer.toString(block.address));
|
||||||
|
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
properties.put(PROPERTY_VENDOR, commonBlock.manufacturer);
|
properties.put(PROPERTY_VENDOR, commonBlock.manufacturer);
|
||||||
|
|
|
@ -171,8 +171,8 @@ public abstract class AbstractSunSpecHandler extends BaseThingHandler {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ModelBlock block = new ModelBlock();
|
ModelBlock block = new ModelBlock();
|
||||||
block.address = (int) Double.parseDouble(thing.getProperties().get(PROPERTY_BLOCK_ADDRESS));
|
block.address = (int) Double.parseDouble(thing.getProperties().getOrDefault(PROPERTY_BLOCK_ADDRESS, ""));
|
||||||
block.length = (int) Double.parseDouble(thing.getProperties().get(PROPERTY_BLOCK_LENGTH));
|
block.length = (int) Double.parseDouble(thing.getProperties().getOrDefault(PROPERTY_BLOCK_LENGTH, ""));
|
||||||
return block;
|
return block;
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
logger.debug("Could not parse address and length properties, error: {}", ex.getMessage());
|
logger.debug("Could not parse address and length properties, error: {}", ex.getMessage());
|
||||||
|
|
|
@ -255,7 +255,12 @@ public class MonopriceAudioHandler extends BaseThingHandler implements Monoprice
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command instanceof RefreshType) {
|
if (command instanceof RefreshType) {
|
||||||
updateChannelState(zone, channelType, zoneDataMap.get(zone.getZoneId()));
|
MonopriceAudioZoneDTO zoneDTO = zoneDataMap.get(zone.getZoneId());
|
||||||
|
if (zoneDTO != null) {
|
||||||
|
updateChannelState(zone, channelType, zoneDTO);
|
||||||
|
} else {
|
||||||
|
logger.info("Could not execute REFRESH command for zone {}: null", zone.getZoneId());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,12 +467,12 @@ public class MonopriceAudioHandler extends BaseThingHandler implements Monoprice
|
||||||
|
|
||||||
case MonopriceAudioConnector.KEY_ZONE_UPDATE:
|
case MonopriceAudioConnector.KEY_ZONE_UPDATE:
|
||||||
String zoneId = updateData.substring(0, 2);
|
String zoneId = updateData.substring(0, 2);
|
||||||
|
MonopriceAudioZoneDTO zoneDTO = zoneDataMap.get(zoneId);
|
||||||
if (MonopriceAudioZone.VALID_ZONE_IDS.contains(zoneId)) {
|
if (MonopriceAudioZone.VALID_ZONE_IDS.contains(zoneId) && zoneDTO != null) {
|
||||||
MonopriceAudioZone targetZone = MonopriceAudioZone.fromZoneId(zoneId);
|
MonopriceAudioZone targetZone = MonopriceAudioZone.fromZoneId(zoneId);
|
||||||
processZoneUpdate(targetZone, zoneDataMap.get(zoneId), updateData);
|
processZoneUpdate(targetZone, zoneDTO, updateData);
|
||||||
} else {
|
} else {
|
||||||
logger.warn("invalid event: {} for key: {}", evt.getValue(), key);
|
logger.warn("invalid event: {} for key: {} or zone data null", evt.getValue(), key);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -61,10 +61,12 @@ public class NumberValue extends Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkConditions(BigDecimal newValue, DecimalType oldvalue) {
|
protected boolean checkConditions(BigDecimal newValue, DecimalType oldvalue) {
|
||||||
|
BigDecimal min = this.min;
|
||||||
if (min != null && newValue.compareTo(min) == -1) {
|
if (min != null && newValue.compareTo(min) == -1) {
|
||||||
logger.trace("Number not accepted as it is below the configured minimum");
|
logger.trace("Number not accepted as it is below the configured minimum");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
BigDecimal max = this.max;
|
||||||
if (max != null && newValue.compareTo(max) == 1) {
|
if (max != null && newValue.compareTo(max) == 1) {
|
||||||
logger.trace("Number not accepted as it is above the configured maximum");
|
logger.trace("Number not accepted as it is above the configured maximum");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -145,7 +145,10 @@ public class OpenAPIUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkRequiredFirmware(String modelId, String currentFirmwareVersion) {
|
public static boolean checkRequiredFirmware(@Nullable String modelId, @Nullable String currentFirmwareVersion) {
|
||||||
|
if (modelId == null || currentFirmwareVersion == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
int[] currentVer = getFirmwareVersionNumbers(currentFirmwareVersion);
|
int[] currentVer = getFirmwareVersionNumbers(currentFirmwareVersion);
|
||||||
|
|
||||||
int[] requiredVer = getFirmwareVersionNumbers(
|
int[] requiredVer = getFirmwareVersionNumbers(
|
||||||
|
|
|
@ -123,16 +123,17 @@ public class NanoleafControllerHandler extends BaseBridgeHandler {
|
||||||
setDeviceType(config.deviceType);
|
setDeviceType(config.deviceType);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Map<String, String> properties = getThing().getProperties();
|
||||||
if (StringUtils.isEmpty(getAddress()) || StringUtils.isEmpty(String.valueOf(getPort()))) {
|
if (StringUtils.isEmpty(getAddress()) || StringUtils.isEmpty(String.valueOf(getPort()))) {
|
||||||
logger.warn("No IP address and port configured for the Nanoleaf controller");
|
logger.warn("No IP address and port configured for the Nanoleaf controller");
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING,
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_PENDING,
|
||||||
"@text/error.nanoleaf.controller.noIp");
|
"@text/error.nanoleaf.controller.noIp");
|
||||||
stopAllJobs();
|
stopAllJobs();
|
||||||
} else if (!StringUtils.isEmpty(getThing().getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION))
|
} else if (!StringUtils.isEmpty(properties.get(Thing.PROPERTY_FIRMWARE_VERSION))
|
||||||
&& !OpenAPIUtils.checkRequiredFirmware(getThing().getProperties().get(Thing.PROPERTY_MODEL_ID),
|
&& !OpenAPIUtils.checkRequiredFirmware(properties.get(Thing.PROPERTY_MODEL_ID),
|
||||||
getThing().getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION))) {
|
properties.get(Thing.PROPERTY_FIRMWARE_VERSION))) {
|
||||||
logger.warn("Nanoleaf controller firmware is too old: {}. Must be equal or higher than {}",
|
logger.warn("Nanoleaf controller firmware is too old: {}. Must be equal or higher than {}",
|
||||||
getThing().getProperties().get(Thing.PROPERTY_FIRMWARE_VERSION), API_MIN_FW_VER_LIGHTPANELS);
|
properties.get(Thing.PROPERTY_FIRMWARE_VERSION), API_MIN_FW_VER_LIGHTPANELS);
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||||
"@text/error.nanoleaf.controller.incompatibleFirmware");
|
"@text/error.nanoleaf.controller.incompatibleFirmware");
|
||||||
stopAllJobs();
|
stopAllJobs();
|
||||||
|
|
|
@ -75,9 +75,9 @@ public class HttpResponse {
|
||||||
* @param httpCode the http code
|
* @param httpCode the http code
|
||||||
* @param msg the msg
|
* @param msg the msg
|
||||||
*/
|
*/
|
||||||
HttpResponse(int httpCode, String msg) {
|
HttpResponse(int httpCode, @Nullable String msg) {
|
||||||
httpStatus = httpCode;
|
httpStatus = httpCode;
|
||||||
httpReason = msg;
|
httpReason = msg != null ? msg : "";
|
||||||
contents = null;
|
contents = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,12 +105,10 @@ public abstract class AbstractNetatmoThingHandler extends BaseThingHandler {
|
||||||
if (bridgeStatus == ThingStatus.ONLINE) {
|
if (bridgeStatus == ThingStatus.ONLINE) {
|
||||||
config = getThing().getConfiguration();
|
config = getThing().getConfiguration();
|
||||||
|
|
||||||
radioHelper = thing.getProperties().containsKey(PROPERTY_SIGNAL_LEVELS)
|
String signalLevel = thing.getProperties().get(PROPERTY_SIGNAL_LEVELS);
|
||||||
? new RadioHelper(thing.getProperties().get(PROPERTY_SIGNAL_LEVELS))
|
radioHelper = signalLevel != null ? new RadioHelper(signalLevel) : null;
|
||||||
: null;
|
String batteryLevel = thing.getProperties().get(PROPERTY_BATTERY_LEVELS);
|
||||||
batteryHelper = thing.getProperties().containsKey(PROPERTY_BATTERY_LEVELS)
|
batteryHelper = batteryLevel != null ? new BatteryHelper(batteryLevel) : null;
|
||||||
? new BatteryHelper(thing.getProperties().get(PROPERTY_BATTERY_LEVELS))
|
|
||||||
: null;
|
|
||||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "Pending parent object initialization");
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "Pending parent object initialization");
|
||||||
|
|
||||||
initializeThing();
|
initializeThing();
|
||||||
|
|
|
@ -47,9 +47,10 @@ public class CommunicationStatus {
|
||||||
|
|
||||||
public final String getMessage() {
|
public final String getMessage() {
|
||||||
Exception err = error;
|
Exception err = error;
|
||||||
|
String errMsg = err == null ? err.getMessage() : null;
|
||||||
String msg = getHttpCode().getMessage();
|
String msg = getHttpCode().getMessage();
|
||||||
if (err != null && err.getMessage() != null && !err.getMessage().isEmpty()) {
|
if (errMsg != null && !errMsg.isEmpty()) {
|
||||||
return err.getMessage();
|
return errMsg;
|
||||||
} else if (msg != null && !msg.isEmpty()) {
|
} else if (msg != null && !msg.isEmpty()) {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
@ -274,39 +275,26 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setIfPresent(Map<String, String> data, String key, Consumer<String> consumer) {
|
||||||
|
String val = data.get(key);
|
||||||
|
if (val != null) {
|
||||||
|
consumer.accept(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized void cmdSystemInfo(Map<String, String> data) {
|
private synchronized void cmdSystemInfo(Map<String, String> data) {
|
||||||
logger.debug("Niko Home Control: systeminfo");
|
logger.debug("Niko Home Control: systeminfo");
|
||||||
|
|
||||||
if (data.containsKey("swversion")) {
|
setIfPresent(data, "swversion", systemInfo::setSwVersion);
|
||||||
systemInfo.setSwVersion(data.get("swversion"));
|
setIfPresent(data, "api", systemInfo::setApi);
|
||||||
}
|
setIfPresent(data, "time", systemInfo::setTime);
|
||||||
if (data.containsKey("api")) {
|
setIfPresent(data, "language", systemInfo::setLanguage);
|
||||||
systemInfo.setApi(data.get("api"));
|
setIfPresent(data, "currency", systemInfo::setCurrency);
|
||||||
}
|
setIfPresent(data, "units", systemInfo::setUnits);
|
||||||
if (data.containsKey("time")) {
|
setIfPresent(data, "DST", systemInfo::setDst);
|
||||||
systemInfo.setTime(data.get("time"));
|
setIfPresent(data, "TZ", systemInfo::setTz);
|
||||||
}
|
setIfPresent(data, "lastenergyerase", systemInfo::setLastEnergyErase);
|
||||||
if (data.containsKey("language")) {
|
setIfPresent(data, "lastconfig", systemInfo::setLastConfig);
|
||||||
systemInfo.setLanguage(data.get("language"));
|
|
||||||
}
|
|
||||||
if (data.containsKey("currency")) {
|
|
||||||
systemInfo.setCurrency(data.get("currency"));
|
|
||||||
}
|
|
||||||
if (data.containsKey("units")) {
|
|
||||||
systemInfo.setUnits(data.get("units"));
|
|
||||||
}
|
|
||||||
if (data.containsKey("DST")) {
|
|
||||||
systemInfo.setDst(data.get("DST"));
|
|
||||||
}
|
|
||||||
if (data.containsKey("TZ")) {
|
|
||||||
systemInfo.setTz(data.get("TZ"));
|
|
||||||
}
|
|
||||||
if (data.containsKey("lastenergyerase")) {
|
|
||||||
systemInfo.setLastEnergyErase(data.get("lastenergyerase"));
|
|
||||||
}
|
|
||||||
if (data.containsKey("lastconfig")) {
|
|
||||||
systemInfo.setLastConfig(data.get("lastconfig"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -319,12 +307,16 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cmdStartEvents(Map<String, String> data) {
|
private void cmdStartEvents(Map<String, String> data) {
|
||||||
int errorCode = Integer.parseInt(data.get("error"));
|
String errorCodeString = data.get("error");
|
||||||
|
if (errorCodeString != null) {
|
||||||
if (errorCode == 0) {
|
int errorCode = Integer.parseInt(errorCodeString);
|
||||||
logger.debug("Niko Home Control: start events success");
|
if (errorCode == 0) {
|
||||||
|
logger.debug("Niko Home Control: start events success");
|
||||||
|
} else {
|
||||||
|
logger.warn("Niko Home Control: error code {} returned on start events", errorCode);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Niko Home Control: error code {} returned on start events", errorCode);
|
logger.warn("Niko Home Control: could not determine error code returned on start events");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +339,8 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
|
||||||
for (Map<String, String> action : data) {
|
for (Map<String, String> action : data) {
|
||||||
|
|
||||||
String id = action.get("id");
|
String id = action.get("id");
|
||||||
int state = Integer.parseInt(action.get("value1"));
|
String value1 = action.get("value1");
|
||||||
|
int state = ((value1 == null) || value1.isEmpty() ? 0 : Integer.parseInt(value1));
|
||||||
String value2 = action.get("value2");
|
String value2 = action.get("value2");
|
||||||
int closeTime = ((value2 == null) || value2.isEmpty() ? 0 : Integer.parseInt(value2));
|
int closeTime = ((value2 == null) || value2.isEmpty() ? 0 : Integer.parseInt(value2));
|
||||||
String value3 = action.get("value3");
|
String value3 = action.get("value3");
|
||||||
|
@ -396,121 +389,156 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int parseIntOrThrow(@Nullable String str) throws IllegalArgumentException {
|
||||||
|
if (str == null)
|
||||||
|
throw new IllegalArgumentException("String is null");
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new IllegalArgumentException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void cmdListThermostat(List<Map<String, String>> data) {
|
private void cmdListThermostat(List<Map<String, String>> data) {
|
||||||
logger.debug("Niko Home Control: list thermostats");
|
logger.debug("Niko Home Control: list thermostats");
|
||||||
|
|
||||||
for (Map<String, String> thermostat : data) {
|
for (Map<String, String> thermostat : data) {
|
||||||
|
try {
|
||||||
String id = thermostat.get("id");
|
String id = thermostat.get("id");
|
||||||
int measured = Integer.parseInt(thermostat.get("measured"));
|
int measured = parseIntOrThrow(thermostat.get("measured"));
|
||||||
int setpoint = Integer.parseInt(thermostat.get("setpoint"));
|
int setpoint = parseIntOrThrow(thermostat.get("setpoint"));
|
||||||
int mode = Integer.parseInt(thermostat.get("mode"));
|
int mode = parseIntOrThrow(thermostat.get("mode"));
|
||||||
int overrule = Integer.parseInt(thermostat.get("overrule"));
|
int overrule = parseIntOrThrow(thermostat.get("overrule"));
|
||||||
// overruletime received in "HH:MM" format
|
// overruletime received in "HH:MM" format
|
||||||
String[] overruletimeStrings = thermostat.get("overruletime").split(":");
|
String[] overruletimeStrings = thermostat.getOrDefault("overruletime", "").split(":");
|
||||||
int overruletime = 0;
|
int overruletime = 0;
|
||||||
if (overruletimeStrings.length == 2) {
|
if (overruletimeStrings.length == 2) {
|
||||||
overruletime = Integer.parseInt(overruletimeStrings[0]) * 60 + Integer.parseInt(overruletimeStrings[1]);
|
overruletime = Integer.parseInt(overruletimeStrings[0]) * 60
|
||||||
}
|
+ Integer.parseInt(overruletimeStrings[1]);
|
||||||
int ecosave = Integer.parseInt(thermostat.get("ecosave"));
|
|
||||||
|
|
||||||
// For parity with NHC II, assume heating/cooling if thermostat is on and setpoint different from measured
|
|
||||||
int demand = (mode != 3) ? (setpoint > measured ? 1 : (setpoint < measured ? -1 : 0)) : 0;
|
|
||||||
|
|
||||||
if (!thermostats.containsKey(id)) {
|
|
||||||
// Initial instantiation of NhcThermostat class for thermostat object
|
|
||||||
String name = thermostat.get("name");
|
|
||||||
String locationId = thermostat.get("location");
|
|
||||||
String location = "";
|
|
||||||
if (!locationId.isEmpty()) {
|
|
||||||
location = locations.get(locationId).getName();
|
|
||||||
}
|
}
|
||||||
NhcThermostat nhcThermostat = new NhcThermostat1(id, name, location, this);
|
int ecosave = parseIntOrThrow(thermostat.get("ecosave"));
|
||||||
nhcThermostat.updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand);
|
|
||||||
thermostats.put(id, nhcThermostat);
|
// For parity with NHC II, assume heating/cooling if thermostat is on and setpoint different from
|
||||||
} else {
|
// measured
|
||||||
// Thermostat object already exists, so only update state.
|
int demand = (mode != 3) ? (setpoint > measured ? 1 : (setpoint < measured ? -1 : 0)) : 0;
|
||||||
// If we would re-instantiate thermostat, we would lose pointer back from thermostat to thing handler
|
|
||||||
// that was set in thing handler initialize().
|
NhcThermostat t = thermostats.computeIfAbsent(id, i -> {
|
||||||
thermostats.get(id).updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand);
|
// Initial instantiation of NhcThermostat class for thermostat object
|
||||||
|
String name = thermostat.get("name");
|
||||||
|
String locationId = thermostat.get("location");
|
||||||
|
String location = "";
|
||||||
|
if (!locationId.isEmpty()) {
|
||||||
|
location = locations.get(locationId).getName();
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
return new NhcThermostat1(i, name, location, this);
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
});
|
||||||
|
if (t != null) {
|
||||||
|
t.updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand);
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cmdExecuteActions(Map<String, String> data) {
|
private void cmdExecuteActions(Map<String, String> data) {
|
||||||
int errorCode = Integer.parseInt(data.get("error"));
|
try {
|
||||||
if (errorCode == 0) {
|
int errorCode = parseIntOrThrow(data.get("error"));
|
||||||
logger.debug("Niko Home Control: execute action success");
|
if (errorCode == 0) {
|
||||||
} else {
|
logger.debug("Niko Home Control: execute action success");
|
||||||
logger.warn("Niko Home Control: error code {} returned on command execution", errorCode);
|
} else {
|
||||||
|
logger.warn("Niko Home Control: error code {} returned on command execution", errorCode);
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
logger.warn("Niko Home Control: no error code returned on command execution");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cmdExecuteThermostat(Map<String, String> data) {
|
private void cmdExecuteThermostat(Map<String, String> data) {
|
||||||
int errorCode = Integer.parseInt(data.get("error"));
|
try {
|
||||||
if (errorCode == 0) {
|
int errorCode = parseIntOrThrow(data.get("error"));
|
||||||
logger.debug("Niko Home Control: execute thermostats success");
|
if (errorCode == 0) {
|
||||||
} else {
|
logger.debug("Niko Home Control: execute thermostats success");
|
||||||
logger.warn("Niko Home Control: error code {} returned on command execution", errorCode);
|
} else {
|
||||||
|
logger.warn("Niko Home Control: error code {} returned on command execution", errorCode);
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
logger.warn("Niko Home Control: no error code returned on command execution");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void eventListActions(List<Map<String, String>> data) {
|
private void eventListActions(List<Map<String, String>> data) {
|
||||||
for (Map<String, String> action : data) {
|
for (Map<String, String> action : data) {
|
||||||
String id = action.get("id");
|
String id = action.get("id");
|
||||||
if (!actions.containsKey(id)) {
|
if (id == null || !actions.containsKey(id)) {
|
||||||
logger.warn("Niko Home Control: action in controller not known {}", id);
|
logger.warn("Niko Home Control: action in controller not known {}", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int state = Integer.parseInt(action.get("value1"));
|
String stateString = action.get("value1");
|
||||||
logger.debug("Niko Home Control: event execute action {} with state {}", id, state);
|
if (stateString != null) {
|
||||||
actions.get(id).setState(state);
|
int state = Integer.parseInt(stateString);
|
||||||
|
logger.debug("Niko Home Control: event execute action {} with state {}", id, state);
|
||||||
|
NhcAction action1 = actions.get(id);
|
||||||
|
if (action1 != null) {
|
||||||
|
action1.setState(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void eventListThermostat(List<Map<String, String>> data) {
|
private void eventListThermostat(List<Map<String, String>> data) {
|
||||||
for (Map<String, String> thermostat : data) {
|
for (Map<String, String> thermostat : data) {
|
||||||
String id = thermostat.get("id");
|
try {
|
||||||
if (!thermostats.containsKey(id)) {
|
String id = thermostat.get("id");
|
||||||
logger.warn("Niko Home Control: thermostat in controller not known {}", id);
|
if (!thermostats.containsKey(id)) {
|
||||||
return;
|
logger.warn("Niko Home Control: thermostat in controller not known {}", id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int measured = parseIntOrThrow(thermostat.get("measured"));
|
||||||
|
int setpoint = parseIntOrThrow(thermostat.get("setpoint"));
|
||||||
|
int mode = parseIntOrThrow(thermostat.get("mode"));
|
||||||
|
int overrule = parseIntOrThrow(thermostat.get("overrule"));
|
||||||
|
// overruletime received in "HH:MM" format
|
||||||
|
String[] overruletimeStrings = thermostat.getOrDefault("overruletime", "").split(":");
|
||||||
|
int overruletime = 0;
|
||||||
|
if (overruletimeStrings.length == 2) {
|
||||||
|
overruletime = Integer.parseInt(overruletimeStrings[0]) * 60
|
||||||
|
+ Integer.parseInt(overruletimeStrings[1]);
|
||||||
|
}
|
||||||
|
int ecosave = parseIntOrThrow(thermostat.get("ecosave"));
|
||||||
|
|
||||||
|
int demand = (mode != 3) ? (setpoint > measured ? 1 : (setpoint < measured ? -1 : 0)) : 0;
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
"Niko Home Control: event execute thermostat {} with measured {}, setpoint {}, mode {}, overrule {}, overruletime {}, ecosave {}, demand {}",
|
||||||
|
id, measured, setpoint, mode, overrule, overruletime, ecosave, demand);
|
||||||
|
NhcThermostat t = thermostats.get(id);
|
||||||
|
if (t != null) {
|
||||||
|
t.updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand);
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
int measured = Integer.parseInt(thermostat.get("measured"));
|
|
||||||
int setpoint = Integer.parseInt(thermostat.get("setpoint"));
|
|
||||||
int mode = Integer.parseInt(thermostat.get("mode"));
|
|
||||||
int overrule = Integer.parseInt(thermostat.get("overrule"));
|
|
||||||
// overruletime received in "HH:MM" format
|
|
||||||
String[] overruletimeStrings = thermostat.get("overruletime").split(":");
|
|
||||||
int overruletime = 0;
|
|
||||||
if (overruletimeStrings.length == 2) {
|
|
||||||
overruletime = Integer.parseInt(overruletimeStrings[0]) * 60 + Integer.parseInt(overruletimeStrings[1]);
|
|
||||||
}
|
|
||||||
int ecosave = Integer.parseInt(thermostat.get("ecosave"));
|
|
||||||
|
|
||||||
int demand = (mode != 3) ? (setpoint > measured ? 1 : (setpoint < measured ? -1 : 0)) : 0;
|
|
||||||
|
|
||||||
logger.debug(
|
|
||||||
"Niko Home Control: event execute thermostat {} with measured {}, setpoint {}, mode {}, overrule {}, overruletime {}, ecosave {}, demand {}",
|
|
||||||
id, measured, setpoint, mode, overrule, overruletime, ecosave, demand);
|
|
||||||
thermostats.get(id).updateState(measured, setpoint, mode, overrule, overruletime, ecosave, demand);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void eventGetAlarms(Map<String, String> data) {
|
private void eventGetAlarms(Map<String, String> data) {
|
||||||
int type = Integer.parseInt(data.get("type"));
|
|
||||||
String alarmText = data.get("text");
|
String alarmText = data.get("text");
|
||||||
switch (type) {
|
switch (data.getOrDefault("type", "")) {
|
||||||
case 0:
|
case "0":
|
||||||
logger.debug("Niko Home Control: alarm - {}", alarmText);
|
logger.debug("Niko Home Control: alarm - {}", alarmText);
|
||||||
handler.alarmEvent(alarmText);
|
handler.alarmEvent(alarmText);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case "1":
|
||||||
logger.debug("Niko Home Control: notice - {}", alarmText);
|
logger.debug("Niko Home Control: notice - {}", alarmText);
|
||||||
handler.noticeEvent(alarmText);
|
handler.noticeEvent(alarmText);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.debug("Niko Home Control: unexpected message type {}", type);
|
logger.debug("Niko Home Control: unexpected message type {}", data.get("type"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -486,9 +486,12 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dimmerProperty.isPresent()) {
|
if (dimmerProperty.isPresent()) {
|
||||||
action.setState(Integer.parseInt(dimmerProperty.get().brightness));
|
String brightness = dimmerProperty.get().brightness;
|
||||||
logger.debug("Niko Home Control: setting action {} internally to {}", action.getId(),
|
if (brightness != null) {
|
||||||
dimmerProperty.get().brightness);
|
action.setState(Integer.parseInt(brightness));
|
||||||
|
logger.debug("Niko Home Control: setting action {} internally to {}", action.getId(),
|
||||||
|
dimmerProperty.get().brightness);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,15 +510,19 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
|
||||||
Optional<Boolean> overruleActiveProperty = deviceProperties.stream().map(p -> p.overruleActive)
|
Optional<Boolean> overruleActiveProperty = deviceProperties.stream().map(p -> p.overruleActive)
|
||||||
.filter(Objects::nonNull).map(t -> Boolean.parseBoolean(t)).findFirst();
|
.filter(Objects::nonNull).map(t -> Boolean.parseBoolean(t)).findFirst();
|
||||||
Optional<Integer> overruleSetpointProperty = deviceProperties.stream().map(p -> p.overruleSetpoint)
|
Optional<Integer> overruleSetpointProperty = deviceProperties.stream().map(p -> p.overruleSetpoint)
|
||||||
.filter(s -> !((s == null) || s.isEmpty())).map(t -> Math.round(Float.parseFloat(t) * 10)).findFirst();
|
.map(s -> (!((s == null) || s.isEmpty())) ? Math.round(Float.parseFloat(s) * 10) : null)
|
||||||
|
.filter(Objects::nonNull).findFirst();
|
||||||
Optional<Integer> overruleTimeProperty = deviceProperties.stream().map(p -> p.overruleTime)
|
Optional<Integer> overruleTimeProperty = deviceProperties.stream().map(p -> p.overruleTime)
|
||||||
.filter(s -> !((s == null) || s.isEmpty())).map(t -> Math.round(Float.parseFloat(t))).findFirst();
|
.map(s -> (!((s == null) || s.isEmpty())) ? Math.round(Float.parseFloat(s)) : null)
|
||||||
|
.filter(Objects::nonNull).findFirst();
|
||||||
Optional<Integer> setpointTemperatureProperty = deviceProperties.stream().map(p -> p.setpointTemperature)
|
Optional<Integer> setpointTemperatureProperty = deviceProperties.stream().map(p -> p.setpointTemperature)
|
||||||
.filter(s -> !((s == null) || s.isEmpty())).map(t -> Math.round(Float.parseFloat(t) * 10)).findFirst();
|
.map(s -> (!((s == null) || s.isEmpty())) ? Math.round(Float.parseFloat(s) * 10) : null)
|
||||||
Optional<Boolean> ecoSaveProperty = deviceProperties.stream().map(p -> p.ecoSave).filter(Objects::nonNull)
|
.filter(Objects::nonNull).findFirst();
|
||||||
.map(t -> Boolean.parseBoolean(t)).findFirst();
|
Optional<Boolean> ecoSaveProperty = deviceProperties.stream().map(p -> p.ecoSave)
|
||||||
|
.map(s -> s != null ? Boolean.parseBoolean(s) : null).filter(Objects::nonNull).findFirst();
|
||||||
Optional<Integer> ambientTemperatureProperty = deviceProperties.stream().map(p -> p.ambientTemperature)
|
Optional<Integer> ambientTemperatureProperty = deviceProperties.stream().map(p -> p.ambientTemperature)
|
||||||
.filter(s -> !(s == null || s.isEmpty())).map(t -> Math.round(Float.parseFloat(t) * 10)).findFirst();
|
.map(s -> (!((s == null) || s.isEmpty())) ? Math.round(Float.parseFloat(s) * 10) : null)
|
||||||
|
.filter(Objects::nonNull).findFirst();
|
||||||
Optional<@Nullable String> demandProperty = deviceProperties.stream().map(p -> p.demand)
|
Optional<@Nullable String> demandProperty = deviceProperties.stream().map(p -> p.demand)
|
||||||
.filter(Objects::nonNull).findFirst();
|
.filter(Objects::nonNull).findFirst();
|
||||||
Optional<@Nullable String> operationModeProperty = deviceProperties.stream().map(p -> p.operationMode)
|
Optional<@Nullable String> operationModeProperty = deviceProperties.stream().map(p -> p.operationMode)
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class ThermostatHandler extends BaseThingHandler {
|
||||||
updateState(BindingConstants.CHANNEL_OWD5_GROUPNAME, StringType.valueOf(thermostat.groupName));
|
updateState(BindingConstants.CHANNEL_OWD5_GROUPNAME, StringType.valueOf(thermostat.groupName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getRegulationMode(int regulationMode) {
|
private @Nullable String getRegulationMode(int regulationMode) {
|
||||||
return REGULATION_MODES.get(regulationMode);
|
return REGULATION_MODES.get(regulationMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,10 @@ public class SensorId {
|
||||||
* - characters are case-insensitive
|
* - characters are case-insensitive
|
||||||
* - hubs ("1F.xxxxxxxxxxxx/aux/") may be repeated
|
* - hubs ("1F.xxxxxxxxxxxx/aux/") may be repeated
|
||||||
*/
|
*/
|
||||||
public SensorId(String fullPath) {
|
public SensorId(@Nullable String fullPath) {
|
||||||
|
if (fullPath == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
Matcher matcher = SENSOR_ID_PATTERN.matcher(fullPath);
|
Matcher matcher = SENSOR_ID_PATTERN.matcher(fullPath);
|
||||||
if (matcher.matches() && matcher.groupCount() == 2) {
|
if (matcher.matches() && matcher.groupCount() == 2) {
|
||||||
path = matcher.group(1) == null ? "" : matcher.group(1);
|
path = matcher.group(1) == null ? "" : matcher.group(1);
|
||||||
|
|
|
@ -118,8 +118,8 @@ public class OwDiscoveryItem {
|
||||||
* @return ThingTypeUID if mapping successful
|
* @return ThingTypeUID if mapping successful
|
||||||
*/
|
*/
|
||||||
public ThingTypeUID getThingTypeUID() throws OwException {
|
public ThingTypeUID getThingTypeUID() throws OwException {
|
||||||
if (THING_TYPE_MAP.containsKey(sensorType)) {
|
ThingTypeUID thingTypeUID = THING_TYPE_MAP.get(sensorType);
|
||||||
thingTypeUID = THING_TYPE_MAP.get(sensorType);
|
if (thingTypeUID != null) {
|
||||||
return thingTypeUID;
|
return thingTypeUID;
|
||||||
} else {
|
} else {
|
||||||
throw new OwException(sensorType + " cannot be mapped to thing type");
|
throw new OwException(sensorType + " cannot be mapped to thing type");
|
||||||
|
|
|
@ -90,17 +90,20 @@ public class AdvancedMultisensorThingHandler extends OwBaseThingHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwRevision = Integer.valueOf(properties.get(PROPERTY_HW_REVISION));
|
hwRevision = Integer.valueOf(properties.getOrDefault(PROPERTY_HW_REVISION, "0"));
|
||||||
|
|
||||||
sensors.add(new DS2438(sensorId, this));
|
try {
|
||||||
sensors.add(new DS18x20(new SensorId(properties.get(PROPERTY_DS18B20)), this));
|
sensors.add(new DS2438(sensorId, this));
|
||||||
if (THING_TYPE_AMS.equals(thingType)) {
|
sensors.add(new DS18x20(new SensorId(properties.get(PROPERTY_DS18B20)), this));
|
||||||
sensors.add(new DS2438(new SensorId(properties.get(PROPERTY_DS2438)), this));
|
if (THING_TYPE_AMS.equals(thingType)) {
|
||||||
sensors.add(new DS2406_DS2413(new SensorId(properties.get(PROPERTY_DS2413)), this));
|
sensors.add(new DS2438(new SensorId(properties.get(PROPERTY_DS2438)), this));
|
||||||
digitalRefreshInterval = configuration.digitalRefresh * 1000;
|
sensors.add(new DS2406_DS2413(new SensorId(properties.get(PROPERTY_DS2413)), this));
|
||||||
digitalLastRefresh = 0;
|
digitalRefreshInterval = configuration.digitalRefresh * 1000;
|
||||||
|
digitalLastRefresh = 0;
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "properties invalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduler.execute(() -> {
|
scheduler.execute(() -> {
|
||||||
configureThingChannels();
|
configureThingChannels();
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.openweathermap.internal.connection;
|
package org.openhab.binding.openweathermap.internal.connection;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link OpenWeatherMapCommunicationException} is a communication exception for the connections to OpenWeatherMap
|
* The {@link OpenWeatherMapCommunicationException} is a communication exception for the connections to OpenWeatherMap
|
||||||
|
@ -37,7 +38,7 @@ public class OpenWeatherMapCommunicationException extends RuntimeException {
|
||||||
*
|
*
|
||||||
* @param message Detail message
|
* @param message Detail message
|
||||||
*/
|
*/
|
||||||
public OpenWeatherMapCommunicationException(String message) {
|
public OpenWeatherMapCommunicationException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class OpenWeatherMapCommunicationException extends RuntimeException {
|
||||||
*
|
*
|
||||||
* @param cause The cause
|
* @param cause The cause
|
||||||
*/
|
*/
|
||||||
public OpenWeatherMapCommunicationException(Throwable cause) {
|
public OpenWeatherMapCommunicationException(@Nullable Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ public class OpenWeatherMapCommunicationException extends RuntimeException {
|
||||||
* @param message Detail message
|
* @param message Detail message
|
||||||
* @param cause The cause
|
* @param cause The cause
|
||||||
*/
|
*/
|
||||||
public OpenWeatherMapCommunicationException(String message, Throwable cause) {
|
public OpenWeatherMapCommunicationException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.openweathermap.internal.connection;
|
package org.openhab.binding.openweathermap.internal.connection;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link OpenWeatherMapConfigurationException} is a configuration exception for the connections to OpenWeatherMap
|
* The {@link OpenWeatherMapConfigurationException} is a configuration exception for the connections to OpenWeatherMap
|
||||||
|
@ -37,7 +38,7 @@ public class OpenWeatherMapConfigurationException extends IllegalArgumentExcepti
|
||||||
*
|
*
|
||||||
* @param message Detail message
|
* @param message Detail message
|
||||||
*/
|
*/
|
||||||
public OpenWeatherMapConfigurationException(String message) {
|
public OpenWeatherMapConfigurationException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class OpenWeatherMapConfigurationException extends IllegalArgumentExcepti
|
||||||
*
|
*
|
||||||
* @param cause The cause
|
* @param cause The cause
|
||||||
*/
|
*/
|
||||||
public OpenWeatherMapConfigurationException(Throwable cause) {
|
public OpenWeatherMapConfigurationException(@Nullable Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ public class OpenWeatherMapConfigurationException extends IllegalArgumentExcepti
|
||||||
* @param message Detail message
|
* @param message Detail message
|
||||||
* @param cause The cause
|
* @param cause The cause
|
||||||
*/
|
*/
|
||||||
public OpenWeatherMapConfigurationException(String message, Throwable cause) {
|
public OpenWeatherMapConfigurationException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,7 +278,10 @@ public class OpenWeatherMapConnection {
|
||||||
.collect(joining("&", url + "?", ""));
|
.collect(joining("&", url + "?", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String encodeParam(String value) {
|
private String encodeParam(@Nullable String value) {
|
||||||
|
if (value == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
|
return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
|
|
@ -126,8 +126,9 @@ public class PJLinkDevice {
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
Socket socket = this.socket;
|
Socket socket = this.socket;
|
||||||
boolean connectionTooOld = false;
|
boolean connectionTooOld = false;
|
||||||
if (this.socketCreatedOn != null) {
|
Instant socketCreatedOn = this.socketCreatedOn;
|
||||||
long millisecondsSinceLastConnect = Duration.between(this.socketCreatedOn, now).toMillis();
|
if (socketCreatedOn != null) {
|
||||||
|
long millisecondsSinceLastConnect = Duration.between(socketCreatedOn, now).toMillis();
|
||||||
// according to the PJLink specification, the device closes the connection after 30s idle (without notice),
|
// according to the PJLink specification, the device closes the connection after 30s idle (without notice),
|
||||||
// so to be on the safe side we do not reuse sockets older than 20s
|
// so to be on the safe side we do not reuse sockets older than 20s
|
||||||
connectionTooOld = millisecondsSinceLastConnect > 20 * 1000;
|
connectionTooOld = millisecondsSinceLastConnect > 20 * 1000;
|
||||||
|
|
|
@ -280,6 +280,10 @@ public abstract class PLCCommonHandler extends BaseThingHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getBlockFromChannel(final @Nullable Channel channel) {
|
protected static String getBlockFromChannel(final @Nullable Channel channel) {
|
||||||
return channel == null ? NOT_SUPPORTED : channel.getProperties().get(BLOCK_PROPERTY);
|
if (channel == null) {
|
||||||
|
return NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
String block = channel.getProperties().get(BLOCK_PROPERTY);
|
||||||
|
return block == null ? NOT_SUPPORTED : block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,7 @@ public abstract class AbstractPlugwiseThingHandler extends BaseThingHandler impl
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean recentlySendConfigurationUpdate() {
|
protected boolean recentlySendConfigurationUpdate() {
|
||||||
|
LocalDateTime lastConfigurationUpdateSend = this.lastConfigurationUpdateSend;
|
||||||
return lastConfigurationUpdateSend != null
|
return lastConfigurationUpdateSend != null
|
||||||
&& LocalDateTime.now().minus(Duration.ofMillis(500)).isBefore(lastConfigurationUpdateSend);
|
&& LocalDateTime.now().minus(Duration.ofMillis(500)).isBefore(lastConfigurationUpdateSend);
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,10 +265,11 @@ public class Parser {
|
||||||
source.setMuted(properties.get("muted").equalsIgnoreCase("yes"));
|
source.setMuted(properties.get("muted").equalsIgnoreCase("yes"));
|
||||||
}
|
}
|
||||||
if (properties.containsKey("volume")) {
|
if (properties.containsKey("volume")) {
|
||||||
source.setVolume(Integer.valueOf(parseVolume(properties.get("volume"))));
|
source.setVolume(parseVolume(properties.get("volume")));
|
||||||
}
|
}
|
||||||
if (properties.containsKey("monitor_of")) {
|
String monitorOf = properties.get("monitor_of");
|
||||||
source.setMonitorOf(client.getSink(Integer.valueOf(properties.get("monitor_of"))));
|
if (monitorOf != null) {
|
||||||
|
source.setMonitorOf(client.getSink(Integer.valueOf(monitorOf)));
|
||||||
}
|
}
|
||||||
sources.add(source);
|
sources.add(source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,6 +152,10 @@ public class RadioThermostatConnector {
|
||||||
* @return a valid URL for the thermostat's JSON interface
|
* @return a valid URL for the thermostat's JSON interface
|
||||||
*/
|
*/
|
||||||
private String buildRequestURL(String resource) {
|
private String buildRequestURL(String resource) {
|
||||||
|
String hostName = this.hostName;
|
||||||
|
if (hostName == null) {
|
||||||
|
throw new IllegalStateException("hostname must not be null");
|
||||||
|
}
|
||||||
String urlStr = URL.replace("%hostName%", hostName);
|
String urlStr = URL.replace("%hostName%", hostName);
|
||||||
urlStr = urlStr.replace("%resource%", resource);
|
urlStr = urlStr.replace("%resource%", resource);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.openhab.binding.remoteopenhab.internal.exceptions;
|
package org.openhab.binding.remoteopenhab.internal.exceptions;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exceptions thrown by this binding.
|
* Exceptions thrown by this binding.
|
||||||
|
@ -23,15 +24,15 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class RemoteopenhabException extends Exception {
|
public class RemoteopenhabException extends Exception {
|
||||||
|
|
||||||
public RemoteopenhabException(String message) {
|
public RemoteopenhabException(@Nullable String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoteopenhabException(String message, Throwable cause) {
|
public RemoteopenhabException(@Nullable String message, @Nullable Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoteopenhabException(Throwable cause) {
|
public RemoteopenhabException(@Nullable Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ExpiringMap<T> {
|
||||||
values.put(now, newValue);
|
values.put(now, newValue);
|
||||||
Optional<Long> eldestKey = values.keySet().stream().filter(key -> key < now - eldestAge).findFirst();
|
Optional<Long> eldestKey = values.keySet().stream().filter(key -> key < now - eldestAge).findFirst();
|
||||||
if (eldestKey.isPresent()) {
|
if (eldestKey.isPresent()) {
|
||||||
agedValue = Optional.of(values.get(eldestKey.get()));
|
agedValue = Optional.ofNullable(values.get(eldestKey.get()));
|
||||||
values.entrySet().removeIf(map -> map.getKey() <= eldestKey.get());
|
values.entrySet().removeIf(map -> map.getKey() <= eldestKey.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newValue = DataConverters.convertCommandToIntValue(command, 0, 100,
|
newValue = DataConverters.convertCommandToIntValue(command, 0, 100,
|
||||||
Integer.valueOf(stateMap.get("CurrentVolume")));
|
Integer.valueOf(stateMap.getOrDefault("CurrentVolume", "")));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new NumberFormatException("Command '" + command + "' not supported");
|
throw new NumberFormatException("Command '" + command + "' not supported");
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newValue = DataConverters.convertCommandToIntValue(command, 0, 100,
|
newValue = DataConverters.convertCommandToIntValue(command, 0, 100,
|
||||||
Integer.valueOf(stateMap.get("CurrentBrightness")));
|
Integer.valueOf(stateMap.getOrDefault("CurrentBrightness", "")));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new NumberFormatException("Command '" + command + "' not supported");
|
throw new NumberFormatException("Command '" + command + "' not supported");
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newValue = DataConverters.convertCommandToIntValue(command, 0, 100,
|
newValue = DataConverters.convertCommandToIntValue(command, 0, 100,
|
||||||
Integer.valueOf(stateMap.get("CurrentContrast")));
|
Integer.valueOf(stateMap.getOrDefault("CurrentContrast", "")));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new NumberFormatException("Command '" + command + "' not supported");
|
throw new NumberFormatException("Command '" + command + "' not supported");
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newValue = DataConverters.convertCommandToIntValue(command, 0, 100,
|
newValue = DataConverters.convertCommandToIntValue(command, 0, 100,
|
||||||
Integer.valueOf(stateMap.get("CurrentSharpness")));
|
Integer.valueOf(stateMap.getOrDefault("CurrentSharpness", "")));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new NumberFormatException("Command '" + command + "' not supported");
|
throw new NumberFormatException("Command '" + command + "' not supported");
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ public class MediaRendererService implements UpnpIOParticipant, SamsungTvService
|
||||||
|
|
||||||
try {
|
try {
|
||||||
newValue = DataConverters.convertCommandToIntValue(command, 0, 4,
|
newValue = DataConverters.convertCommandToIntValue(command, 0, 4,
|
||||||
Integer.valueOf(stateMap.get("CurrentColorTemperature")));
|
Integer.valueOf(stateMap.getOrDefault("CurrentColorTemperature", "")));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new NumberFormatException("Command '" + command + "' not supported");
|
throw new NumberFormatException("Command '" + command + "' not supported");
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class ServiceFactory {
|
||||||
* @param serviceName Name of the service
|
* @param serviceName Name of the service
|
||||||
* @return Class of the service
|
* @return Class of the service
|
||||||
*/
|
*/
|
||||||
public static Class<? extends SamsungTvService> getClassByServiceName(String serviceName) {
|
public static @Nullable Class<? extends SamsungTvService> getClassByServiceName(String serviceName) {
|
||||||
return SERVICEMAP.get(serviceName);
|
return SERVICEMAP.get(serviceName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public class SatelEventLogActions implements ThingActions {
|
||||||
logger.debug("satel.readEvent called with input: index={}", index);
|
logger.debug("satel.readEvent called with input: index={}", index);
|
||||||
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
SatelEventLogHandler handler = this.handler;
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
handler.readEvent(index == null ? -1 : index.intValue()).ifPresent(event -> {
|
handler.readEvent(index == null ? -1 : index.intValue()).ifPresent(event -> {
|
||||||
result.put("index", event.getIndex());
|
result.put("index", event.getIndex());
|
||||||
|
|
|
@ -58,8 +58,8 @@ public abstract class SatelThingHandler extends BaseThingHandler implements Sate
|
||||||
if (bridge != null) {
|
if (bridge != null) {
|
||||||
final ThingHandler handler = bridge.getHandler();
|
final ThingHandler handler = bridge.getHandler();
|
||||||
if (handler != null && handler instanceof SatelBridgeHandler) {
|
if (handler != null && handler instanceof SatelBridgeHandler) {
|
||||||
|
((SatelBridgeHandler) handler).addEventListener(this);
|
||||||
this.bridgeHandler = (SatelBridgeHandler) handler;
|
this.bridgeHandler = (SatelBridgeHandler) handler;
|
||||||
this.bridgeHandler.addEventListener(this);
|
|
||||||
}
|
}
|
||||||
if (bridge.getStatus() == ThingStatus.ONLINE) {
|
if (bridge.getStatus() == ThingStatus.ONLINE) {
|
||||||
updateStatus(ThingStatus.ONLINE);
|
updateStatus(ThingStatus.ONLINE);
|
||||||
|
|
|
@ -351,8 +351,8 @@ public abstract class SatelModule extends EventDispatcher implements SatelEventL
|
||||||
private synchronized void disconnect(@Nullable String reason) {
|
private synchronized void disconnect(@Nullable String reason) {
|
||||||
// remove all pending commands from the queue
|
// remove all pending commands from the queue
|
||||||
// notifying about send failure
|
// notifying about send failure
|
||||||
while (!this.sendQueue.isEmpty()) {
|
SatelCommand cmd;
|
||||||
SatelCommand cmd = this.sendQueue.poll();
|
while ((cmd = this.sendQueue.poll()) != null) {
|
||||||
cmd.setState(State.FAILED);
|
cmd.setState(State.FAILED);
|
||||||
}
|
}
|
||||||
final CommunicationChannel channel = this.channel;
|
final CommunicationChannel channel = this.channel;
|
||||||
|
@ -503,13 +503,13 @@ public abstract class SatelModule extends EventDispatcher implements SatelEventL
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startCommunication() {
|
private void startCommunication() {
|
||||||
final Thread thread = this.thread;
|
Thread thread = this.thread;
|
||||||
if (thread != null && thread.isAlive()) {
|
if (thread != null && thread.isAlive()) {
|
||||||
logger.error("Start communication canceled: communication thread is still alive");
|
logger.error("Start communication canceled: communication thread is still alive");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// start new thread
|
// start new thread
|
||||||
this.thread = new Thread(new Runnable() {
|
thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.debug("Communication thread started");
|
logger.debug("Communication thread started");
|
||||||
|
@ -517,7 +517,8 @@ public abstract class SatelModule extends EventDispatcher implements SatelEventL
|
||||||
logger.debug("Communication thread stopped");
|
logger.debug("Communication thread stopped");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.thread.start();
|
thread.start();
|
||||||
|
this.thread = thread;
|
||||||
// if module is not initialized yet, send version command
|
// if module is not initialized yet, send version command
|
||||||
if (!SatelModule.this.isInitialized()) {
|
if (!SatelModule.this.isInitialized()) {
|
||||||
SatelModule.this.sendCommand(new IntegraVersionCommand());
|
SatelModule.this.sendCommand(new IntegraVersionCommand());
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ShellyApiException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public @Nullable String getMessage() {
|
||||||
return isEmpty() ? "" : nonNullString(super.getMessage());
|
return isEmpty() ? "" : nonNullString(super.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ public class ShellyCoIoTProtocol {
|
||||||
Double brightness = -1.0;
|
Double brightness = -1.0;
|
||||||
Double power = -1.0;
|
Double power = -1.0;
|
||||||
for (CoIotSensor update : allUpdates) {
|
for (CoIotSensor update : allUpdates) {
|
||||||
CoIotDescrSen d = fixDescription(sensorMap.get(update.id), blkMap);
|
CoIotDescrSen d = fixDescription(sensorMap.getOrDefault(update.id, new CoIotDescrSen()), blkMap);
|
||||||
if (!checkL.isEmpty() && !d.links.equals(checkL)) {
|
if (!checkL.isEmpty() && !d.links.equals(checkL)) {
|
||||||
// continue until we find the correct one
|
// continue until we find the correct one
|
||||||
continue;
|
continue;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue