diff --git a/bundles/action/org.openhab.action.ecobee/.classpath b/bundles/action/org.openhab.action.ecobee/.classpath new file mode 100644 index 00000000000..6d224cd3d0d --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/bundles/action/org.openhab.action.ecobee/.project b/bundles/action/org.openhab.action.ecobee/.project new file mode 100644 index 00000000000..6f771c069bd --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/.project @@ -0,0 +1,33 @@ + + + org.openhab.action.ecobee + This is the ${binding-name} action bundle of the open Home Automation Bus (openHAB) + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.ds.core.builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/bundles/action/org.openhab.action.ecobee/META-INF/MANIFEST.MF b/bundles/action/org.openhab.action.ecobee/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..0cafb7d54c2 --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/META-INF/MANIFEST.MF @@ -0,0 +1,28 @@ +Manifest-Version: 1.0 +Private-Package: org.openhab.action.ecobee.internal +Ignore-Package: org.openhab.action.ecobee.internal +Bundle-License: http://www.eclipse.org/legal/epl-v10.html +Bundle-Name: openHAB Ecobee Action +Bundle-SymbolicName: org.openhab.action.ecobee +Bundle-Vendor: openHAB.org +Bundle-Version: 1.8.0.qualifier +Bundle-Activator: org.openhab.action.ecobee.internal.EcobeeActivator +Bundle-ManifestVersion: 2 +Bundle-Description: This is the Ecobee action of the open Home Aut + omation Bus (openHAB) +Import-Package: org.openhab.binding.ecobee, + org.openhab.binding.ecobee.messages, + org.openhab.core.items, + org.openhab.core.library.items, + org.openhab.core.library.types, + org.openhab.core.scriptengine.action, + org.openhab.core.types, + org.osgi.framework, + org.osgi.service.cm, + org.osgi.service.component, + org.slf4j +Bundle-DocURL: http://www.openhab.org +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Service-Component: OSGI-INF/action.xml +Bundle-ClassPath: . +Bundle-ActivationPolicy: lazy diff --git a/bundles/action/org.openhab.action.ecobee/OSGI-INF/action.xml b/bundles/action/org.openhab.action.ecobee/OSGI-INF/action.xml new file mode 100644 index 00000000000..85dd43531ca --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/OSGI-INF/action.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/bundles/action/org.openhab.action.ecobee/README.md b/bundles/action/org.openhab.action.ecobee/README.md new file mode 100644 index 00000000000..57cb003eeb7 --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/README.md @@ -0,0 +1,50 @@ +# Documentation for the Ecobee Action Bundle + +## Introduction +This bundle exposes openHAB Rule extensions to be used with the [Ecobee Binding](https://github.com/openhab/openhab/wiki/Ecobee-Binding). + +It exposes the ability to call [Ecobee API functions](https://www.ecobee.com/home/developer/api/documentation/v1/functions/using-functions.shtml) from within [openHAB Rules](https://github.com/openhab/openhab/wiki/Rules). + +The Ecobee Action bundle depends upon the installation of the Ecobee Binding, and need only be installed if the target deployment uses Ecobee Action extensions in its Rules. + +## Configuration +The Ecobee Action bundle relies on the Ecobee Binding being installed and configured, and the installation of the Ecobee Action Bundle (JAR) file. Once these are done, you're ready to use the Rule extensions this bundle provides. + +## Extensions +Parameters in _italics_ are optional, in which case each unused parameter must be replaced with `null`. Read the [API documentation](https://www.ecobee.com/home/developer/api/documentation/v1/functions/using-functions.shtml) to be sure you know the rules for calling these functions. + +Each action's first parameter is an `Item` that is bound to the Ecobee binding, and references the thermostat(s) your action is to target. The item's Ecobee binding string could be setting or retrieving any thermostat property; what's important is the reference to the thermostat(s) you want to affect. + +* ecobeeAcknowledge(Item item, String thermostatIdentifier, String ackRef, String ackType, _Boolean remindMeLater_) - Acknowledge an alert. +* ecobeeControlPlug(Item item, String plugName, String plugState, _Date startDateTime_, _Date endDateTime_, _String holdType_, _Integer holdHours_) - Control the on/off state of a plug by setting a hold on the plug. +* ecobeeCreateVacation(Item item, String name, DecimalType coolHoldTemp, DecimalType heatHoldTemp, _Date startDateTime_, _Date endDateTime_, _String fan_, _Integer fanMinOnTime_) - Create a vacation event on the thermostat. +* ecobeeDeleteVacation(Item item, String name) - Delete a vacation event from a thermostat. +* ecobeeResetPreferences(Item item) - Set all user configurable settings back to the factory default values. +* ecobeeResumeProgram(Item item, _Boolean resumeAll_) - Remove the currently running event providing the event is not a mandatory demand response event. +* ecobeeSendMessage(Item item, String text) - Send an alert message to the thermostat. +* ecobeeSetHold(Item item, _DecimalType coolHoldTemp_, _DecimalType heatHoldTemp_, _String holdClimateRef_, _Date startDateTime_, _Date endDateTime_, _String holdType_, _Integer holdHours_) - Set the thermostat into a hold with the specified temperature. +* ecobeeSetOccupied(Item item, Boolean occupied, _Date startDateTime_, _Date endDateTime_, _String holdType_, _Integer holdHours_) - Switches a (EMS model only) thermostat from occupied mode to unoccupied, or vice versa. +* ecobeeUpdateSensor(Item item, String name, String deviceId, String sensorId) - Update the name of an ecobee3 remote sensor. + +## Examples +A wiki page showing more examples for how to use the Ecobee binding and action bundles is forthcoming. + +* Switch to `away` comfort setting when a door or window is opened and put a message on the thermostat to close the windows and doors. + +``` +rule "Heat and cool indoors only" +when + Item Bedroom2ZoneTripped changed from CLOSED to OPEN or + Item Bedroom3ZoneTripped changed from CLOSED to OPEN +then + if (GWindowsDoors.members.filter(s|s.state==OPEN).size == 1) { + ecobeeSetHold(SomeEcobeeItem, null, null, "away", null, null, null, null) + ecobeeSendMessage(SomeEcobeeItem, "Close the windows and doors!") + } +end +``` + +## Change Log + +* 1.8.0 - First release + diff --git a/bundles/action/org.openhab.action.ecobee/build.properties b/bundles/action/org.openhab.action.ecobee/build.properties new file mode 100644 index 00000000000..30f33af0ad2 --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/build.properties @@ -0,0 +1,6 @@ +source.. = src/main/java/,\ + src/main/resources/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ +output.. = target/classes/ diff --git a/bundles/action/org.openhab.action.ecobee/pom.xml b/bundles/action/org.openhab.action.ecobee/pom.xml new file mode 100644 index 00000000000..5fbf879ddd3 --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/pom.xml @@ -0,0 +1,35 @@ + + + + + org.openhab.bundles + action + 1.8.0-SNAPSHOT + + + + org.openhab.action.ecobee + org.openhab.action.ecobee + openhab-addon-action-ecobee + ${project.name} + + + 4.0.0 + org.openhab.action + org.openhab.action.ecobee + + openHAB Ecobee Action + + eclipse-plugin + + + + + org.vafer + jdeb + + + + + diff --git a/bundles/action/org.openhab.action.ecobee/src/main/java/org/openhab/action/ecobee/internal/EcobeeAction.java b/bundles/action/org.openhab.action.ecobee/src/main/java/org/openhab/action/ecobee/internal/EcobeeAction.java new file mode 100644 index 00000000000..970fe7d191c --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/src/main/java/org/openhab/action/ecobee/internal/EcobeeAction.java @@ -0,0 +1,290 @@ +/** + * Copyright (c) 2010-2015, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.action.ecobee.internal; + +import java.util.Date; + +import org.openhab.binding.ecobee.EcobeeActionProvider; +import org.openhab.binding.ecobee.messages.*; +import org.openhab.core.items.Item; +import org.openhab.core.library.types.DecimalType; +import org.openhab.core.scriptengine.action.ActionDoc; +import org.openhab.core.scriptengine.action.ParamDoc; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class provides static methods for invocation of Ecobee functions, for use in automation rules. + * + * @see Using + * Functions + * @author John Cocula + * @since 1.8.0 + */ +public class EcobeeAction { + + private static final Logger logger = LoggerFactory.getLogger(EcobeeAction.class); + + /** + * The acknowledge function allows an alert to be acknowledged. + * + * @see Acknowledge + */ + @ActionDoc(text = "The acknowledge function allows an alert to be acknowledged.") + public static boolean ecobeeAcknowledge( + @ParamDoc(name = "item", text = "The Item associated with the thermostat to acknowledge the alert for.") Item item, + @ParamDoc(name = "thermostatIdentifier", text = "The thermostat identifier to acknowledge the alert for.") String thermostatIdentifier, + @ParamDoc(name = "ackRef", text = "The acknowledge ref of alert.") String ackRef, + @ParamDoc(name = "ackType", text = "The type of acknowledgement. Valid values: accept, decline, defer, unacknowledged.") String ackType, + @ParamDoc(name = "remindMeLater", text = "(opt) Whether to remind at a later date, if this is a defer acknowledgement.") Boolean remindMeLater) { + AcknowledgeFunction function = new AcknowledgeFunction(thermostatIdentifier, ackRef, + AcknowledgeFunction.AckType.forValue(ackType), remindMeLater); + return callEcobeeInternal(item, function); + } + + /** + * Control the on/off state of a plug by setting a hold on the plug. Creates a hold for the on or off state of the + * plug for the specified duration. Note that an event is created regardless of whether the program is in the same + * state as the requested state. + * + * @see Control + * Plug + */ + @ActionDoc(text = "Control the on/off state of a plug by setting a hold on the plug.") + public static boolean ecobeeControlPlug( + @ParamDoc(name = "item", text = "The Item associated with the thermostat controlling the plug.") Item item, + @ParamDoc(name = "plugName", text = "The name of the plug. Ensure each plug has a unique name.") String plugName, + @ParamDoc(name = "plugState", text = "The state to put the plug into. Valid values: on, off, resume.") String plugState, + @ParamDoc(name = "startDateTime", text = "(opt) The start date/time in thermostat time.") Date startDateTime, + @ParamDoc(name = "endDateTime", text = "(opt) The end date/time in thermostat time.") Date endDateTime, + @ParamDoc(name = "holdType", text = "(opt) The hold duration type. Valid values: dateTime, nextTransition, indefinite, holdHours.") String holdType, + @ParamDoc(name = "holdHours", text = "(opt) The number of hours to hold for, used and required if holdType='holdHours'.") Integer holdHours) { + ControlPlugFunction function = new ControlPlugFunction(plugName, + ControlPlugFunction.PlugState.forValue(plugState), startDateTime, endDateTime, + (holdType == null) ? null : HoldType.forValue(holdType), holdHours); + return callEcobeeInternal(item, function); + } + + /** + * The create vacation function creates a vacation event on the thermostat. If the start/end date/times are not + * provided for the vacation event, the vacation event will begin immediately and last 14 days. + * + * If both the coolHoldTemp and heatHoldTemp parameters provided to this function have the same value, and the + * Thermostat is in auto mode, then the two values will be adjusted during processing to be separated by the value + * stored in thermostat.settings.heatCoolMinDelta. + * + * @see Create + * Vacation + */ + @ActionDoc(text = "The create vacation function creates a vacation event on the thermostat.") + public static boolean ecobeeCreateVacation( + @ParamDoc(name = "item", text = "The Item associated with the thermostat controlling the plug.") Item item, + @ParamDoc(name = "name", text = "The vacation event name. It must be unique.") String name, + @ParamDoc(name = "coolHoldTemp", text = "The temperature to set the cool vacation hold at.") DecimalType coolHoldTemp, + @ParamDoc(name = "heatHoldTemp", text = "The temperature to set the heat vacation hold at.") DecimalType heatHoldTemp, + @ParamDoc(name = "startDateTime", text = "(opt) The start date/time in thermostat time.") Date startDateTime, + @ParamDoc(name = "endDateTime", text = "(opt) The end date in thermostat time.") Date endDateTime, + @ParamDoc(name = "fan", text = "(opt) The fan mode during the vacation. Values: auto, on Default: auto") String fan, + @ParamDoc(name = "fanMinOnTime", text = "(opt) The minimum number of minutes to run the fan each hour. Range: 0-60, Default: 0") Integer fanMinOnTime) { + CreateVacationFunction function = new CreateVacationFunction(name, + Temperature.fromLocalTemperature(coolHoldTemp.toBigDecimal()), + Temperature.fromLocalTemperature(heatHoldTemp.toBigDecimal()), startDateTime, endDateTime, + FanMode.forValue(fan), fanMinOnTime); + return callEcobeeInternal(item, function); + } + + /** + * The delete vacation function deletes a vacation event from a thermostat. This is the only way to cancel a + * vacation event. This method is able to remove vacation events not yet started and scheduled in the future. + * + * @see Delete + * Vacation + */ + @ActionDoc(text = "The delete vacation function deletes a vacation event from a thermostat.") + public static boolean ecobeeDeleteVacation( + @ParamDoc(name = "item", text = "The Item associated with the thermostat to delete vacation.") Item item, + @ParamDoc(name = "name", text = "The vacation event name to delete.") String name) { + return callEcobeeInternal(item, new DeleteVacationFunction(name)); + } + + /** + * The reset preferences function sets all of the user configurable settings back to the factory default values. + * This function call will not only reset the top level thermostat settings such as hvacMode, lastServiceDate and + * vent, but also all of the user configurable fields of the thermostat.settings and thermostat.program objects. + * + * Note that this does not reset all values. For example, the installer settings and wifi details remain untouched. + * + * @see Reset + * Preferences + */ + @ActionDoc(text = "The reset preferences function sets all of the user configurable settings back to the factory default values.") + public static boolean ecobeeResetPreferences( + @ParamDoc(name = "item", text = "The Item associated with the thermostat to reset preferences.") Item item) { + return callEcobeeInternal(item, new ResetPreferencesFunction()); + } + + /** + * The resume program function removes the currently running event providing the event is not a mandatory demand + * response event. If resumeAll parameter is not set, top active event is removed from the stack and the thermostat + * resumes its program, or enters the next event in the stack if one exists. + * + * If resumeAll parameter set to true, the function resumes all events and returns the thermostat to its program. + * + * @see Resume + * Program + */ + @ActionDoc(text = "The resume program function removes the currently running event providing the event is not a mandatory demand response event.") + public static boolean ecobeeResumeProgram( + @ParamDoc(name = "item", text = "The Item associated with the thermostat to resume program.") Item item, + @ParamDoc(name = "resumeAll", text = "(opt) Should the thermostat be resumed to next event (false) or to its program (true).") Boolean resumeAll) { + return callEcobeeInternal(item, new ResumeProgramFunction(resumeAll)); + } + + /** + * The send message function allows an alert message to be sent to the thermostat. The message properties are same + * as those of the Alert Object. + * + * @see Send + * Message + */ + @ActionDoc(text = "The send message function allows an alert message to be sent to the thermostat.") + public static boolean ecobeeSendMessage( + @ParamDoc(name = "item", text = "The Item associated with the thermostat to send message.") Item item, + @ParamDoc(name = "text", text = "The message text to send. Text will be truncated to 500 characters if longer.") String text) { + return callEcobeeInternal(item, new SendMessageFunction(text)); + } + + /** + * The set hold function sets the thermostat into a hold with the specified temperature. Creates a hold for the + * specified duration. Note that an event is created regardless of whether the program is in the same state as the + * requested state. + * + * There is also support for creating a hold by passing a holdClimateRef request parameter/value pair to this + * function (See Event). When an existing and valid Climate.climateRef value is passed to this function, the + * coolHoldTemp, heatHoldTemp and fan mode from that Climate are used in the creation of the hold event. The values + * from that Climate will take precedence over any coolHoldTemp, heatHoldTemp and fan mode parameters passed into + * this function separately. + * + * To resume from a hold and return to the program, use the ResumeProgram function. + * + * @see Set Hold + */ + @ActionDoc(text = "The set hold function sets the thermostat into a hold with the specified temperature or climate ref.") + public static boolean ecobeeSetHold( + @ParamDoc(name = "item", text = "The Item associated with the thermostat to send message.") Item item, + @ParamDoc(name = "coolHoldTemp", text = "(opt) The temperature to set the cool hold at.") DecimalType coolHoldTemp, + @ParamDoc(name = "heatHoldTemp", text = "(opt) The temperature to set the heat hold at.") DecimalType heatHoldTemp, + @ParamDoc(name = "holdClimateRef", text = "(opt) The Climate to use as reference for setting the coolHoldTemp, heatHoldTemp and fan settings for this hold. If this value is passed the coolHoldTemp and heatHoldTemp are not required.") String holdClimateRef, + @ParamDoc(name = "startDateTime", text = "(opt) The start date in thermostat time.") Date startDateTime, + @ParamDoc(name = "endDateTime", text = "(opt) The end date in thermostat time.") Date endDateTime, + @ParamDoc(name = "holdType", text = "(opt) The hold duration type. Valid values: dateTime, nextTransition, indefinite, holdHours.") String holdType, + @ParamDoc(name = "holdHours", text = "(opt) The number of hours to hold for, used and required if holdType='holdHours'.") Integer holdHours) { + SetHoldFunction function = new SetHoldFunction((coolHoldTemp == null) ? null + : Temperature.fromLocalTemperature(coolHoldTemp.toBigDecimal()), (heatHoldTemp == null) ? null + : Temperature.fromLocalTemperature(heatHoldTemp.toBigDecimal()), holdClimateRef, startDateTime, + endDateTime, (holdType == null) ? null : HoldType.forValue(holdType), holdHours); + return callEcobeeInternal(item, function); + } + + /** + * The set occupied function may only be used by EMS thermostats. The function switches a thermostat from occupied + * mode to unoccupied, or vice versa. If used on a Smart thermostat, the function will throw an error. Switch + * occupancy events are treated as Holds. There may only be one Switch Occupancy at one time, and the new event will + * replace any previous event. + * + * Note that an occupancy event is created regardless what the program on the thermostat is set to. For example, if + * the program is currently unoccupied and you set occupied=false, an occupancy event will be created using the + * heat/cool settings of the unoccupied program climate. If your intent is to go back to the program and remove the + * occupancy event, use resumeProgram instead. + * + * @see Set + * Occupied + */ + @ActionDoc(text = "The function switches a thermostat from occupied mode to unoccupied, or vice versa (EMS MODELS ONLY).") + public static boolean ecobeeSetOccupied( + @ParamDoc(name = "item", text = "The Item associated with the EMS model thermostat to set occupied.") Item item, + @ParamDoc(name = "occupied", text = "The climate to use for the temperature, occupied (true) or unoccupied (false).") Boolean occupied, + @ParamDoc(name = "startDateTime", text = "(opt) The start date in thermostat time.") Date startDateTime, + @ParamDoc(name = "endDateTime", text = "(opt) The end date in thermostat time.") Date endDateTime, + @ParamDoc(name = "holdType", text = "(opt) The hold duration type. Valid values: dateTime, nextTransition, indefinite, holdHours.") String holdType, + @ParamDoc(name = "holdHours", text = "(opt) The number of hours to hold for, used and required if holdType='holdHours'.") Integer holdHours) { + SetOccupiedFunction function = new SetOccupiedFunction(occupied, startDateTime, endDateTime, + (holdType == null) ? null : HoldType.forValue(holdType), holdHours); + return callEcobeeInternal(item, function); + } + + /** + * The update sensor function allows the caller to update the name of an ecobee3 remote sensor. + * + * Each ecobee3 remote sensor "enclosure" contains two distinct sensors types temperature and occupancy. Only one of + * the sensors is required in the request. Both of the sensors' names will be updated to ensure consistency as they + * are part of the same remote sensor enclosure. This also reflects accurately what happens on the Thermostat + * itself. + * + * @see Update + * Sensor + */ + @ActionDoc(text = "The update sensor function allows the caller to update the name of an ecobee3 remote sensor.") + public static boolean ecobeeUpdateSensor( + @ParamDoc(name = "item", text = "The Item associated with the EMS model thermostat to update the sensor name.") Item item, + @ParamDoc(name = "name", text = "The updated name to give the sensor. Has a max length of 32, but shorter is recommended.") String name, + @ParamDoc(name = "deviceId", text = "The deviceId for the sensor, typically this indicates the enclosure and corresponds to the ThermostatRemoteSensor.id field. For example: rs:100") String deviceId, + @ParamDoc(name = "sensorId", text = "The identifier for the sensor within the enclosure. Corresponds to the RemoteSensorCapability.id. For example: 1") String sensorId) { + return callEcobeeInternal(item, new UpdateSensorFunction(name, deviceId, sensorId)); + } + + /** + * Return the EcobeeActionProvider so we can perform Ecobee actions. + * + * @param itemName + * unused + * @return the Ecobee action provider + * @throws Exception + * if no Ecobee action service or provider has been set + */ + private static EcobeeActionProvider getActionProvider(String itemName) throws Exception { + EcobeeActionService service = EcobeeActionService.getEcobeeActionService(); + if (service == null) { + throw new Exception(String.format("Ecobee Service is not configured, Action for Item %1$s not queued.", + itemName)); + } + + EcobeeActionProvider actionProvider = service.getEcobeeActionProvider(); + if (actionProvider == null) { + throw new Exception(String.format( + "Ecobee Action Provider is not configured, Action for Item %1$s not queued.", itemName)); + } + + return actionProvider; + } + + /** + * This internal method sends function objects to the binding to invoke against thermostat(s). + * + * @param item + * the item associated with the thermostat(s) against which to perform the function. + * @param function + * the function to perform + * @return true if the request to perform the function was successful. + */ + private static boolean callEcobeeInternal(Item item, AbstractFunction function) { + try { + String itemName = item.getName(); + logger.debug("Attempting to call Ecobee function '{}' using Item '{}'", function, itemName); + + EcobeeActionProvider actionProvider = getActionProvider(itemName); + + return actionProvider.callEcobee(itemName, function); + } catch (Exception ex) { + logger.error(ex.getMessage(), ex); + return false; + } + } +} diff --git a/bundles/action/org.openhab.action.ecobee/src/main/java/org/openhab/action/ecobee/internal/EcobeeActionService.java b/bundles/action/org.openhab.action.ecobee/src/main/java/org/openhab/action/ecobee/internal/EcobeeActionService.java new file mode 100644 index 00000000000..9fee6782144 --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/src/main/java/org/openhab/action/ecobee/internal/EcobeeActionService.java @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2010-2015, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.action.ecobee.internal; + +import java.util.Dictionary; + +import org.openhab.binding.ecobee.EcobeeActionProvider; +import org.openhab.core.scriptengine.action.ActionService; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class registers an OSGi service for the Ecobee Action. + * + * @author John Cocula + * @since 1.8.0 + */ +public class EcobeeActionService implements ActionService, ManagedService { + + private static final Logger logger = LoggerFactory.getLogger(EcobeeActionService.class); + + private EcobeeActionProvider actionProvider; + private static EcobeeActionService service; + + public static EcobeeActionService getEcobeeActionService() { + return service; + } + + public void activate() { + logger.debug("Ecobee action service activated"); + service = this; + } + + public void deactivate() { + logger.debug("Ecobee action service deactivated"); + service = null; + } + + /** + * {@inheritDoc} + */ + @Override + public String getActionClassName() { + return getActionClass().getCanonicalName(); + } + + /** + * {@inheritDoc} + */ + @Override + public Class getActionClass() { + return EcobeeAction.class; + } + + /** + * {@inheritDoc} + */ + @Override + public void updated(Dictionary properties) throws ConfigurationException { + } + + /** + * Setter for use by OSGi injection. + * + * @param actionProvider the Ecobee Action Provider (provided by the Ecobee Binding). + */ + public void setEcobeeActionProvider(EcobeeActionProvider actionProvider) { + this.actionProvider = actionProvider; + logger.trace("setEcobeeActionProvider called"); + } + + /** + * Unsetter for use by OSGi injection. + * + * @param actionProvider Ecobee Action Provider to remove. + */ + public void unsetEcobeeActionProvider(EcobeeActionProvider actionProvider) { + this.actionProvider = null; + logger.trace("unsetEcobeeActionProvider called"); + } + + /** + * Get the EcobeeActionProvider instance injected by OSGi. + * + * @return the Ecobee Action Provider associated with this Action Service. + */ + public EcobeeActionProvider getEcobeeActionProvider() { + return this.actionProvider; + } +} diff --git a/bundles/action/org.openhab.action.ecobee/src/main/java/org/openhab/action/ecobee/internal/EcobeeActivator.java b/bundles/action/org.openhab.action.ecobee/src/main/java/org/openhab/action/ecobee/internal/EcobeeActivator.java new file mode 100644 index 00000000000..6a3e0b78190 --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/src/main/java/org/openhab/action/ecobee/internal/EcobeeActivator.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010-2015, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.action.ecobee.internal; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Extension of the default OSGi bundle activator. + * + * @author John Cocula + * @since 1.8.0 + */ +public final class EcobeeActivator implements BundleActivator { + + private static Logger logger = LoggerFactory.getLogger(EcobeeActivator.class); + + private static BundleContext context; + + /** + * Called whenever the OSGi framework starts our bundle. + */ + public void start(BundleContext bc) throws Exception { + context = bc; + logger.debug("Ecobee Action has been started."); + } + + /** + * Called whenever the OSGi framework stops our bundle. + */ + public void stop(BundleContext bc) throws Exception { + context = null; + logger.debug("Ecobee Action has been stopped."); + } + + /** + * Returns the bundle context of this bundle. + * + * @return the bundle context. + */ + public static BundleContext getContext() { + return context; + } +} diff --git a/bundles/action/org.openhab.action.ecobee/src/main/resources/readme.txt b/bundles/action/org.openhab.action.ecobee/src/main/resources/readme.txt new file mode 100644 index 00000000000..98698c670dc --- /dev/null +++ b/bundles/action/org.openhab.action.ecobee/src/main/resources/readme.txt @@ -0,0 +1 @@ +Bundle resources go in here! \ No newline at end of file diff --git a/bundles/action/pom.xml b/bundles/action/pom.xml index afca1a84c6d..480866ccc2f 100644 --- a/bundles/action/pom.xml +++ b/bundles/action/pom.xml @@ -32,6 +32,7 @@ org.openhab.action.astro org.openhab.action.tinkerforge org.openhab.action.harmonyhub + org.openhab.action.ecobee diff --git a/bundles/binding/org.openhab.binding.ecobee/META-INF/MANIFEST.MF b/bundles/binding/org.openhab.binding.ecobee/META-INF/MANIFEST.MF index 133805fd89e..d99704815b6 100644 --- a/bundles/binding/org.openhab.binding.ecobee/META-INF/MANIFEST.MF +++ b/bundles/binding/org.openhab.binding.ecobee/META-INF/MANIFEST.MF @@ -34,7 +34,8 @@ Import-Package: com.google.common.base, org.osgi.service.component, org.osgi.service.event, org.slf4j -Export-Package: org.openhab.binding.ecobee +Export-Package: org.openhab.binding.ecobee, + org.openhab.binding.ecobee.messages Bundle-DocURL: http://www.openhab.org Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Service-Component: OSGI-INF/binding.xml, OSGI-INF/genericbindingprovider.xml diff --git a/bundles/binding/org.openhab.binding.ecobee/OSGI-INF/binding.xml b/bundles/binding/org.openhab.binding.ecobee/OSGI-INF/binding.xml index bfcb3d10f04..8e09f224f1c 100644 --- a/bundles/binding/org.openhab.binding.ecobee/OSGI-INF/binding.xml +++ b/bundles/binding/org.openhab.binding.ecobee/OSGI-INF/binding.xml @@ -15,6 +15,7 @@ + diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/EcobeeActionProvider.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/EcobeeActionProvider.java new file mode 100644 index 00000000000..ecc09e6e9c7 --- /dev/null +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/EcobeeActionProvider.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2010-2015, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.ecobee; + +import org.openhab.binding.ecobee.messages.AbstractFunction; + +/** + * openHAB Action Provider interface for Ecobee thermostats. + * + * @author John Cocula + * @since 1.8.0 + */ +public interface EcobeeActionProvider { + /** + * Call the specified Ecobee function. + * + * Requests the named Ecobee function, associated with the Item be invoked. Callers can pass an AbstractFunction to be + * called. + * + * @param itemName + * the name of of the openHAB Item to which the Action invocation should be delivered. + * @param function + * the function to call using the specified itemName. + * @return true if the function call was performed. + */ + public boolean callEcobee(String itemName, AbstractFunction function); +} diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/EcobeeBinding.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/EcobeeBinding.java index 4f40250c95b..4ecdd825180 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/EcobeeBinding.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/EcobeeBinding.java @@ -24,28 +24,29 @@ import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.Converter; +import org.openhab.binding.ecobee.EcobeeActionProvider; import org.openhab.binding.ecobee.EcobeeBindingProvider; -import org.openhab.binding.ecobee.internal.messages.AbstractFunction; -import org.openhab.binding.ecobee.internal.messages.ApiResponse; -import org.openhab.binding.ecobee.internal.messages.AuthorizeRequest; -import org.openhab.binding.ecobee.internal.messages.AuthorizeResponse; -import org.openhab.binding.ecobee.internal.messages.Request; -import org.openhab.binding.ecobee.internal.messages.Selection; -import org.openhab.binding.ecobee.internal.messages.Selection.SelectionType; -import org.openhab.binding.ecobee.internal.messages.Status; -import org.openhab.binding.ecobee.internal.messages.Temperature; -import org.openhab.binding.ecobee.internal.messages.Thermostat; -import org.openhab.binding.ecobee.internal.messages.Thermostat.HvacMode; -import org.openhab.binding.ecobee.internal.messages.Thermostat.VentilatorMode; -import org.openhab.binding.ecobee.internal.messages.ThermostatRequest; -import org.openhab.binding.ecobee.internal.messages.ThermostatResponse; -import org.openhab.binding.ecobee.internal.messages.ThermostatSummaryRequest; -import org.openhab.binding.ecobee.internal.messages.ThermostatSummaryResponse; -import org.openhab.binding.ecobee.internal.messages.ThermostatSummaryResponse.Revision; -import org.openhab.binding.ecobee.internal.messages.RefreshTokenRequest; -import org.openhab.binding.ecobee.internal.messages.TokenRequest; -import org.openhab.binding.ecobee.internal.messages.TokenResponse; -import org.openhab.binding.ecobee.internal.messages.UpdateThermostatRequest; +import org.openhab.binding.ecobee.messages.AbstractFunction; +import org.openhab.binding.ecobee.messages.ApiResponse; +import org.openhab.binding.ecobee.messages.AuthorizeRequest; +import org.openhab.binding.ecobee.messages.AuthorizeResponse; +import org.openhab.binding.ecobee.messages.RefreshTokenRequest; +import org.openhab.binding.ecobee.messages.Request; +import org.openhab.binding.ecobee.messages.Selection; +import org.openhab.binding.ecobee.messages.Status; +import org.openhab.binding.ecobee.messages.Temperature; +import org.openhab.binding.ecobee.messages.Thermostat; +import org.openhab.binding.ecobee.messages.ThermostatRequest; +import org.openhab.binding.ecobee.messages.ThermostatResponse; +import org.openhab.binding.ecobee.messages.ThermostatSummaryRequest; +import org.openhab.binding.ecobee.messages.ThermostatSummaryResponse; +import org.openhab.binding.ecobee.messages.TokenRequest; +import org.openhab.binding.ecobee.messages.TokenResponse; +import org.openhab.binding.ecobee.messages.UpdateThermostatRequest; +import org.openhab.binding.ecobee.messages.Selection.SelectionType; +import org.openhab.binding.ecobee.messages.Thermostat.HvacMode; +import org.openhab.binding.ecobee.messages.Thermostat.VentilatorMode; +import org.openhab.binding.ecobee.messages.ThermostatSummaryResponse.Revision; import static org.apache.commons.lang.StringUtils.isNotBlank; @@ -70,7 +71,8 @@ * @author John Cocula * @since 1.7.0 */ -public class EcobeeBinding extends AbstractActiveBinding implements ManagedService { +public class EcobeeBinding extends AbstractActiveBinding implements ManagedService, + EcobeeActionProvider { private static final String DEFAULT_USER_ID = "DEFAULT_USER"; @@ -257,7 +259,8 @@ protected void execute() { readEcobee(oauthCredentials, selection); } } catch (Exception e) { - logger.error("Error reading from Ecobee:", e); + logger.warn("Exception reading from Ecobee: {}", e.getMessage()); + logger.debug("Stack trace:", e); } } @@ -576,6 +579,72 @@ private void updateEcobee(final String itemName, final State newState) { } } + /** + * {@inheritDoc} + */ + @Override + public boolean callEcobee(final String itemName, final AbstractFunction function) { + // Find the first binding provider for this itemName. + EcobeeBindingProvider provider = null; + String selectionMatch = null; + for (EcobeeBindingProvider p : this.providers) { + selectionMatch = p.getThermostatIdentifier(itemName); + if (selectionMatch != null) { + provider = p; + break; + } + } + + if (provider == null) { + logger.warn("no matching binding provider found [itemName={}, function={}]", itemName, function); + return false; + } + + final Selection selection = new Selection(selectionMatch); + logger.trace("Selection for function: {}", selection); + + try { + logger.trace("Function to call: {}", function); + + OAuthCredentials oauthCredentials = getOAuthCredentials(provider.getUserid(itemName)); + + if (oauthCredentials == null) { + logger.warn("Unable to locate credentials for item {}; aborting function call.", itemName); + return false; + } + + if (oauthCredentials.noAccessToken()) { + if (!oauthCredentials.refreshTokens()) { + logger.warn("Calling function skipped."); + return false; + } + } + + List functions = new ArrayList(1); + functions.add(function); + + UpdateThermostatRequest request = new UpdateThermostatRequest(oauthCredentials.accessToken, selection, + functions, null); + + ApiResponse response = request.execute(); + if (response.isError()) { + final Status status = response.getStatus(); + if (status.isAccessTokenExpired()) { + if (oauthCredentials.refreshTokens()) { + return callEcobee(itemName, function); + } + } else { + logger.error("Error calling function: {}", response); + } + return false; + } + return true; + } catch (Exception e) { + logger.error("Unable to call function", e); + return false; + } + } + /** * {@inheritDoc} */ diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/EcobeeGenericBindingProvider.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/EcobeeGenericBindingProvider.java index 011b80c1493..645b4392417 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/EcobeeGenericBindingProvider.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/EcobeeGenericBindingProvider.java @@ -12,7 +12,7 @@ import java.util.regex.Pattern; import org.openhab.binding.ecobee.EcobeeBindingProvider; -import org.openhab.binding.ecobee.internal.messages.Selection; +import org.openhab.binding.ecobee.messages.Selection; import org.openhab.core.binding.BindingConfig; import org.openhab.core.items.Item; import org.openhab.model.item.binding.AbstractGenericBindingProvider; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractAuthResponse.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractAuthResponse.java similarity index 97% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractAuthResponse.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractAuthResponse.java index 42acf6b3556..b72c774aca2 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractAuthResponse.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractAuthResponse.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import org.apache.commons.lang.builder.ToStringBuilder; import org.codehaus.jackson.annotate.JsonIgnoreProperties; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractFunction.java similarity index 97% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractFunction.java index b78ef4d604b..86f868c3514 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractFunction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -51,8 +51,9 @@ protected AbstractFunction(String type) { } protected final Map makeParams() { - if (params == null) + if (params == null) { params = new HashMap(); + } return params; } diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractMessage.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractMessage.java similarity index 93% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractMessage.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractMessage.java index 1eb384aa752..c52876de461 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractMessage.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractMessage.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import static org.apache.commons.lang.builder.ToStringStyle.SHORT_PREFIX_STYLE; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractMessagePart.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractMessagePart.java similarity index 94% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractMessagePart.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractMessagePart.java index d4ffb6d88b6..8c0d86a8e48 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractMessagePart.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractMessagePart.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import static org.apache.commons.lang.builder.ToStringStyle.SHORT_PREFIX_STYLE; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractRequest.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractRequest.java similarity index 97% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractRequest.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractRequest.java index 335b087d8cd..172237b832b 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AbstractRequest.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AbstractRequest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.text.SimpleDateFormat; import java.util.Properties; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AcknowledgeFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AcknowledgeFunction.java similarity index 82% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AcknowledgeFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AcknowledgeFunction.java index 93f9511f6e0..7d191f71c33 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AcknowledgeFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AcknowledgeFunction.java @@ -6,8 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; +import org.codehaus.jackson.annotate.JsonCreator; import org.codehaus.jackson.annotate.JsonValue; /** @@ -31,6 +32,16 @@ private AckType(String type) { this.type = type; } + @JsonCreator + public static AckType forValue(String v) { + for (AckType at : AckType.values()) { + if (at.type.equals(v)) { + return at; + } + } + throw new IllegalArgumentException("Invalid ack type: " + v); + } + @Override @JsonValue public String toString() { diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ApiResponse.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ApiResponse.java similarity index 95% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ApiResponse.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ApiResponse.java index 06c48e6ddaa..4c9a732d589 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ApiResponse.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ApiResponse.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import org.apache.commons.lang.builder.ToStringBuilder; import org.codehaus.jackson.annotate.JsonProperty; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AuthorizeRequest.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AuthorizeRequest.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AuthorizeRequest.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AuthorizeRequest.java index 44c8f9fe74d..73a430d4096 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AuthorizeRequest.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AuthorizeRequest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import static org.openhab.io.net.http.HttpUtil.executeUrl; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AuthorizeResponse.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AuthorizeResponse.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AuthorizeResponse.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AuthorizeResponse.java index 6e20b4ec744..17565a756c6 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/AuthorizeResponse.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/AuthorizeResponse.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import org.apache.commons.lang.builder.ToStringBuilder; import org.codehaus.jackson.annotate.JsonIgnoreProperties; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ControlPlugFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ControlPlugFunction.java similarity index 91% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ControlPlugFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ControlPlugFunction.java index ab45110dd0a..37fb0340d7d 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ControlPlugFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ControlPlugFunction.java @@ -6,10 +6,11 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.util.Date; +import org.codehaus.jackson.annotate.JsonCreator; import org.codehaus.jackson.annotate.JsonValue; /** @@ -50,6 +51,16 @@ private PlugState(String state) { this.state = state; } + @JsonCreator + public static PlugState forValue(String v) { + for (PlugState ps : PlugState.values()) { + if (ps.state.equals(v)) { + return ps; + } + } + throw new IllegalArgumentException("Invalid plug state: " + v); + } + @Override @JsonValue public String toString() { diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/CreateVacationFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/CreateVacationFunction.java similarity index 88% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/CreateVacationFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/CreateVacationFunction.java index db0b00a90f5..2fe4ad9a74d 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/CreateVacationFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/CreateVacationFunction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.util.Date; @@ -29,7 +29,6 @@ public final class CreateVacationFunction extends AbstractFunction { public CreateVacationFunction(final String name, final Temperature coolHoldTemp, final Temperature heatHoldTemp, final Date startDateTime, final Date endDateTime, final FanMode fan, final Integer fanMinOnTime) { - // TODO doc says String not Integer for fanMinOnTime parameter (@watou) super("createVacation"); if (name == null || coolHoldTemp == null || heatHoldTemp == null) { @@ -47,5 +46,12 @@ public CreateVacationFunction(final String name, final Temperature coolHoldTemp, makeParams().put("endDate", ymd.format(endDateTime)); makeParams().put("endTime", hms.format(endDateTime)); } + if (fan != null) { + makeParams().put("fan", fan); + } + if (fanMinOnTime != null) { + // doc says String not Integer for fanMinOnTime parameter (@watou) + makeParams().put("fanMinOnTime", fanMinOnTime.toString()); + } } } diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/DeleteVacationFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/DeleteVacationFunction.java similarity index 95% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/DeleteVacationFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/DeleteVacationFunction.java index cf57936e976..8103257ac9c 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/DeleteVacationFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/DeleteVacationFunction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; /** * The delete vacation function deletes a vacation event from a thermostat. This is the only way to cancel a vacation diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/FanMode.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/FanMode.java similarity index 95% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/FanMode.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/FanMode.java index ea44f42c95f..708aec16003 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/FanMode.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/FanMode.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import org.codehaus.jackson.annotate.JsonCreator; import org.codehaus.jackson.annotate.JsonValue; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Group.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Group.java similarity index 99% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Group.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Group.java index ff0b1767895..5e4db0250c7 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Group.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Group.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.util.List; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/HoldType.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/HoldType.java similarity index 85% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/HoldType.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/HoldType.java index 4dbf0113818..3d686df0769 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/HoldType.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/HoldType.java @@ -6,8 +6,9 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; +import org.codehaus.jackson.annotate.JsonCreator; import org.codehaus.jackson.annotate.JsonValue; /** @@ -49,6 +50,16 @@ private HoldType(final String type) { this.type = type; } + @JsonCreator + public static HoldType forValue(String v) { + for (HoldType ht : HoldType.values()) { + if (ht.type.equals(v)) { + return ht; + } + } + throw new IllegalArgumentException("Invalid hold type: " + v); + } + @Override @JsonValue public String toString() { diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Page.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Page.java similarity index 97% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Page.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Page.java index 4af960409e6..5fdcec22f5b 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Page.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Page.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import org.apache.commons.lang.builder.ToStringBuilder; import org.codehaus.jackson.annotate.JsonIgnoreProperties; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/RefreshTokenRequest.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/RefreshTokenRequest.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/RefreshTokenRequest.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/RefreshTokenRequest.java index 72a3a3a6551..6bfa77d5247 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/RefreshTokenRequest.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/RefreshTokenRequest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import static org.openhab.io.net.http.HttpUtil.executeUrl; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Request.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Request.java similarity index 92% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Request.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Request.java index c0cc14a88ae..0ca94e3bed9 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Request.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Request.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; /** * Base interface for all Ecobee API requests. diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ResetPreferencesFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ResetPreferencesFunction.java new file mode 100644 index 00000000000..84546ec7dc7 --- /dev/null +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ResetPreferencesFunction.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2010-2015, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.ecobee.messages; + +/** + * The reset preferences function sets all of the user configurable settings back to the factory default values. This + * function call will not only reset the top level thermostat settings such as hvacMode, lastServiceDate and vent, but + * also all of the user configurable fields of the thermostat.settings and thermostat.program objects. + * + * Note that this does not reset all values. For example, the installer settings and wifi details remain untouched. + * + * @see ResetPreferences + * @author John Cocula + * @since 1.8.0 + */ +public final class ResetPreferencesFunction extends AbstractFunction { + + public ResetPreferencesFunction() { + super("resetPreferences"); + } +} diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Response.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Response.java similarity index 93% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Response.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Response.java index a0413eda1fa..68d273713bf 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Response.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Response.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; /** * Base interface for all Ecobee API responses. diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ResumeProgramFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ResumeProgramFunction.java similarity index 87% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ResumeProgramFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ResumeProgramFunction.java index 54b3e17c9ab..40b43076fdd 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ResumeProgramFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ResumeProgramFunction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; /** * The resume program function removes the currently running event providing the event is not a mandatory demand @@ -25,7 +25,10 @@ */ public final class ResumeProgramFunction extends AbstractFunction { - public ResumeProgramFunction() { + public ResumeProgramFunction(Boolean resumeAll) { super("resumeProgram"); + if (resumeAll != null) { + makeParams().put("resumeAll", resumeAll); + } } } diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Selection.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Selection.java similarity index 99% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Selection.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Selection.java index 08c6d5281cd..e57557b8219 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Selection.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Selection.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.util.Set; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/SendMessageFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/SendMessageFunction.java similarity index 95% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/SendMessageFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/SendMessageFunction.java index 77821f65a4f..2d9b48986c6 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/SendMessageFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/SendMessageFunction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; /** * The send message function allows an alert message to be sent to the thermostat. The message properties are same diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/SetHoldFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/SetHoldFunction.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/SetHoldFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/SetHoldFunction.java index 938c6d9d3fe..8acb0ff8235 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/SetHoldFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/SetHoldFunction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.util.Date; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/SetOccupiedFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/SetOccupiedFunction.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/SetOccupiedFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/SetOccupiedFunction.java index 176129efb8e..4c47d4503c4 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/SetOccupiedFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/SetOccupiedFunction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.util.Date; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Status.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Status.java similarity index 97% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Status.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Status.java index ace95d5e050..b562f0e88c7 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Status.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Status.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import org.apache.commons.lang.builder.ToStringBuilder; import org.codehaus.jackson.annotate.JsonIgnoreProperties; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Temperature.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Temperature.java similarity index 90% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Temperature.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Temperature.java index a8fd69273cc..cc4845357be 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Temperature.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Temperature.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.math.BigDecimal; import java.math.MathContext; @@ -122,8 +122,7 @@ public static Temperature fromFahrenheit(BigDecimal fahrenheit) { return new Temperature(fahrenheit.movePointRight(1)); } - private static BigDecimal NINE = new BigDecimal("9"); - private static BigDecimal FIVE = new BigDecimal("5"); + private static BigDecimal ONE_POINT_EIGHT = new BigDecimal("1.8"); private static BigDecimal THIRTY_TWO = new BigDecimal("32"); /** @@ -133,13 +132,13 @@ public static Temperature fromFahrenheit(BigDecimal fahrenheit) { * the Celsius temperature */ public static Temperature fromCelsius(BigDecimal celsius) { - return new Temperature(celsius.multiply(NINE).divide(FIVE, MathContext.DECIMAL32).add(THIRTY_TWO).movePointRight(1)); + return new Temperature(celsius.multiply(ONE_POINT_EIGHT).add(THIRTY_TWO).movePointRight(1)); } /** * Convert this temperature to a temperature in the local temperature scale. * - * @return temperarure in the local temperature scale + * @return temperature in the local temperature scale */ public final BigDecimal toLocalTemperature() { return localScale == Scale.CELSIUS ? toCelsius() : toFahrenheit(); @@ -160,7 +159,7 @@ public final BigDecimal toFahrenheit() { * @return temperature in Celsius */ public final BigDecimal toCelsius() { - return temp.movePointLeft(1).subtract(THIRTY_TWO).divide(NINE.divide(FIVE), MathContext.DECIMAL32); + return temp.movePointLeft(1).subtract(THIRTY_TWO).divide(ONE_POINT_EIGHT, MathContext.DECIMAL32); } @Override diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Thermostat.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Thermostat.java similarity index 99% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Thermostat.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Thermostat.java index 76d3649b795..7686f71c104 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Thermostat.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/Thermostat.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.lang.reflect.InvocationTargetException; import java.util.Date; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatRequest.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatRequest.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatRequest.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatRequest.java index b6e307e391e..7410b6d5f87 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatRequest.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatRequest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import static org.openhab.io.net.http.HttpUtil.executeUrl; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatResponse.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatResponse.java similarity index 97% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatResponse.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatResponse.java index 10f2f1175e4..7a18543d4d5 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatResponse.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatResponse.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.util.List; import org.apache.commons.lang.builder.ToStringBuilder; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatSummaryRequest.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatSummaryRequest.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatSummaryRequest.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatSummaryRequest.java index 6cda3f1858f..74cf3efa129 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatSummaryRequest.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatSummaryRequest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import static org.openhab.io.net.http.HttpUtil.executeUrl; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatSummaryResponse.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatSummaryResponse.java similarity index 99% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatSummaryResponse.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatSummaryResponse.java index 1cb02374ee3..deb5c9feb58 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/ThermostatSummaryResponse.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/ThermostatSummaryResponse.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import java.util.HashSet; import java.util.List; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/TokenRequest.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/TokenRequest.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/TokenRequest.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/TokenRequest.java index a3bc03ec096..cfe656e0827 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/TokenRequest.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/TokenRequest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import static org.openhab.io.net.http.HttpUtil.executeUrl; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/TokenResponse.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/TokenResponse.java similarity index 97% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/TokenResponse.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/TokenResponse.java index 1b4749ace35..8e54a723110 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/TokenResponse.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/TokenResponse.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import org.apache.commons.lang.builder.ToStringBuilder; import org.codehaus.jackson.annotate.JsonIgnoreProperties; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/UpdateSensorFunction.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/UpdateSensorFunction.java similarity index 97% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/UpdateSensorFunction.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/UpdateSensorFunction.java index b1997e15a2c..f6dba2023f7 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/UpdateSensorFunction.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/UpdateSensorFunction.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; /** * The update sensor function allows the caller to update the name of an ecobee3 remote sensor. diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/UpdateThermostatRequest.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/UpdateThermostatRequest.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/UpdateThermostatRequest.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/UpdateThermostatRequest.java index 6e5e27d8ec3..20f88640a5f 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/UpdateThermostatRequest.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/UpdateThermostatRequest.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import static org.openhab.io.net.http.HttpUtil.executeUrl; diff --git a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/User.java b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/User.java similarity index 98% rename from bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/User.java rename to bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/User.java index 95ebf2a68ca..9ec1e395f13 100644 --- a/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/User.java +++ b/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/messages/User.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.openhab.binding.ecobee.internal.messages; +package org.openhab.binding.ecobee.messages; import org.apache.commons.lang.builder.ToStringBuilder; import org.codehaus.jackson.annotate.JsonIgnoreProperties; diff --git a/distribution/pom.xml b/distribution/pom.xml index cba5c887906..9deb8af02d7 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -524,6 +524,12 @@ ${project.version} jar + + org.openhab.action + org.openhab.action.ecobee + ${project.version} + jar + org.openhab.binding diff --git a/features/org.openhab.designer.feature/feature.xml b/features/org.openhab.designer.feature/feature.xml index 6f0ffa6c247..0c4a9c3b89b 100644 --- a/features/org.openhab.designer.feature/feature.xml +++ b/features/org.openhab.designer.feature/feature.xml @@ -467,4 +467,18 @@ version="0.0.0" unpack="false"/> + + + + diff --git a/targetplatform/openHAB Designer (Mac).launch b/targetplatform/openHAB Designer (Mac).launch index f0b1b16f2eb..35f3854bf3e 100644 --- a/targetplatform/openHAB Designer (Mac).launch +++ b/targetplatform/openHAB Designer (Mac).launch @@ -22,7 +22,7 @@ - +