From 02cf68b835aea5c61a77b648ce80f25b31d5450e Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sat, 2 Jul 2022 20:21:25 -0500 Subject: [PATCH 01/13] enhance: add thermostat channels to amazonechocontrol Signed-off-by: Daniel Campbell --- .../pom.xml | 25 ++++ .../internal/Connection.java | 110 +++++++++++++++--- .../discovery/SmartHomeDevicesDiscovery.java | 4 +- .../handler/SmartHomeDeviceHandler.java | 3 +- .../internal/smarthome/Constants.java | 34 ++++-- .../internal/smarthome/HandlerBase.java | 6 + .../smarthome/HandlerHumiditySensor.java | 104 +++++++++++++++++ .../smarthome/HandlerTemperatureSensor.java | 11 +- .../HandlerThermostatController.java | 89 +++++++++++++- .../OH-INF/i18n/amazonechocontrol.properties | 10 +- .../i18n/amazonechocontrol_de.properties | 6 + .../resources/OH-INF/thing/thing-types.xml | 25 ++++ 12 files changed, 393 insertions(+), 34 deletions(-) create mode 100644 bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java diff --git a/bundles/org.openhab.binding.amazonechocontrol/pom.xml b/bundles/org.openhab.binding.amazonechocontrol/pom.xml index 250b5e7b9ff8d..d93e61bb16632 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/pom.xml +++ b/bundles/org.openhab.binding.amazonechocontrol/pom.xml @@ -23,4 +23,29 @@ + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0 + + + enforce-java + + enforce + + + + + 1.6.0 + + + + + + + + + diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java index b950df3706aef..fb6c5c33394fa 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java @@ -32,6 +32,7 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -109,6 +110,7 @@ import org.openhab.binding.amazonechocontrol.internal.jsons.SmartHomeBaseDevice; import org.openhab.core.common.ThreadPoolManager; import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.types.StringType; import org.openhab.core.library.unit.SIUnits; import org.openhab.core.util.HexUtils; import org.slf4j.Logger; @@ -118,6 +120,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonElement; +import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import com.google.gson.JsonSyntaxException; @@ -1074,7 +1077,7 @@ public Map getSmartHomeDeviceStatesJson(Set) { - parameters.addProperty(property + ".value", ((QuantityType) value).floatValue()); - parameters.addProperty(property + ".scale", - ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" : "fahrenheit"); - } else if (value instanceof Boolean) { - parameters.addProperty(property, (boolean) value); - } else if (value instanceof String) { - parameters.addProperty(property, (String) value); - } else if (value instanceof Number) { - parameters.addProperty(property, (Number) value); - } else if (value instanceof Character) { - parameters.addProperty(property, (Character) value); - } else if (value instanceof JsonElement) { - parameters.add(property, (JsonElement) value); + if (action == "setThermostatMode") { + if (value instanceof StringType) { + parameters.addProperty(property + ".value", value.toString()); + } + } else if (action == "setTargetTemperature") { + if (property == "targetTemperature") { + if (value instanceof QuantityType) { + parameters.addProperty(property + ".value", ((QuantityType) value).floatValue()); + parameters.addProperty(property + ".scale", + ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" : "fahrenheit"); + } + } else { + Map devices = null; + try { + devices = getSmartHomeDeviceStatesJson(new HashSet<>(getSmarthomeDeviceList())); + } catch (URISyntaxException e) { + logger.error(e.toString()); + } + Object applianceId = "AAA_SonarCloudService_00QAbw7vzYhdndv3-Sirp40Zargm3orQ0tKQK9sIKbqIM6-rFm3KsAnOKWApPNqtmzGL6cOR30mQrIwEQtDA"; + JsonArray states = devices.get(applianceId); + for (JsonElement stateElement : states) { + JsonObject stateValue = new JsonObject(); + String stateJson = stateElement.getAsString(); + if (stateJson.startsWith("{") && stateJson.endsWith("}")) { + JsonObject state = Objects.requireNonNull(gson.fromJson(stateJson, JsonObject.class)); + String interfaceName = Objects.requireNonNullElse(state.get("namespace"), JsonNull.INSTANCE) + .getAsString(); + String name = Objects.requireNonNullElse(state.get("name"), JsonNull.INSTANCE) + .getAsString(); + if (interfaceName.equals("Alexa.ThermostatController")) { + if (name.equals("upperSetpoint")) { + stateValue = Objects.requireNonNullElse(state.get("value"), JsonNull.INSTANCE) + .getAsJsonObject(); + upperSetpoint = Objects + .requireNonNullElse(stateValue.get("value"), JsonNull.INSTANCE) + .getAsFloat(); + } else if (name.equals("lowerSetpoint")) { + stateValue = Objects.requireNonNullElse(state.get("value"), JsonNull.INSTANCE) + .getAsJsonObject(); + lowerSetpoint = Objects + .requireNonNullElse(stateValue.get("value"), JsonNull.INSTANCE) + .getAsFloat(); + } + if (lowerSetpoint > 60 && upperSetpoint < 85) { + break; + } + } + } + } + if (property == "lowerSetTemperature") { + if (value instanceof QuantityType) { + parameters.addProperty("upperSetTemperature.value", upperSetpoint); + parameters.addProperty("upperSetTemperature.scale", + ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" + : "fahrenheit"); + parameters.addProperty(property + ".value", ((QuantityType) value).floatValue()); + parameters.addProperty(property + ".scale", + ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" + : "fahrenheit"); + } + } else if (property == "upperSetTemperature") { + if (value instanceof QuantityType) { + parameters.addProperty(property + ".value", ((QuantityType) value).floatValue()); + parameters.addProperty(property + ".scale", + ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" + : "fahrenheit"); + parameters.addProperty("lowerSetTemperature.value", lowerSetpoint); + parameters.addProperty("lowerSetTemperature.scale", + ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" + : "fahrenheit"); + } + } + } + } else { + if (value instanceof QuantityType) { + parameters.addProperty(property + ".value", ((QuantityType) value).floatValue()); + parameters.addProperty(property + ".scale", + ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" : "fahrenheit"); + } else if (value instanceof Boolean) { + parameters.addProperty(property, (boolean) value); + } else if (value instanceof String) { + parameters.addProperty(property, (String) value); + } else if (value instanceof Number) { + parameters.addProperty(property, (Number) value); + } else if (value instanceof Character) { + parameters.addProperty(property, (Character) value); + } else if (value instanceof JsonElement) { + parameters.add(property, (JsonElement) value); + } } } controlRequest.add("parameters", parameters); diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java index 2ac945bc796f4..2f7c8ef242888 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/SmartHomeDevicesDiscovery.java @@ -49,7 +49,7 @@ @NonNullByDefault public class SmartHomeDevicesDiscovery extends AbstractDiscoveryService { private AccountHandler accountHandler; - private final Logger logger = LoggerFactory.getLogger(SmartHomeDevicesDiscovery.class); + private Logger logger = LoggerFactory.getLogger(SmartHomeDevicesDiscovery.class); private @Nullable ScheduledFuture startScanStateJob; private @Nullable Long activateTimeStamp; @@ -189,6 +189,8 @@ synchronized void setSmartHomeDevices(List deviceList) { deviceName = "Alexa Color Controller on " + shd.friendlyName; } else if (interfaces.contains("Alexa.PowerController")) { deviceName = "Alexa Plug on " + shd.friendlyName; + } else if (interfaces.contains("Alexa.ThermostatController")) { + deviceName = "Alexa Smart " + shd.friendlyName; } else { deviceName = "Unknown Device on " + shd.friendlyName; } diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java index 5cfda45db1bec..c676219d07674 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java @@ -70,7 +70,7 @@ */ @NonNullByDefault public class SmartHomeDeviceHandler extends BaseThingHandler { - private final Logger logger = LoggerFactory.getLogger(SmartHomeDeviceHandler.class); + private final static Logger logger = LoggerFactory.getLogger(SmartHomeDeviceHandler.class); private @Nullable SmartHomeBaseDevice smartHomeBaseDevice; private final Gson gson; @@ -347,7 +347,6 @@ public static Set getSupportedSmartHomeDevices(@Nullable SmartH if (shd.getCapabilities().stream().map(capability -> capability.interfaceName) .anyMatch(SUPPORTED_INTERFACES::contains)) { result.add(shd); - } } else { SmartHomeGroup shg = (SmartHomeGroup) baseDevice; diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/Constants.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/Constants.java index 874495bf2f814..dacec9f873acd 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/Constants.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/Constants.java @@ -26,23 +26,38 @@ */ @NonNullByDefault public class Constants { - public static final Map> HANDLER_FACTORY = Map.of( - HandlerPowerController.INTERFACE, HandlerPowerController::new, HandlerBrightnessController.INTERFACE, - HandlerBrightnessController::new, HandlerColorController.INTERFACE, HandlerColorController::new, - HandlerColorTemperatureController.INTERFACE, HandlerColorTemperatureController::new, - HandlerSecurityPanelController.INTERFACE, HandlerSecurityPanelController::new, - HandlerAcousticEventSensor.INTERFACE, HandlerAcousticEventSensor::new, HandlerTemperatureSensor.INTERFACE, - HandlerTemperatureSensor::new, HandlerThermostatController.INTERFACE, HandlerThermostatController::new, - HandlerPercentageController.INTERFACE, HandlerPercentageController::new, - HandlerPowerLevelController.INTERFACE, HandlerPowerLevelController::new); + public static final Map> HANDLER_FACTORY = Map.ofEntries( + Map.entry(HandlerPowerController.INTERFACE, HandlerPowerController::new), + Map.entry(HandlerBrightnessController.INTERFACE, HandlerBrightnessController::new), + Map.entry(HandlerColorController.INTERFACE, HandlerColorController::new), + Map.entry(HandlerColorTemperatureController.INTERFACE, HandlerColorTemperatureController::new), + Map.entry(HandlerSecurityPanelController.INTERFACE, HandlerSecurityPanelController::new), + Map.entry(HandlerAcousticEventSensor.INTERFACE, HandlerAcousticEventSensor::new), + Map.entry(HandlerTemperatureSensor.INTERFACE, HandlerTemperatureSensor::new), + Map.entry(HandlerThermostatController.INTERFACE, HandlerThermostatController::new), + Map.entry(HandlerPercentageController.INTERFACE, HandlerPercentageController::new), + Map.entry(HandlerPowerLevelController.INTERFACE, HandlerPowerLevelController::new), + Map.entry(HandlerHumiditySensor.INTERFACE, HandlerHumiditySensor::new)); public static final Set SUPPORTED_INTERFACES = HANDLER_FACTORY.keySet(); // channel types public static final ChannelTypeUID CHANNEL_TYPE_TEMPERATURE = new ChannelTypeUID( AmazonEchoControlBindingConstants.BINDING_ID, "temperature"); + public static final ChannelTypeUID CHANNEL_TYPE_HUMIDITY = new ChannelTypeUID( + AmazonEchoControlBindingConstants.BINDING_ID, "relativeHumidity"); public static final ChannelTypeUID CHANNEL_TYPE_TARGETSETPOINT = new ChannelTypeUID( AmazonEchoControlBindingConstants.BINDING_ID, "targetSetpoint"); + public static final ChannelTypeUID CHANNEL_TYPE_LOWERSETPOINT = new ChannelTypeUID( + AmazonEchoControlBindingConstants.BINDING_ID, "lowerSetpoint"); + public static final ChannelTypeUID CHANNEL_TYPE_UPPERSETPOINT = new ChannelTypeUID( + AmazonEchoControlBindingConstants.BINDING_ID, "upperSetpoint"); + public static final ChannelTypeUID CHANNEL_TYPE_THERMOSTATMODE = new ChannelTypeUID( + AmazonEchoControlBindingConstants.BINDING_ID, "thermostatMode"); + public static final ChannelTypeUID CHANNEL_TYPE_FAN_OPERATION = new ChannelTypeUID( + AmazonEchoControlBindingConstants.BINDING_ID, "fanOperation"); + public static final ChannelTypeUID CHANNEL_TYPE_COOLER_OPERATION = new ChannelTypeUID( + AmazonEchoControlBindingConstants.BINDING_ID, "coolerOperation"); // List of Item types public static final String ITEM_TYPE_SWITCH = "Switch"; @@ -50,6 +65,7 @@ public class Constants { public static final String ITEM_TYPE_STRING = "String"; public static final String ITEM_TYPE_NUMBER = "Number"; public static final String ITEM_TYPE_NUMBER_TEMPERATURE = "Number:Temperature"; + public static final String ITEM_TYPE_HUMIDITY = "Number:Dimensionless"; public static final String ITEM_TYPE_CONTACT = "Contact"; public static final String ITEM_TYPE_COLOR = "Color"; } diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerBase.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerBase.java index e95b0a469b5ec..6060807f7bcd7 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerBase.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerBase.java @@ -33,6 +33,8 @@ import org.openhab.core.types.Command; import org.openhab.core.types.State; import org.openhab.core.types.StateDescription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.gson.JsonObject; @@ -41,6 +43,9 @@ */ @NonNullByDefault public abstract class HandlerBase { + // Logger + private final Logger logger = LoggerFactory.getLogger(HandlerBase.class); + protected SmartHomeDeviceHandler smartHomeDeviceHandler; protected Map channels = new HashMap<>(); @@ -76,6 +81,7 @@ public Collection initialize(List capabilities if (properties != null) { List supported = Objects.requireNonNullElse(properties.supported, List.of()); + logger.trace(capability.toString() + " | " + supported.toString()); for (Property property : supported) { String name = property.name; if (name != null) { diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java new file mode 100644 index 0000000000000..fca1185ceae7a --- /dev/null +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2010-2022 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.amazonechocontrol.internal.smarthome; + +import static org.openhab.binding.amazonechocontrol.internal.smarthome.Constants.*; +import static org.openhab.core.library.unit.Units.*; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; + +import javax.measure.Unit; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.amazonechocontrol.internal.Connection; +import org.openhab.binding.amazonechocontrol.internal.handler.SmartHomeDeviceHandler; +import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeCapabilities.SmartHomeCapability; +import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.SmartHomeDevice; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.types.Command; +import org.openhab.core.types.State; +import org.openhab.core.types.StateDescription; +import org.openhab.core.types.UnDefType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.JsonObject; + +/** + * The {@link HandlerHumiditySensor} is responsible for the Alexa.HumiditySensorInterface + * + * @author Daniel Campbell - Initial contribution + */ +@NonNullByDefault +public class HandlerHumiditySensor extends HandlerBase { + // Logger + private final Logger logger = LoggerFactory.getLogger(HandlerHumiditySensor.class); + // Interface + public static final String INTERFACE = "Alexa.HumiditySensor"; + // Channel definitions + private static final ChannelInfo HUMIDITY = new ChannelInfo("relativeHumidity" /* propertyName */ , + "relativeHumidity" /* ChannelId */, CHANNEL_TYPE_HUMIDITY /* Channel Type */ , + ITEM_TYPE_HUMIDITY /* Item Type */); + + public HandlerHumiditySensor(SmartHomeDeviceHandler smartHomeDeviceHandler) { + super(smartHomeDeviceHandler); + } + + @Override + public String[] getSupportedInterface() { + return new String[] { INTERFACE }; + } + + @Override + protected ChannelInfo @Nullable [] findChannelInfos(SmartHomeCapability capability, String property) { + if (HUMIDITY.propertyName.equals(property)) { + return new ChannelInfo[] { HUMIDITY }; + } + return null; + } + + @Override + public void updateChannels(String interfaceName, List stateList, UpdateChannelResult result) { + for (JsonObject state : stateList) { + State humidityValue = null; + logger.debug("Updating " + interfaceName + " with state: " + state.toString()); + if (HUMIDITY.propertyName.equals(state.get("name").getAsString())) { + // For groups take the first + if (humidityValue == null) { + // humidityValue = state.get("value").getAsInt(); + humidityValue = getQuantityTypeState(state.get("value").getAsInt(), PERCENT); + updateState(HUMIDITY.channelId, humidityValue == null ? UnDefType.UNDEF : humidityValue); + } + } + } + } + + protected State getQuantityTypeState(@Nullable Number value, Unit unit) { + return (value == null) ? UnDefType.UNDEF : new QuantityType<>(value, unit); + } + + @Override + public boolean handleCommand(Connection connection, SmartHomeDevice shd, String entityId, + List capabilities, String channelId, Command command) throws IOException { + return false; + } + + @Override + public @Nullable StateDescription findStateDescription(String channelId, StateDescription originalStateDescription, + @Nullable Locale locale) { + return null; + } +} diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java index 3f87071905b5f..c985224718054 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java @@ -32,17 +32,21 @@ import org.openhab.core.types.Command; import org.openhab.core.types.StateDescription; import org.openhab.core.types.UnDefType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.gson.JsonObject; /** - * The {@link HandlerTemperatureSensor} is responsible for the Alexa.PowerControllerInterface + * The {@link HandlerTemperatureSensor} is responsible for the Alexa.TemperatureSensorInterface * * @author Lukas Knoeller - Initial contribution * @author Michael Geramb - Initial contribution */ @NonNullByDefault public class HandlerTemperatureSensor extends HandlerBase { + // Logger + private final Logger logger = LoggerFactory.getLogger(HandlerTemperatureSensor.class); // Interface public static final String INTERFACE = "Alexa.TemperatureSensor"; // Channel definitions @@ -69,8 +73,9 @@ public String[] getSupportedInterface() { @Override public void updateChannels(String interfaceName, List stateList, UpdateChannelResult result) { - QuantityType temperatureValue = null; for (JsonObject state : stateList) { + QuantityType temperatureValue = null; + logger.debug("Updating " + interfaceName + " with state: " + state.toString()); if (TEMPERATURE.propertyName.equals(state.get("name").getAsString())) { JsonObject value = state.get("value").getAsJsonObject(); // For groups take the first @@ -83,9 +88,9 @@ public void updateChannels(String interfaceName, List stateList, Upd temperatureValue = new QuantityType(temperature, ImperialUnits.FAHRENHEIT); } } + updateState(TEMPERATURE.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue); } } - updateState(TEMPERATURE.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue); } @Override diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java index 44fba494bc00e..c2112c49852d2 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java @@ -27,11 +27,14 @@ import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeCapabilities.SmartHomeCapability; import org.openhab.binding.amazonechocontrol.internal.jsons.JsonSmartHomeDevices.SmartHomeDevice; import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.types.StringType; import org.openhab.core.library.unit.ImperialUnits; import org.openhab.core.library.unit.SIUnits; import org.openhab.core.types.Command; import org.openhab.core.types.StateDescription; import org.openhab.core.types.UnDefType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.gson.JsonObject; @@ -42,12 +45,23 @@ */ @NonNullByDefault public class HandlerThermostatController extends HandlerBase { + // Logger + private final Logger logger = LoggerFactory.getLogger(HandlerThermostatController.class); // Interface public static final String INTERFACE = "Alexa.ThermostatController"; // Channel definitions private static final ChannelInfo TARGET_SETPOINT = new ChannelInfo("targetSetpoint" /* propertyName */ , "targetSetpoint" /* ChannelId */, CHANNEL_TYPE_TARGETSETPOINT /* Channel Type */ , ITEM_TYPE_NUMBER_TEMPERATURE /* Item Type */); + private static final ChannelInfo LOWER_SETPOINT = new ChannelInfo("lowerSetpoint" /* propertyName */ , + "lowerSetpoint" /* ChannelId */, CHANNEL_TYPE_LOWERSETPOINT /* Channel Type */ , + ITEM_TYPE_NUMBER_TEMPERATURE /* Item Type */); + private static final ChannelInfo UPPER_SETPOINT = new ChannelInfo("upperSetpoint" /* propertyName */ , + "upperSetpoint" /* ChannelId */, CHANNEL_TYPE_UPPERSETPOINT /* Channel Type */ , + ITEM_TYPE_NUMBER_TEMPERATURE /* Item Type */); + private static final ChannelInfo THERMOSTAT_MODE = new ChannelInfo("thermostatMode" /* propertyName */ , + "thermostatMode" /* ChannelId */, CHANNEL_TYPE_THERMOSTATMODE /* Channel Type */ , + ITEM_TYPE_STRING /* Item Type */); public HandlerThermostatController(SmartHomeDeviceHandler smartHomeDeviceHandler) { super(smartHomeDeviceHandler); @@ -63,17 +77,48 @@ public String[] getSupportedInterface() { if (TARGET_SETPOINT.propertyName.equals(property)) { return new ChannelInfo[] { TARGET_SETPOINT }; } + if (LOWER_SETPOINT.propertyName.equals(property)) { + return new ChannelInfo[] { LOWER_SETPOINT }; + } + if (UPPER_SETPOINT.propertyName.equals(property)) { + return new ChannelInfo[] { UPPER_SETPOINT }; + } + if (THERMOSTAT_MODE.propertyName.equals(property)) { + return new ChannelInfo[] { THERMOSTAT_MODE }; + } return null; } @Override public void updateChannels(String interfaceName, List stateList, UpdateChannelResult result) { - QuantityType temperatureValue = null; for (JsonObject state : stateList) { + QuantityType temperatureValue = null; + StringType operationValue = null; + logger.debug("Updating " + interfaceName + " with state: " + state.toString()); if (TARGET_SETPOINT.propertyName.equals(state.get("name").getAsString())) { - JsonObject value = state.get("value").getAsJsonObject(); // For groups take the first if (temperatureValue == null) { + JsonObject value = state.get("value").getAsJsonObject(); + float temperature = value.get("value").getAsFloat(); + String scale = value.get("scale").getAsString().toUpperCase(); + if ("CELSIUS".equals(scale)) { + temperatureValue = new QuantityType(temperature, SIUnits.CELSIUS); + } else { + temperatureValue = new QuantityType(temperature, ImperialUnits.FAHRENHEIT); + } + } + updateState(TARGET_SETPOINT.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue); + } + if (THERMOSTAT_MODE.propertyName.equals(state.get("name").getAsString())) { + // For groups take the first + String operation = state.get("value").getAsString().toUpperCase(); + operationValue = new StringType(operation); + updateState(THERMOSTAT_MODE.channelId, operationValue == null ? UnDefType.UNDEF : operationValue); + } + if (UPPER_SETPOINT.propertyName.equals(state.get("name").getAsString())) { + // For groups take the first + if (temperatureValue == null) { + JsonObject value = state.get("value").getAsJsonObject(); float temperature = value.get("value").getAsFloat(); String scale = value.get("scale").getAsString().toUpperCase(); if ("CELSIUS".equals(scale)) { @@ -82,9 +127,23 @@ public void updateChannels(String interfaceName, List stateList, Upd temperatureValue = new QuantityType(temperature, ImperialUnits.FAHRENHEIT); } } + updateState(UPPER_SETPOINT.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue); + } + if (LOWER_SETPOINT.propertyName.equals(state.get("name").getAsString())) { + // For groups take the first + if (temperatureValue == null) { + JsonObject value = state.get("value").getAsJsonObject(); + float temperature = value.get("value").getAsFloat(); + String scale = value.get("scale").getAsString().toUpperCase(); + if ("CELSIUS".equals(scale)) { + temperatureValue = new QuantityType(temperature, SIUnits.CELSIUS); + } else { + temperatureValue = new QuantityType(temperature, ImperialUnits.FAHRENHEIT); + } + } + updateState(LOWER_SETPOINT.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue); } } - updateState(TARGET_SETPOINT.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue); } @Override @@ -99,6 +158,30 @@ public boolean handleCommand(Connection connection, SmartHomeDevice shd, String } } } + if (channelId.equals(LOWER_SETPOINT.channelId)) { + if (containsCapabilityProperty(capabilities, LOWER_SETPOINT.propertyName)) { + if (command instanceof QuantityType) { + connection.smartHomeCommand(entityId, "setTargetTemperature", "lowerSetTemperature", command); + return true; + } + } + } + if (channelId.equals(UPPER_SETPOINT.channelId)) { + if (containsCapabilityProperty(capabilities, UPPER_SETPOINT.propertyName)) { + if (command instanceof QuantityType) { + connection.smartHomeCommand(entityId, "setTargetTemperature", "upperSetTemperature", command); + return true; + } + } + } + if (channelId.equals(THERMOSTAT_MODE.channelId)) { + if (containsCapabilityProperty(capabilities, THERMOSTAT_MODE.propertyName)) { + if (command instanceof StringType) { + connection.smartHomeCommand(entityId, "setThermostatMode", "thermostatMode", command); + return true; + } + } + } return false; } diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties index 1875688d70123..d98ae1d1482dc 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties @@ -60,7 +60,7 @@ channel-type.amazonechocontrol.amazonMusicPlayListIdLastUsed.description = Id of channel-type.amazonechocontrol.amazonMusicTrackId.label = Amazon Music Track Id channel-type.amazonechocontrol.amazonMusicTrackId.description = Id of the amazon music track channel-type.amazonechocontrol.announcement.label = Announcement -channel-type.amazonechocontrol.announcement.description = Display the announcement message on the display (Write only). See in the tutorial section of the binding description to learn how it's possible to set the title and turn off the sound. +channel-type.amazonechocontrol.announcement.description = Display the announcement message on the display (Write only). See in the tutorial section of the binding description to learn how its possible to set the title and turn off the sound. channel-type.amazonechocontrol.armState.label = ARM State channel-type.amazonechocontrol.armState.description = ARM State channel-type.amazonechocontrol.ascendingAlarm.label = Ascending Alarm @@ -163,10 +163,18 @@ channel-type.amazonechocontrol.subtitle1.label = Subtitle 1 channel-type.amazonechocontrol.subtitle1.description = Subtitle 1 channel-type.amazonechocontrol.subtitle2.label = Subtitle 2 channel-type.amazonechocontrol.subtitle2.description = Subtitle 2 +channel-type.amazonechocontrol.relativeHumidty.label = Humidity +channel-type.amazonechocontrol.relativeHumidty.description = Humidity channel-type.amazonechocontrol.targetSetpoint.label = Target Setpoint channel-type.amazonechocontrol.targetSetpoint.description = Target Setpoint +channel-type.amazonechocontrol.upperSetpoint.label = Upper Setpoint +channel-type.amazonechocontrol.upperSetpoint.description = Upper Setpoint +channel-type.amazonechocontrol.lowerSetpoint.label = Lower Setpoint +channel-type.amazonechocontrol.lowerSetpoint.description = Lower Setpoint channel-type.amazonechocontrol.temperature.label = Temperature channel-type.amazonechocontrol.temperature.description = Temperature +channel-type.amazonechocontrol.thermostatMode.label = Thermostat Mode +channel-type.amazonechocontrol.thermostatMode.description = Thermostat Mode channel-type.amazonechocontrol.textCommand.label = TextCommand channel-type.amazonechocontrol.textCommand.description = Run a command (Write only). The command can run like a spoken command. channel-type.amazonechocontrol.textToSpeech.label = Speak diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol_de.properties b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol_de.properties index 1a50b4b088947..88441c5f66153 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol_de.properties +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol_de.properties @@ -163,8 +163,14 @@ channel-type.amazonechocontrol.subtitle1.label = Untertitel 1 channel-type.amazonechocontrol.subtitle1.description = Untertitel 1 channel-type.amazonechocontrol.subtitle2.label = Untertitel 2 channel-type.amazonechocontrol.subtitle2.description = Untertitel 2 +channel-type.amazonechocontrol.relativeHumidty.label = Feuchtigkeit +channel-type.amazonechocontrol.relativeHumidty.description = Feuchtigkeit channel-type.amazonechocontrol.targetSetpoint.label = Zieleinstellung channel-type.amazonechocontrol.targetSetpoint.description = Zieleinstellung +channel-type.amazonechocontrol.upperSetpoint.label = Oberen Sollwert +channel-type.amazonechocontrol.upperSetpoint.description = Oberen Sollwert +channel-type.amazonechocontrol.lowerSetpoint.label = Unteren Sollwert +channel-type.amazonechocontrol.lowerSetpoint.description = Unteren Sollwert channel-type.amazonechocontrol.temperature.label = Temperatur channel-type.amazonechocontrol.temperature.description = Temperatur channel-type.amazonechocontrol.textCommand.label = Befehl diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml index 20601205a7a24..05df162defb06 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml @@ -634,6 +634,13 @@ Temperature + + + Number:Dimensionless + + Humidity + + Number:Temperature @@ -641,4 +648,22 @@ Target Setpoint + + Number:Temperature + + Upper Setpoint + + + + Number:Temperature + + Lower Setpoint + + + + String + + Thermostat Mode + + From fa1254ca8b2bc3efe3ee425f5bad45babd598e7b Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sat, 2 Jul 2022 20:26:09 -0500 Subject: [PATCH 02/13] revert: pom.xml Signed-off-by: Daniel Campbell --- .../pom.xml | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/pom.xml b/bundles/org.openhab.binding.amazonechocontrol/pom.xml index d93e61bb16632..250b5e7b9ff8d 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/pom.xml +++ b/bundles/org.openhab.binding.amazonechocontrol/pom.xml @@ -23,29 +23,4 @@ - - - - org.apache.maven.plugins - maven-enforcer-plugin - 3.0.0 - - - enforce-java - - enforce - - - - - 1.6.0 - - - - - - - - - From 45f1bf91e8299f731683c42250624745a1a8e6a6 Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sat, 2 Jul 2022 20:55:13 -0500 Subject: [PATCH 03/13] enhance: update readme Signed-off-by: Daniel Campbell --- bundles/org.openhab.binding.amazonechocontrol/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bundles/org.openhab.binding.amazonechocontrol/README.md b/bundles/org.openhab.binding.amazonechocontrol/README.md index 6d1979d13580c..bae1f8f5834f5 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/README.md +++ b/bundles/org.openhab.binding.amazonechocontrol/README.md @@ -27,6 +27,7 @@ It provides features to control and view the current state of echo devices: - change the equalizer settings - get information about the next alarm, reminder and timer - send a message to the echo devices +- control alexa smart thermostat It also provides features to control devices connected to your echo: @@ -58,6 +59,7 @@ Some ideas what you can do in your home by using rules and other openHAB control - Change the equalizer settings depending on the bluetooth connection - Turn on a light on your alexa alarm time - Activate or deactivate the Alexa Guard with presence detection +- Adjust thermostat setPoint and mode With the possibility to control your lights you could do: @@ -452,6 +454,11 @@ The channels of the smarthome devices will be generated at runtime. Check in the | glassBreakDetectionState | Contact | R | smartHomeDevice | Glass break detection alarm | smokeAlarmDetectionState | Contact | R | smartHomeDevice | Smoke detection alarm | temperature | Number | R | smartHomeDevice | Temperature +| targetSetpoint | Number | R/W | smartHomeDevice | Thermostat target setpoint +| upperSetpoint | Number | R/W | smartHomeDevice | Thermostat upper setpoint (AUTO) +| lowerSetpoint | Number | R/W | smartHomeDevice | Thermostat lower setpoint (AUTO) +| relativeHumidity | Number | R | smartHomeDevice | Thermostat humidity +| thermostatMode | String | R/W | smartHomeDevice | Thermostat operation mode ### Example From 85dced06d2250c4d5b5f8b8d549edbcd09ac5fbe Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sat, 2 Jul 2022 22:46:37 -0500 Subject: [PATCH 04/13] fix: maven code corrections Signed-off-by: Daniel Campbell --- .../amazonechocontrol/internal/Connection.java | 12 ++++++------ .../internal/smarthome/HandlerBase.java | 2 +- .../internal/smarthome/HandlerHumiditySensor.java | 2 +- .../internal/smarthome/HandlerTemperatureSensor.java | 2 +- .../smarthome/HandlerThermostatController.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java index fb6c5c33394fa..6dd0c67aeacd3 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java @@ -1178,12 +1178,12 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr JsonObject parameters = new JsonObject(); parameters.addProperty("action", action); if (property != null) { - if (action == "setThermostatMode") { + if (action.equals("setThermostatMode")) { if (value instanceof StringType) { parameters.addProperty(property + ".value", value.toString()); } - } else if (action == "setTargetTemperature") { - if (property == "targetTemperature") { + } else if (action.equals("setTargetTemperature")) { + if (property.equals("targetTemperature")) { if (value instanceof QuantityType) { parameters.addProperty(property + ".value", ((QuantityType) value).floatValue()); parameters.addProperty(property + ".scale", @@ -1194,7 +1194,7 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr try { devices = getSmartHomeDeviceStatesJson(new HashSet<>(getSmarthomeDeviceList())); } catch (URISyntaxException e) { - logger.error(e.toString()); + logger.error("{}", e.toString()); } Object applianceId = "AAA_SonarCloudService_00QAbw7vzYhdndv3-Sirp40Zargm3orQ0tKQK9sIKbqIM6-rFm3KsAnOKWApPNqtmzGL6cOR30mQrIwEQtDA"; JsonArray states = devices.get(applianceId); @@ -1227,7 +1227,7 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr } } } - if (property == "lowerSetTemperature") { + if (property.equals("lowerSetTemperature")) { if (value instanceof QuantityType) { parameters.addProperty("upperSetTemperature.value", upperSetpoint); parameters.addProperty("upperSetTemperature.scale", @@ -1238,7 +1238,7 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" : "fahrenheit"); } - } else if (property == "upperSetTemperature") { + } else if (property.equals("upperSetTemperature")) { if (value instanceof QuantityType) { parameters.addProperty(property + ".value", ((QuantityType) value).floatValue()); parameters.addProperty(property + ".scale", diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerBase.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerBase.java index 6060807f7bcd7..ddbc2b212838b 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerBase.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerBase.java @@ -81,7 +81,7 @@ public Collection initialize(List capabilities if (properties != null) { List supported = Objects.requireNonNullElse(properties.supported, List.of()); - logger.trace(capability.toString() + " | " + supported.toString()); + logger.trace("{} | {}", capability.toString(), supported.toString()); for (Property property : supported) { String name = property.name; if (name != null) { diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java index fca1185ceae7a..6fee9d5268346 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java @@ -74,7 +74,7 @@ public String[] getSupportedInterface() { public void updateChannels(String interfaceName, List stateList, UpdateChannelResult result) { for (JsonObject state : stateList) { State humidityValue = null; - logger.debug("Updating " + interfaceName + " with state: " + state.toString()); + logger.debug("Updating {} with state: {}", interfaceName, state.toString()); if (HUMIDITY.propertyName.equals(state.get("name").getAsString())) { // For groups take the first if (humidityValue == null) { diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java index c985224718054..abddc4dcc4148 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java @@ -75,7 +75,7 @@ public String[] getSupportedInterface() { public void updateChannels(String interfaceName, List stateList, UpdateChannelResult result) { for (JsonObject state : stateList) { QuantityType temperatureValue = null; - logger.debug("Updating " + interfaceName + " with state: " + state.toString()); + logger.debug("Updating {} with state: {}", interfaceName, state.toString()); if (TEMPERATURE.propertyName.equals(state.get("name").getAsString())) { JsonObject value = state.get("value").getAsJsonObject(); // For groups take the first diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java index c2112c49852d2..03b1d2fc64a8b 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java @@ -94,7 +94,7 @@ public void updateChannels(String interfaceName, List stateList, Upd for (JsonObject state : stateList) { QuantityType temperatureValue = null; StringType operationValue = null; - logger.debug("Updating " + interfaceName + " with state: " + state.toString()); + logger.debug("Updating {} with state: {}", interfaceName, state.toString()); if (TARGET_SETPOINT.propertyName.equals(state.get("name").getAsString())) { // For groups take the first if (temperatureValue == null) { From 8ea965e171e45fafe652ea82483e59548fbc7bfd Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sat, 2 Jul 2022 23:34:55 -0500 Subject: [PATCH 05/13] fix: cleaned up maven warnings Signed-off-by: Daniel Campbell --- .../pom.xml | 25 +++++++++++++++++++ .../internal/AccountServlet.java | 16 ++++++------ .../internal/BindingServlet.java | 2 +- .../internal/Connection.java | 20 +++++++-------- .../internal/WebSocketConnection.java | 6 +++-- .../discovery/AmazonEchoDiscovery.java | 8 +++--- .../internal/handler/EchoHandler.java | 10 ++++---- .../smarthome/HandlerHumiditySensor.java | 7 ++---- .../smarthome/HandlerTemperatureSensor.java | 14 +++++------ 9 files changed, 65 insertions(+), 43 deletions(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/pom.xml b/bundles/org.openhab.binding.amazonechocontrol/pom.xml index 250b5e7b9ff8d..d93e61bb16632 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/pom.xml +++ b/bundles/org.openhab.binding.amazonechocontrol/pom.xml @@ -23,4 +23,29 @@ + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0 + + + enforce-java + + enforce + + + + + 1.6.0 + + + + + + + + + diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java index ce006aea10497..cc2974ca0bd58 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/AccountServlet.java @@ -145,7 +145,7 @@ void doVerb(String verb, @Nullable HttpServletRequest req, @Nullable HttpServlet } Connection connection = this.account.findConnection(); - if (connection != null && uri.equals("/changedomain")) { + if (connection != null && "/changedomain".equals(uri)) { Map map = req.getParameterMap(); String[] domainArray = map.get("domain"); if (domainArray == null) { @@ -199,7 +199,7 @@ void doVerb(String verb, @Nullable HttpServletRequest req, @Nullable HttpServlet postDataBuilder.append(name); postDataBuilder.append('='); String value = ""; - if (name.equals("failedSignInCount")) { + if ("failedSignInCount".equals(name)) { value = "ape:AA=="; } else { String[] strings = map.get(name); @@ -277,29 +277,29 @@ protected void doGet(@Nullable HttpServletRequest req, @Nullable HttpServletResp if (connection != null && connection.verifyLogin()) { // handle commands - if (baseUrl.equals("/logout") || baseUrl.equals("/logout/")) { + if ("/logout".equals(baseUrl) || "/logout/".equals(baseUrl)) { this.connectionToInitialize = reCreateConnection(); this.account.setConnection(null); resp.sendRedirect(this.servletUrl); return; } // handle commands - if (baseUrl.equals("/newdevice") || baseUrl.equals("/newdevice/")) { + if ("/newdevice".equals(baseUrl) || "/newdevice/".equals(baseUrl)) { this.connectionToInitialize = new Connection(null, this.gson); this.account.setConnection(null); resp.sendRedirect(this.servletUrl); return; } - if (baseUrl.equals("/devices") || baseUrl.equals("/devices/")) { + if ("/devices".equals(baseUrl) || "/devices/".equals(baseUrl)) { handleDevices(resp, connection); return; } - if (baseUrl.equals("/changeDomain") || baseUrl.equals("/changeDomain/")) { + if ("/changeDomain".equals(baseUrl) || "/changeDomain/".equals(baseUrl)) { handleChangeDomain(resp, connection); return; } - if (baseUrl.equals("/ids") || baseUrl.equals("/ids/")) { + if ("/ids".equals(baseUrl) || "/ids/".equals(baseUrl)) { String serialNumber = getQueryMap(queryString).get("serialNumber"); Device device = account.findDeviceJson(serialNumber); if (device != null) { @@ -318,7 +318,7 @@ protected void doGet(@Nullable HttpServletRequest req, @Nullable HttpServletResp this.connectionToInitialize = connection; } - if (!uri.equals("/")) { + if (!"/".equals(uri)) { String newUri = req.getServletPath() + "/"; resp.sendRedirect(newUri); return; diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/BindingServlet.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/BindingServlet.java index 69a671d47a542..6ec223e70799c 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/BindingServlet.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/BindingServlet.java @@ -97,7 +97,7 @@ protected void doGet(@Nullable HttpServletRequest req, @Nullable HttpServletResp } logger.debug("doGet {}", uri); - if (!uri.equals("/")) { + if (!"/".equals(uri)) { String newUri = req.getServletPath() + "/"; resp.sendRedirect(newUri); return; diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java index 6dd0c67aeacd3..bf5a201a6fb83 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java @@ -647,7 +647,7 @@ public HttpsURLConnection makeRequest(String verb, String url, @Nullable String for (Map.Entry<@Nullable String, List> header : headerFields.entrySet()) { String key = header.getKey(); if (key != null && !key.isEmpty()) { - if (key.equalsIgnoreCase("Set-Cookie")) { + if ("Set-Cookie".equalsIgnoreCase(key)) { // store cookie for (String cookieHeader : header.getValue()) { if (!cookieHeader.isEmpty()) { @@ -658,7 +658,7 @@ public HttpsURLConnection makeRequest(String verb, String url, @Nullable String } } } - if (key.equalsIgnoreCase("Location")) { + if ("Location".equalsIgnoreCase(key)) { // get redirect location location = header.getValue().get(0); if (!location.isEmpty()) { @@ -1178,12 +1178,12 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr JsonObject parameters = new JsonObject(); parameters.addProperty("action", action); if (property != null) { - if (action.equals("setThermostatMode")) { + if ("setThermostatMode".equals(action)) { if (value instanceof StringType) { parameters.addProperty(property + ".value", value.toString()); } - } else if (action.equals("setTargetTemperature")) { - if (property.equals("targetTemperature")) { + } else if ("setTargetTemperature".equals(action)) { + if ("targetTemperature".equals(property)) { if (value instanceof QuantityType) { parameters.addProperty(property + ".value", ((QuantityType) value).floatValue()); parameters.addProperty(property + ".scale", @@ -1207,14 +1207,14 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr .getAsString(); String name = Objects.requireNonNullElse(state.get("name"), JsonNull.INSTANCE) .getAsString(); - if (interfaceName.equals("Alexa.ThermostatController")) { - if (name.equals("upperSetpoint")) { + if ("Alexa.ThermostatController".equals(interfaceName)) { + if ("upperSetpoint".equals(name)) { stateValue = Objects.requireNonNullElse(state.get("value"), JsonNull.INSTANCE) .getAsJsonObject(); upperSetpoint = Objects .requireNonNullElse(stateValue.get("value"), JsonNull.INSTANCE) .getAsFloat(); - } else if (name.equals("lowerSetpoint")) { + } else if ("lowerSetpoint".equals(name)) { stateValue = Objects.requireNonNullElse(state.get("value"), JsonNull.INSTANCE) .getAsJsonObject(); lowerSetpoint = Objects @@ -1227,7 +1227,7 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr } } } - if (property.equals("lowerSetTemperature")) { + if ("lowerSetTemperature".equals(property)) { if (value instanceof QuantityType) { parameters.addProperty("upperSetTemperature.value", upperSetpoint); parameters.addProperty("upperSetTemperature.scale", @@ -1238,7 +1238,7 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" : "fahrenheit"); } - } else if (property.equals("upperSetTemperature")) { + } else if ("upperSetTemperature".equals(property)) { if (value instanceof QuantityType) { parameters.addProperty(property + ".value", ((QuantityType) value).floatValue()); parameters.addProperty(property + ".scale", diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java index 399ea52a04d53..dc5d5df1ad504 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java @@ -58,6 +58,7 @@ public class WebSocketConnection { private final Logger logger = LoggerFactory.getLogger(WebSocketConnection.class); private final Gson gson = new Gson(); + private final org.eclipse.jetty.client.HttpClient httpClient; private final WebSocketClient webSocketClient; private final IWebSocketCommandHandler webSocketCommandHandler; private final AmazonEchoControlWebSocket amazonEchoControlWebSocket; @@ -73,10 +74,11 @@ public WebSocketConnection(String amazonSite, List sessionCookies, IWebSocketCommandHandler webSocketCommandHandler) throws IOException { this.webSocketCommandHandler = webSocketCommandHandler; amazonEchoControlWebSocket = new AmazonEchoControlWebSocket(); - webSocketClient = new WebSocketClient(new SslContextFactory.Client()); + httpClient = new org.eclipse.jetty.client.HttpClient(new SslContextFactory.Client()); + webSocketClient = new WebSocketClient(httpClient); try { String host; - if (amazonSite.equalsIgnoreCase("amazon.com")) { + if ("amazon.com".equalsIgnoreCase(amazonSite)) { host = "dp-gw-na-js." + amazonSite; } else { host = "dp-gw-na." + amazonSite; diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/AmazonEchoDiscovery.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/AmazonEchoDiscovery.java index 13a2bceccec8f..073a1061f1db9 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/AmazonEchoDiscovery.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/discovery/AmazonEchoDiscovery.java @@ -139,13 +139,13 @@ synchronized void setDevices(List deviceList) { String deviceFamily = device.deviceFamily; if (deviceFamily != null) { ThingTypeUID thingTypeId; - if (deviceFamily.equals("ECHO")) { + if ("ECHO".equals(deviceFamily)) { thingTypeId = THING_TYPE_ECHO; - } else if (deviceFamily.equals("ROOK")) { + } else if ("ROOK".equals(deviceFamily)) { thingTypeId = THING_TYPE_ECHO_SPOT; - } else if (deviceFamily.equals("KNIGHT")) { + } else if ("KNIGHT".equals(deviceFamily)) { thingTypeId = THING_TYPE_ECHO_SHOW; - } else if (deviceFamily.equals("WHA")) { + } else if ("WHA".equals(deviceFamily)) { thingTypeId = THING_TYPE_ECHO_WHA; } else { logger.debug("Unknown thing type '{}'", deviceFamily); diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java index 110a5b2cc760a..59952ace83b50 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/EchoHandler.java @@ -783,11 +783,11 @@ private void updateNotificationTimerState() { if (currentNotification != null) { String type = currentNotification.type; if (type != null) { - if (type.equals("Reminder")) { + if ("Reminder".equals(type)) { updateState(CHANNEL_REMIND, StringType.EMPTY); updateRemind = false; } - if (type.equals("Alarm")) { + if ("Alarm".equals(type)) { updateState(CHANNEL_PLAY_ALARM_SOUND, StringType.EMPTY); updateAlarm = false; } @@ -864,10 +864,10 @@ public void updateState(AccountHandler accountHandler, @Nullable Device device, if (musicProviderId != null) { musicProviderId = musicProviderId.toUpperCase(); - if (musicProviderId.equals("AMAZON MUSIC")) { + if ("AMAZON MUSIC".equals(musicProviderId)) { musicProviderId = "AMAZON_MUSIC"; } - if (musicProviderId.equals("CLOUD_PLAYER")) { + if ("CLOUD_PLAYER".equals(musicProviderId)) { musicProviderId = "AMAZON_MUSIC"; } if (musicProviderId.startsWith("TUNEIN")) { @@ -876,7 +876,7 @@ public void updateState(AccountHandler accountHandler, @Nullable Device device, if (musicProviderId.startsWith("IHEARTRADIO")) { musicProviderId = "I_HEART_RADIO"; } - if (musicProviderId.equals("APPLE") && musicProviderId.contains("MUSIC")) { + if ("APPLE".equals(musicProviderId) && musicProviderId.contains("MUSIC")) { musicProviderId = "APPLE_MUSIC"; } } diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java index 6fee9d5268346..6576b550f5270 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerHumiditySensor.java @@ -77,11 +77,8 @@ public void updateChannels(String interfaceName, List stateList, Upd logger.debug("Updating {} with state: {}", interfaceName, state.toString()); if (HUMIDITY.propertyName.equals(state.get("name").getAsString())) { // For groups take the first - if (humidityValue == null) { - // humidityValue = state.get("value").getAsInt(); - humidityValue = getQuantityTypeState(state.get("value").getAsInt(), PERCENT); - updateState(HUMIDITY.channelId, humidityValue == null ? UnDefType.UNDEF : humidityValue); - } + humidityValue = getQuantityTypeState(state.get("value").getAsInt(), PERCENT); + updateState(HUMIDITY.channelId, humidityValue == null ? UnDefType.UNDEF : humidityValue); } } } diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java index abddc4dcc4148..748bd1e096e79 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java @@ -79,14 +79,12 @@ public void updateChannels(String interfaceName, List stateList, Upd if (TEMPERATURE.propertyName.equals(state.get("name").getAsString())) { JsonObject value = state.get("value").getAsJsonObject(); // For groups take the first - if (temperatureValue == null) { - float temperature = value.get("value").getAsFloat(); - String scale = value.get("scale").getAsString(); - if ("CELSIUS".equals(scale)) { - temperatureValue = new QuantityType(temperature, SIUnits.CELSIUS); - } else { - temperatureValue = new QuantityType(temperature, ImperialUnits.FAHRENHEIT); - } + float temperature = value.get("value").getAsFloat(); + String scale = value.get("scale").getAsString(); + if ("CELSIUS".equals(scale)) { + temperatureValue = new QuantityType(temperature, SIUnits.CELSIUS); + } else { + temperatureValue = new QuantityType(temperature, ImperialUnits.FAHRENHEIT); } updateState(TEMPERATURE.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue); } From 7f568b4dad1c6a46fdb57a1a7897dedb2f2cbb41 Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sun, 3 Jul 2022 14:38:52 -0500 Subject: [PATCH 06/13] revert: pom.xml Signed-off-by: Daniel Campbell --- .../pom.xml | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/pom.xml b/bundles/org.openhab.binding.amazonechocontrol/pom.xml index d93e61bb16632..250b5e7b9ff8d 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/pom.xml +++ b/bundles/org.openhab.binding.amazonechocontrol/pom.xml @@ -23,29 +23,4 @@ - - - - org.apache.maven.plugins - maven-enforcer-plugin - 3.0.0 - - - enforce-java - - enforce - - - - - 1.6.0 - - - - - - - - - From 7bfac6e0d9c8574c3bab386827b1156d33241a81 Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sat, 23 Jul 2022 00:05:03 -0500 Subject: [PATCH 07/13] fix: PR suggested changes Signed-off-by: Daniel Campbell --- .../README.md | 40 +++++++++---------- .../internal/Connection.java | 21 +++++----- .../internal/WebSocketConnection.java | 4 +- .../handler/SmartHomeDeviceHandler.java | 2 +- .../smarthome/HandlerTemperatureSensor.java | 18 +++++---- .../HandlerThermostatController.java | 5 +-- .../OH-INF/i18n/amazonechocontrol.properties | 2 +- .../i18n/amazonechocontrol_de.properties | 6 --- .../resources/OH-INF/thing/thing-types.xml | 15 +++++++ 9 files changed, 63 insertions(+), 50 deletions(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/README.md b/bundles/org.openhab.binding.amazonechocontrol/README.md index bae1f8f5834f5..a2428e6202f8d 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/README.md +++ b/bundles/org.openhab.binding.amazonechocontrol/README.md @@ -59,7 +59,7 @@ Some ideas what you can do in your home by using rules and other openHAB control - Change the equalizer settings depending on the bluetooth connection - Turn on a light on your alexa alarm time - Activate or deactivate the Alexa Guard with presence detection -- Adjust thermostat setPoint and mode +- Adjust thermostat setpoint and mode With the possibility to control your lights you could do: @@ -440,25 +440,25 @@ The only possibility to find out the id is by using the discover function in the The channels of the smarthome devices will be generated at runtime. Check in the UI thing configurations, which channels are created. | Channel Type ID | Item Type | Access Mode | Thing Type | Description -|--------------------------|-----------|-------------|-------------------------------|------------------------------------------------------------------------------------------ -| powerState | Switch | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows and changes the state (ON/OFF) of your device -| brightness | Dimmer | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows and changes the brightness of your lamp -| color | Color | R | smartHomeDevice, smartHomeDeviceGroup | Shows the color of your light -| colorName | String | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows and changes the color name of your light (groups are not able to show their color) -| colorTemperatureName | String | R/W | smartHomeDevice, smartHomeDeviceGroup | White temperatures name of your lights (groups are not able to show their color) -| armState | String | R/W | smartHomeDevice, smartHomeDeviceGroup | State of your alarm guard. Options: ARMED_AWAY, ARMED_STAY, ARMED_NIGHT, DISARMED (groups are not able to show their state) -| burglaryAlarm | Contact | R | smartHomeDevice | Burglary alarm -| carbonMonoxideAlarm | Contact | R | smartHomeDevice | Carbon monoxide detection alarm -| fireAlarm | Contact | R | smartHomeDevice | Fire alarm -| waterAlarm | Contact | R | smartHomeDevice | Water alarm -| glassBreakDetectionState | Contact | R | smartHomeDevice | Glass break detection alarm -| smokeAlarmDetectionState | Contact | R | smartHomeDevice | Smoke detection alarm -| temperature | Number | R | smartHomeDevice | Temperature -| targetSetpoint | Number | R/W | smartHomeDevice | Thermostat target setpoint -| upperSetpoint | Number | R/W | smartHomeDevice | Thermostat upper setpoint (AUTO) -| lowerSetpoint | Number | R/W | smartHomeDevice | Thermostat lower setpoint (AUTO) -| relativeHumidity | Number | R | smartHomeDevice | Thermostat humidity -| thermostatMode | String | R/W | smartHomeDevice | Thermostat operation mode +|--------------------------|----------------------|-------------|-------------------------------|------------------------------------------------------------------------------------------ +| powerState | Switch | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows and changes the state (ON/OFF) of your device +| brightness | Dimmer | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows and changes the brightness of your lamp +| color | Color | R | smartHomeDevice, smartHomeDeviceGroup | Shows the color of your light +| colorName | String | R/W | smartHomeDevice, smartHomeDeviceGroup | Shows and changes the color name of your light (groups are not able to show their color) +| colorTemperatureName | String | R/W | smartHomeDevice, smartHomeDeviceGroup | White temperatures name of your lights (groups are not able to show their color) +| armState | String | R/W | smartHomeDevice, smartHomeDeviceGroup | State of your alarm guard. Options: ARMED_AWAY, ARMED_STAY, ARMED_NIGHT, DISARMED (groups are not able to show their state) +| burglaryAlarm | Contact | R | smartHomeDevice | Burglary alarm +| carbonMonoxideAlarm | Contact | R | smartHomeDevice | Carbon monoxide detection alarm +| fireAlarm | Contact | R | smartHomeDevice | Fire alarm +| waterAlarm | Contact | R | smartHomeDevice | Water alarm +| glassBreakDetectionState | Contact | R | smartHomeDevice | Glass break detection alarm +| smokeAlarmDetectionState | Contact | R | smartHomeDevice | Smoke detection alarm +| temperature | Number:Temperature | R | smartHomeDevice | Temperature +| targetSetpoint | Number:Temperature | R/W | smartHomeDevice | Thermostat target setpoint +| upperSetpoint | Number:Temperature | R/W | smartHomeDevice | Thermostat upper setpoint (AUTO) +| lowerSetpoint | Number:Temperature | R/W | smartHomeDevice | Thermostat lower setpoint (AUTO) +| relativeHumidity | Number:Dimensionless | R | smartHomeDevice | Thermostat humidity +| thermostatMode | String | R/W | smartHomeDevice | Thermostat operation mode ### Example diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java index bf5a201a6fb83..feecce01640b3 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java @@ -37,6 +37,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Objects; import java.util.Random; import java.util.Scanner; @@ -1167,8 +1168,8 @@ public void smartHomeCommand(String entityId, String action) throws IOException, public void smartHomeCommand(String entityId, String action, @Nullable String property, @Nullable Object value) throws IOException, InterruptedException { String url = alexaServer + "/api/phoenix/state"; - Float lowerSetpoint = Float.valueOf(60); - Float upperSetpoint = Float.valueOf(85); + Float lowerSetpoint = null; + Float upperSetpoint = null; JsonObject json = new JsonObject(); JsonArray controlRequests = new JsonArray(); @@ -1190,14 +1191,19 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr ((QuantityType) value).getUnit().equals(SIUnits.CELSIUS) ? "celsius" : "fahrenheit"); } } else { + // Get current upper and lower setpoints to build command syntax Map devices = null; try { - devices = getSmartHomeDeviceStatesJson(new HashSet<>(getSmarthomeDeviceList())); + List deviceList = getSmarthomeDeviceList().stream().filter( + device -> "AAA_SonarCloudService_00QAbw7vzYhdndv3-Sirp40Zargm3orQ0tKQK9sIKbqIM6-rFm3KsAnOKWApPNqtmzGL6cOR30mQrIwEQtDA" + .equals(device.findId())) + .collect(Collectors.toList()); + devices = getSmartHomeDeviceStatesJson(new HashSet<>(deviceList)); } catch (URISyntaxException e) { - logger.error("{}", e.toString()); + logger.debug("{}", e.toString()); } - Object applianceId = "AAA_SonarCloudService_00QAbw7vzYhdndv3-Sirp40Zargm3orQ0tKQK9sIKbqIM6-rFm3KsAnOKWApPNqtmzGL6cOR30mQrIwEQtDA"; - JsonArray states = devices.get(applianceId); + Entry entry = devices.entrySet().iterator().next(); + JsonArray states = entry.getValue(); for (JsonElement stateElement : states) { JsonObject stateValue = new JsonObject(); String stateJson = stateElement.getAsString(); @@ -1221,9 +1227,6 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr .requireNonNullElse(stateValue.get("value"), JsonNull.INSTANCE) .getAsFloat(); } - if (lowerSetpoint > 60 && upperSetpoint < 85) { - break; - } } } } diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java index dc5d5df1ad504..872dc40fd48e2 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/WebSocketConnection.java @@ -30,6 +30,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; @@ -58,7 +59,6 @@ public class WebSocketConnection { private final Logger logger = LoggerFactory.getLogger(WebSocketConnection.class); private final Gson gson = new Gson(); - private final org.eclipse.jetty.client.HttpClient httpClient; private final WebSocketClient webSocketClient; private final IWebSocketCommandHandler webSocketCommandHandler; private final AmazonEchoControlWebSocket amazonEchoControlWebSocket; @@ -74,7 +74,7 @@ public WebSocketConnection(String amazonSite, List sessionCookies, IWebSocketCommandHandler webSocketCommandHandler) throws IOException { this.webSocketCommandHandler = webSocketCommandHandler; amazonEchoControlWebSocket = new AmazonEchoControlWebSocket(); - httpClient = new org.eclipse.jetty.client.HttpClient(new SslContextFactory.Client()); + HttpClient httpClient = new HttpClient(new SslContextFactory.Client()); webSocketClient = new WebSocketClient(httpClient); try { String host; diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java index c676219d07674..6eb054499410e 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/handler/SmartHomeDeviceHandler.java @@ -70,7 +70,7 @@ */ @NonNullByDefault public class SmartHomeDeviceHandler extends BaseThingHandler { - private final static Logger logger = LoggerFactory.getLogger(SmartHomeDeviceHandler.class); + private final Logger logger = LoggerFactory.getLogger(SmartHomeDeviceHandler.class); private @Nullable SmartHomeBaseDevice smartHomeBaseDevice; private final Gson gson; diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java index 748bd1e096e79..a24c7115d1101 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerTemperatureSensor.java @@ -73,22 +73,24 @@ public String[] getSupportedInterface() { @Override public void updateChannels(String interfaceName, List stateList, UpdateChannelResult result) { + QuantityType temperatureValue = null; for (JsonObject state : stateList) { - QuantityType temperatureValue = null; logger.debug("Updating {} with state: {}", interfaceName, state.toString()); if (TEMPERATURE.propertyName.equals(state.get("name").getAsString())) { JsonObject value = state.get("value").getAsJsonObject(); // For groups take the first - float temperature = value.get("value").getAsFloat(); - String scale = value.get("scale").getAsString(); - if ("CELSIUS".equals(scale)) { - temperatureValue = new QuantityType(temperature, SIUnits.CELSIUS); - } else { - temperatureValue = new QuantityType(temperature, ImperialUnits.FAHRENHEIT); + if (temperatureValue == null) { + float temperature = value.get("value").getAsFloat(); + String scale = value.get("scale").getAsString(); + if ("CELSIUS".equals(scale)) { + temperatureValue = new QuantityType(temperature, SIUnits.CELSIUS); + } else { + temperatureValue = new QuantityType(temperature, ImperialUnits.FAHRENHEIT); + } } - updateState(TEMPERATURE.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue); } } + updateState(TEMPERATURE.channelId, temperatureValue == null ? UnDefType.UNDEF : temperatureValue); } @Override diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java index 03b1d2fc64a8b..033d7c07afd97 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/smarthome/HandlerThermostatController.java @@ -93,7 +93,6 @@ public String[] getSupportedInterface() { public void updateChannels(String interfaceName, List stateList, UpdateChannelResult result) { for (JsonObject state : stateList) { QuantityType temperatureValue = null; - StringType operationValue = null; logger.debug("Updating {} with state: {}", interfaceName, state.toString()); if (TARGET_SETPOINT.propertyName.equals(state.get("name").getAsString())) { // For groups take the first @@ -112,8 +111,8 @@ public void updateChannels(String interfaceName, List stateList, Upd if (THERMOSTAT_MODE.propertyName.equals(state.get("name").getAsString())) { // For groups take the first String operation = state.get("value").getAsString().toUpperCase(); - operationValue = new StringType(operation); - updateState(THERMOSTAT_MODE.channelId, operationValue == null ? UnDefType.UNDEF : operationValue); + StringType operationValue = new StringType(operation); + updateState(THERMOSTAT_MODE.channelId, operationValue); } if (UPPER_SETPOINT.propertyName.equals(state.get("name").getAsString())) { // For groups take the first diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties index d98ae1d1482dc..10d754f2eaa0e 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties @@ -60,7 +60,7 @@ channel-type.amazonechocontrol.amazonMusicPlayListIdLastUsed.description = Id of channel-type.amazonechocontrol.amazonMusicTrackId.label = Amazon Music Track Id channel-type.amazonechocontrol.amazonMusicTrackId.description = Id of the amazon music track channel-type.amazonechocontrol.announcement.label = Announcement -channel-type.amazonechocontrol.announcement.description = Display the announcement message on the display (Write only). See in the tutorial section of the binding description to learn how its possible to set the title and turn off the sound. +channel-type.amazonechocontrol.announcement.description = Display the announcement message on the display (Write only). See in the tutorial section of the binding description to learn how it's possible to set the title and turn off the sound. channel-type.amazonechocontrol.armState.label = ARM State channel-type.amazonechocontrol.armState.description = ARM State channel-type.amazonechocontrol.ascendingAlarm.label = Ascending Alarm diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol_de.properties b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol_de.properties index 88441c5f66153..1a50b4b088947 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol_de.properties +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol_de.properties @@ -163,14 +163,8 @@ channel-type.amazonechocontrol.subtitle1.label = Untertitel 1 channel-type.amazonechocontrol.subtitle1.description = Untertitel 1 channel-type.amazonechocontrol.subtitle2.label = Untertitel 2 channel-type.amazonechocontrol.subtitle2.description = Untertitel 2 -channel-type.amazonechocontrol.relativeHumidty.label = Feuchtigkeit -channel-type.amazonechocontrol.relativeHumidty.description = Feuchtigkeit channel-type.amazonechocontrol.targetSetpoint.label = Zieleinstellung channel-type.amazonechocontrol.targetSetpoint.description = Zieleinstellung -channel-type.amazonechocontrol.upperSetpoint.label = Oberen Sollwert -channel-type.amazonechocontrol.upperSetpoint.description = Oberen Sollwert -channel-type.amazonechocontrol.lowerSetpoint.label = Unteren Sollwert -channel-type.amazonechocontrol.lowerSetpoint.description = Unteren Sollwert channel-type.amazonechocontrol.temperature.label = Temperatur channel-type.amazonechocontrol.temperature.description = Temperatur channel-type.amazonechocontrol.textCommand.label = Befehl diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml index 05df162defb06..92f01948486ad 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml @@ -639,6 +639,11 @@ Number:Dimensionless Humidity + Humidity + + Measurement + Temperature + @@ -652,12 +657,22 @@ Number:Temperature Upper Setpoint + Temperature + + Setpoint + Temperature + Number:Temperature Lower Setpoint + Temperature + + Setpoint + Temperature + From 3ac62efc4c3fa7941e55cd3612813581eeafe689 Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sun, 24 Jul 2022 22:59:55 -0500 Subject: [PATCH 08/13] fix: PR additional suggested changes Signed-off-by: Daniel Campbell --- .../amazonechocontrol/internal/Connection.java | 8 ++++---- .../internal/jsons/JsonSmartHomeDevices.java | 5 +++++ .../internal/jsons/JsonSmartHomeGroups.java | 13 +++++++++++++ .../internal/jsons/SmartHomeBaseDevice.java | 2 ++ .../src/main/resources/OH-INF/thing/thing-types.xml | 2 +- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java index feecce01640b3..e868e24cbaceb 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/Connection.java @@ -12,6 +12,8 @@ */ package org.openhab.binding.amazonechocontrol.internal; +import static org.openhab.binding.amazonechocontrol.internal.smarthome.Constants.*; + import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; @@ -1194,10 +1196,8 @@ public void smartHomeCommand(String entityId, String action, @Nullable String pr // Get current upper and lower setpoints to build command syntax Map devices = null; try { - List deviceList = getSmarthomeDeviceList().stream().filter( - device -> "AAA_SonarCloudService_00QAbw7vzYhdndv3-Sirp40Zargm3orQ0tKQK9sIKbqIM6-rFm3KsAnOKWApPNqtmzGL6cOR30mQrIwEQtDA" - .equals(device.findId())) - .collect(Collectors.toList()); + List deviceList = getSmarthomeDeviceList().stream() + .filter(device -> entityId.equals(device.findEntityId())).collect(Collectors.toList()); devices = getSmartHomeDeviceStatesJson(new HashSet<>(deviceList)); } catch (URISyntaxException e) { logger.debug("{}", e.toString()); diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonSmartHomeDevices.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonSmartHomeDevices.java index fcc53623d8fa6..a02ef015cc316 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonSmartHomeDevices.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonSmartHomeDevices.java @@ -55,6 +55,11 @@ public List getCapabilities() { return applianceId; } + @Override + public @Nullable String findEntityId() { + return entityId; + } + @Override public boolean isGroup() { return false; diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonSmartHomeGroups.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonSmartHomeGroups.java index 4fa6dbea98479..6ed6eada82944 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonSmartHomeGroups.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/JsonSmartHomeGroups.java @@ -39,6 +39,19 @@ public static class SmartHomeGroup implements SmartHomeBaseDevice { return value; } + @Override + public @Nullable String findEntityId() { + SmartHomeGroupIdentifier applianceGroupIdentifier = this.applianceGroupIdentifier; + if (applianceGroupIdentifier == null) { + return null; + } + String value = applianceGroupIdentifier.value; + if (value == null) { + return null; + } + return value; + } + @Override public boolean isGroup() { return true; diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/SmartHomeBaseDevice.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/SmartHomeBaseDevice.java index 1533a06d6a621..c68fdd6308d93 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/SmartHomeBaseDevice.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/SmartHomeBaseDevice.java @@ -25,5 +25,7 @@ public interface SmartHomeBaseDevice { @Nullable String findId(); + String findEntityId(); + boolean isGroup(); } diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml index 92f01948486ad..8e3a374cafea6 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/thing/thing-types.xml @@ -638,7 +638,7 @@ Number:Dimensionless - Humidity + Relative humidity measured by the thermostat. Humidity Measurement From f9662c2b12e50fa5054b6b455916e0930237f393 Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sun, 24 Jul 2022 23:15:29 -0500 Subject: [PATCH 09/13] fix: Nullable constraint in SmartHomeBaseDevice Signed-off-by: Daniel Campbell --- .../amazonechocontrol/internal/jsons/SmartHomeBaseDevice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/SmartHomeBaseDevice.java b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/SmartHomeBaseDevice.java index c68fdd6308d93..4a6ed46f8725c 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/SmartHomeBaseDevice.java +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/java/org/openhab/binding/amazonechocontrol/internal/jsons/SmartHomeBaseDevice.java @@ -25,6 +25,7 @@ public interface SmartHomeBaseDevice { @Nullable String findId(); + @Nullable String findEntityId(); boolean isGroup(); From fd2e06bc406579dbc8ae7a8a71370defd21573db Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Tue, 26 Jul 2022 23:20:23 -0500 Subject: [PATCH 10/13] fix: properties humidity description Signed-off-by: Daniel Campbell --- .../src/main/resources/OH-INF/i18n/amazonechocontrol.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties index 10d754f2eaa0e..2f258b0c29622 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties @@ -164,7 +164,7 @@ channel-type.amazonechocontrol.subtitle1.description = Subtitle 1 channel-type.amazonechocontrol.subtitle2.label = Subtitle 2 channel-type.amazonechocontrol.subtitle2.description = Subtitle 2 channel-type.amazonechocontrol.relativeHumidty.label = Humidity -channel-type.amazonechocontrol.relativeHumidty.description = Humidity +channel-type.amazonechocontrol.relativeHumidty.description = Relative humidity measured by the thermostat. channel-type.amazonechocontrol.targetSetpoint.label = Target Setpoint channel-type.amazonechocontrol.targetSetpoint.description = Target Setpoint channel-type.amazonechocontrol.upperSetpoint.label = Upper Setpoint From 846956034c62e57e528882996fc4f08803ad9ae1 Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Thu, 28 Jul 2022 12:58:03 -0500 Subject: [PATCH 11/13] fix: generate default translations Signed-off-by: Daniel Campbell --- .../OH-INF/i18n/amazonechocontrol.properties | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties index 2f258b0c29622..0dd289befeacf 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties @@ -101,6 +101,8 @@ channel-type.amazonechocontrol.lastVoiceCommand.label = Last Voice Command channel-type.amazonechocontrol.lastVoiceCommand.description = Last voice command spoken to the device. Writing to the channel starts voice output. channel-type.amazonechocontrol.loop.label = Loop channel-type.amazonechocontrol.loop.description = Loop +channel-type.amazonechocontrol.lowerSetpoint.label = Lower Setpoint +channel-type.amazonechocontrol.lowerSetpoint.description = Lower Setpoint channel-type.amazonechocontrol.mediaLength.label = Media Length channel-type.amazonechocontrol.mediaLength.description = Media length channel-type.amazonechocontrol.mediaProgress.label = Media Progress @@ -139,6 +141,8 @@ channel-type.amazonechocontrol.radio.label = TuneIn Radio channel-type.amazonechocontrol.radio.description = Radio turned on channel-type.amazonechocontrol.radioStationId.label = TuneIn Radio Station Id channel-type.amazonechocontrol.radioStationId.description = Id of the radio station +channel-type.amazonechocontrol.relativeHumidity.label = Humidity +channel-type.amazonechocontrol.relativeHumidity.description = Relative humidity measured by the thermostat. channel-type.amazonechocontrol.remind.label = Remind channel-type.amazonechocontrol.remind.description = Speak the reminder and send a notification to the Alexa app channel-type.amazonechocontrol.save.label = Save @@ -163,27 +167,28 @@ channel-type.amazonechocontrol.subtitle1.label = Subtitle 1 channel-type.amazonechocontrol.subtitle1.description = Subtitle 1 channel-type.amazonechocontrol.subtitle2.label = Subtitle 2 channel-type.amazonechocontrol.subtitle2.description = Subtitle 2 -channel-type.amazonechocontrol.relativeHumidty.label = Humidity -channel-type.amazonechocontrol.relativeHumidty.description = Relative humidity measured by the thermostat. channel-type.amazonechocontrol.targetSetpoint.label = Target Setpoint channel-type.amazonechocontrol.targetSetpoint.description = Target Setpoint -channel-type.amazonechocontrol.upperSetpoint.label = Upper Setpoint -channel-type.amazonechocontrol.upperSetpoint.description = Upper Setpoint -channel-type.amazonechocontrol.lowerSetpoint.label = Lower Setpoint -channel-type.amazonechocontrol.lowerSetpoint.description = Lower Setpoint channel-type.amazonechocontrol.temperature.label = Temperature channel-type.amazonechocontrol.temperature.description = Temperature -channel-type.amazonechocontrol.thermostatMode.label = Thermostat Mode -channel-type.amazonechocontrol.thermostatMode.description = Thermostat Mode channel-type.amazonechocontrol.textCommand.label = TextCommand channel-type.amazonechocontrol.textCommand.description = Run a command (Write only). The command can run like a spoken command. channel-type.amazonechocontrol.textToSpeech.label = Speak channel-type.amazonechocontrol.textToSpeech.description = Speak the text (Write only). It is possible to use plain text or SSML: I want to tell you a secret.I am not a real human..Can you believe it? channel-type.amazonechocontrol.textToSpeechVolume.label = Speak Volume channel-type.amazonechocontrol.textToSpeechVolume.description = Volume of the Speak channel. If 0, the current volume will be used. +channel-type.amazonechocontrol.thermostatMode.label = Thermostat Mode +channel-type.amazonechocontrol.thermostatMode.description = Thermostat Mode channel-type.amazonechocontrol.title.label = Title channel-type.amazonechocontrol.title.description = Title +channel-type.amazonechocontrol.upperSetpoint.label = Upper Setpoint +channel-type.amazonechocontrol.upperSetpoint.description = Upper Setpoint channel-type.amazonechocontrol.volume.label = Volume channel-type.amazonechocontrol.volume.description = Volume of the sound channel-type.amazonechocontrol.waterAlarm.label = Water Alarm channel-type.amazonechocontrol.waterAlarm.description = Water Alarm + +# channel types + +channel-type.amazonechocontrol.relativeHumidty.label = Humidity +channel-type.amazonechocontrol.relativeHumidty.description = Relative humidity measured by the thermostat. From ba398c67effa5f994116171d9232312fc5cfce58 Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sun, 31 Jul 2022 23:04:52 -0500 Subject: [PATCH 12/13] fix: remove typo from properties file Signed-off-by: Daniel Campbell --- .../resources/OH-INF/i18n/amazonechocontrol.properties | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties index 0dd289befeacf..340514712f0bd 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties @@ -186,9 +186,4 @@ channel-type.amazonechocontrol.upperSetpoint.description = Upper Setpoint channel-type.amazonechocontrol.volume.label = Volume channel-type.amazonechocontrol.volume.description = Volume of the sound channel-type.amazonechocontrol.waterAlarm.label = Water Alarm -channel-type.amazonechocontrol.waterAlarm.description = Water Alarm - -# channel types - -channel-type.amazonechocontrol.relativeHumidty.label = Humidity -channel-type.amazonechocontrol.relativeHumidty.description = Relative humidity measured by the thermostat. +channel-type.amazonechocontrol.waterAlarm.description = Water Alarm \ No newline at end of file From d7bf87ea2eed89c9fd7614b58c8af80a41c78a79 Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Sun, 31 Jul 2022 23:10:02 -0500 Subject: [PATCH 13/13] fix: remove typo from properties file Signed-off-by: Daniel Campbell --- .../src/main/resources/OH-INF/i18n/amazonechocontrol.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties index 340514712f0bd..dba47615fedf6 100644 --- a/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties +++ b/bundles/org.openhab.binding.amazonechocontrol/src/main/resources/OH-INF/i18n/amazonechocontrol.properties @@ -186,4 +186,4 @@ channel-type.amazonechocontrol.upperSetpoint.description = Upper Setpoint channel-type.amazonechocontrol.volume.label = Volume channel-type.amazonechocontrol.volume.description = Volume of the sound channel-type.amazonechocontrol.waterAlarm.label = Water Alarm -channel-type.amazonechocontrol.waterAlarm.description = Water Alarm \ No newline at end of file +channel-type.amazonechocontrol.waterAlarm.description = Water Alarm