Rework ThingActions (#8732)

* Remove proxy workarounds
* Move ThingActions and a few other classes into the internal package
* Use more consistent action labels/descriptions

Related to:

* openhab/openhab-core#1714
* openhab/openhab-core#1639

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2020-10-14 19:01:12 +02:00
committed by GitHub
parent 4adc214c69
commit bef1046258
86 changed files with 708 additions and 2096 deletions

View File

@@ -1,78 +0,0 @@
/**
* Copyright (c) 2010-2020 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.ecobee.action;
import java.util.Date;
import java.util.Map;
import javax.measure.quantity.Temperature;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.library.types.QuantityType;
/**
* The {@link IEcobeeActions} defines the interface for all thing actions supported by the binding.
* These methods, parameters, and return types are explained in {@link EcobeeActions}.
*
* @author Mark Hilbush - Initial contribution
*/
@NonNullByDefault
public interface IEcobeeActions {
public Boolean acknowledge(@Nullable String ackRef, @Nullable String ackType, @Nullable Boolean remindMeLater);
public Boolean controlPlug(@Nullable String plugName, @Nullable String plugState, @Nullable Date startDateTime,
@Nullable Date endDateTime, @Nullable String holdType, @Nullable Number holdHours);
public Boolean sendMessage(@Nullable String text);
public Boolean createVacation(@Nullable String name, @Nullable QuantityType<Temperature> coolHoldTemp,
@Nullable QuantityType<Temperature> heatHoldTemp, @Nullable Date startDateTime, @Nullable Date endDateTime,
@Nullable String fan, @Nullable Number fanMinOnTime);
public Boolean deleteVacation(@Nullable String name);
public Boolean resetPreferences();
public Boolean resumeProgram(@Nullable Boolean resumeAll);
public Boolean setHold(@Nullable QuantityType<Temperature> coolHoldTemp,
@Nullable QuantityType<Temperature> heatHoldTemp);
public Boolean setHold(@Nullable QuantityType<Temperature> coolHoldTemp,
@Nullable QuantityType<Temperature> heatHoldTemp, @Nullable Number holdHours);
public Boolean setHold(@Nullable String holdClimateRef);
public Boolean setHold(@Nullable String holdClimateRef, @Nullable Number holdHours);
public Boolean setHold(@Nullable QuantityType<Temperature> coolHoldTemp,
@Nullable QuantityType<Temperature> heatHoldTemp, @Nullable String holdClimateRef,
@Nullable Date startDateTime, @Nullable Date endDateTime, @Nullable String holdType,
@Nullable Number holdHours);
public Boolean setHold(@Nullable Map<String, Object> params, @Nullable String holdType, @Nullable Number holdHours,
@Nullable Date startDateTime, @Nullable Date endDateTime);
public Boolean setOccupied(@Nullable Boolean occupied, @Nullable Date startDateTime, @Nullable Date endDateTime,
@Nullable String holdType, @Nullable Number holdHours);
public Boolean updateSensor(@Nullable String name, @Nullable String deviceId, @Nullable String sensorId);
public @Nullable String getAlerts();
public @Nullable String getEvents();
public @Nullable String getClimates();
}

View File

@@ -10,10 +10,8 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.ecobee.action;
package org.openhab.binding.ecobee.internal.action;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -52,11 +50,6 @@ import org.slf4j.LoggerFactory;
/**
* The {@link EcobeeActions} defines the thing actions for the Ecobee binding.
* <p>
* <b>Note:</b>The static method <b>invokeMethod</b> handles the case where
* the test <i>actions instanceof EcobeeActions</i> fails. This test can fail
* due to an issue in openHAB core v2.5.0 where the {@link EcobeeActions} class
* can be loaded by a different classloader than the <i>actions</i> instance.
*
* @author John Cocula - Initial contribution
* @author Mark Hilbush - Adapted for OH2/3
@@ -64,7 +57,7 @@ import org.slf4j.LoggerFactory;
*/
@ThingActionsScope(name = "ecobee")
@NonNullByDefault
public class EcobeeActions implements ThingActions, IEcobeeActions {
public class EcobeeActions implements ThingActions {
private static final Logger LOGGER = LoggerFactory.getLogger(EcobeeActions.class);
@@ -83,26 +76,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
@Override
public @Nullable ThingHandler getThingHandler() {
return this.handler;
}
private static IEcobeeActions invokeMethodOf(@Nullable ThingActions actions) {
if (actions == null) {
throw new IllegalArgumentException("actions cannot be null");
}
if (actions.getClass().getName().equals(EcobeeActions.class.getName())) {
if (actions instanceof IEcobeeActions) {
return (IEcobeeActions) actions;
} else {
return (IEcobeeActions) Proxy.newProxyInstance(IEcobeeActions.class.getClassLoader(),
new Class[] { IEcobeeActions.class }, (Object proxy, Method method, Object[] args) -> {
Method m = actions.getClass().getDeclaredMethod(method.getName(),
method.getParameterTypes());
return m.invoke(actions, args);
});
}
}
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
return handler;
}
/**
@@ -112,8 +86,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
* href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/Acknowledge.shtml">Acknowledge
* </a>
*/
@Override
@RuleAction(label = "Acknowledge", description = "Acknowledges an alert.")
@RuleAction(label = "acknowledge an alert", description = "Acknowledges an alert.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean acknowledge(
@ActionInput(name = "ackRef", description = "The acknowledge ref of alert") @Nullable String ackRef,
@ActionInput(name = "ackType", description = "The type of acknowledgement. Valid values: accept, decline, defer, unacknowledged") @Nullable String ackType,
@@ -131,7 +104,11 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
public static boolean acknowledge(@Nullable ThingActions actions, @Nullable String ackRef, @Nullable String ackType,
@Nullable Boolean remindMeLater) {
return invokeMethodOf(actions).acknowledge(ackRef, ackType, remindMeLater);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).acknowledge(ackRef, ackType, remindMeLater);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
@@ -140,8 +117,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
* @see <a href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/ControlPlug.shtml">Control
* Plug</a>
*/
@Override
@RuleAction(label = "Control Plug", description = "Control the on/off state of a plug by setting a hold on the plug.")
@RuleAction(label = "control a plug", description = "Control the on/off state of a plug by setting a hold on the plug.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean controlPlug(
@ActionInput(name = "plugName", description = "The name of the plug. Ensure each plug has a unique name.") @Nullable String plugName,
@ActionInput(name = "plugState", description = "The state to put the plug into. Valid values: on, off, resume.") @Nullable String plugState,
@@ -164,8 +140,12 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
public static boolean controlPlug(@Nullable ThingActions actions, @Nullable String plugName,
@Nullable String plugState, @Nullable Date startDateTime, @Nullable Date endDateTime,
@Nullable String holdType, @Nullable Number holdHours) {
return invokeMethodOf(actions).controlPlug(plugName, plugState, startDateTime, endDateTime, holdType,
holdHours);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).controlPlug(plugName, plugState, startDateTime, endDateTime, holdType,
holdHours);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
@@ -174,8 +154,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
* @see <a href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/CreateVacation.shtml">Create
* Vacation</a>
*/
@Override
@RuleAction(label = "Create Vacation", description = "The create vacation function creates a vacation event on the thermostat.")
@RuleAction(label = "create a vacation", description = "The create vacation function creates a vacation event on the thermostat.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean createVacation(
@ActionInput(name = "name", description = "The vacation event name. It must be unique.") @Nullable String name,
@ActionInput(name = "coolHoldTemp", description = "The temperature at which to set the cool vacation hold.") @Nullable QuantityType<Temperature> coolHoldTemp,
@@ -200,8 +179,12 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
@Nullable QuantityType<Temperature> coolHoldTemp, @Nullable QuantityType<Temperature> heatHoldTemp,
@Nullable Date startDateTime, @Nullable Date endDateTime, @Nullable String fan,
@Nullable Number fanMinOnTime) {
return invokeMethodOf(actions).createVacation(name, coolHoldTemp, heatHoldTemp, startDateTime, endDateTime, fan,
fanMinOnTime);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).createVacation(name, coolHoldTemp, heatHoldTemp, startDateTime,
endDateTime, fan, fanMinOnTime);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
@@ -210,8 +193,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
* @see <a href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/DeleteVacation.shtml">Delete
* Vacation</a>
*/
@Override
@RuleAction(label = "Delete Vacation", description = "The delete vacation function deletes a vacation event from a thermostat.")
@RuleAction(label = "delete a vacation", description = "The delete vacation function deletes a vacation event from a thermostat.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean deleteVacation(
@ActionInput(name = "name", description = "The vacation event name to delete.") @Nullable String name) {
LOGGER.debug("EcobeeActions: Action 'Delete Vacation' called");
@@ -225,7 +207,11 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
}
public static boolean deleteVacation(@Nullable ThingActions actions, @Nullable String name) {
return invokeMethodOf(actions).deleteVacation(name);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).deleteVacation(name);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
@@ -234,8 +220,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
* @see <a href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/ResetPreferences.shtml">Reset
* Preferences</a>
*/
@Override
@RuleAction(label = "Reset Preferences", description = "The reset preferences function sets all of the user configurable settings back to the factory default values.")
@RuleAction(label = "reset the preferences", description = "The reset preferences function sets all of the user configurable settings back to the factory default values.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean resetPreferences() {
LOGGER.debug("EcobeeActions: Action 'Reset Preferences' called");
EcobeeThermostatBridgeHandler localHandler = handler;
@@ -248,7 +233,11 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
}
public static boolean resetPreferences(@Nullable ThingActions actions) {
return invokeMethodOf(actions).resetPreferences();
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).resetPreferences();
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
@@ -257,8 +246,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
* @see <a href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/ResumeProgram.shtml">Resume
* Program</a>
*/
@Override
@RuleAction(label = "Resume Program", description = "Removes the currently running event providing the event is not a mandatory demand response event")
@RuleAction(label = "resume the program", description = "Removes the currently running event providing the event is not a mandatory demand response event")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean resumeProgram(
@ActionInput(name = "resumeAll", description = "(opt) Should the thermostat be resumed to next event (false) or to its program (true)") @Nullable Boolean resumeAll) {
LOGGER.debug("EcobeeActions: Action 'Resume Program' called");
@@ -272,7 +260,11 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
}
public static boolean resumeProgram(@Nullable ThingActions actions, @Nullable Boolean resumeAll) {
return invokeMethodOf(actions).resumeProgram(resumeAll);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).resumeProgram(resumeAll);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
@@ -281,8 +273,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
* @see <a href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/SendMessage.shtml">Send
* Message</a>
*/
@Override
@RuleAction(label = "Send Message", description = "The send message function allows an alert message to be sent to the thermostat.")
@RuleAction(label = "send a message", description = "The send message function allows an alert message to be sent to the thermostat.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean sendMessage(
@ActionInput(name = "text", description = "The message text to send. Text will be truncated to 500 characters if longer") @Nullable String text) {
LOGGER.debug("EcobeeActions: Action 'SendMessage' called");
@@ -296,7 +287,11 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
}
public static boolean sendMessage(@Nullable ThingActions actions, @Nullable String text) {
return invokeMethodOf(actions).sendMessage(text);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).sendMessage(text);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
@@ -304,8 +299,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
*
* @see <a href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/SetHold.shtml">Set Hold</a>
*/
@Override
@RuleAction(label = "Set Hold", description = "The set hold function sets the thermostat into a hold with the specified temperatures.")
@RuleAction(label = "set the thermostat into hold", description = "The set hold function sets the thermostat into a hold with the specified temperatures.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean setHold(
@ActionInput(name = "coolHoldTemp", description = "The temperature at which to set the cool hold.") @Nullable QuantityType<Temperature> coolHoldTemp,
@ActionInput(name = "heatHoldTemp", description = "The temperature at which to set the heat hold.") @Nullable QuantityType<Temperature> heatHoldTemp) {
@@ -320,14 +314,17 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
public static boolean setHold(@Nullable ThingActions actions, @Nullable QuantityType<Temperature> coolHoldTemp,
@Nullable QuantityType<Temperature> heatHoldTemp) {
return invokeMethodOf(actions).setHold(coolHoldTemp, heatHoldTemp);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).setHold(coolHoldTemp, heatHoldTemp);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
* Set a hold by providing the cool and heat temperatures and the number of hours.
*/
@Override
@RuleAction(label = "Set Hold", description = "The set hold function sets the thermostat into a hold for the specified number of hours.")
@RuleAction(label = "set the thermostat into hold", description = "The set hold function sets the thermostat into a hold for the specified number of hours.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean setHold(
@ActionInput(name = "coolHoldTemp", description = "The temperature at which to set the cool hold.") @Nullable QuantityType<Temperature> coolHoldTemp,
@ActionInput(name = "heatHoldTemp", description = "The temperature at which to set the heat hold.") @Nullable QuantityType<Temperature> heatHoldTemp,
@@ -348,14 +345,17 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
public static boolean setHold(@Nullable ThingActions actions, @Nullable QuantityType<Temperature> coolHoldTemp,
@Nullable QuantityType<Temperature> heatHoldTemp, @Nullable Number holdHours) {
return invokeMethodOf(actions).setHold(coolHoldTemp, heatHoldTemp, holdHours);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).setHold(coolHoldTemp, heatHoldTemp, holdHours);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
* Set an indefinite hold using the supplied climateRef
*/
@Override
@RuleAction(label = "Set Hold", description = "The set hold function sets the thermostat into a hold with the specified climate ref.")
@RuleAction(label = "set the thermostat into hold", description = "The set hold function sets the thermostat into a hold with the specified climate ref.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean setHold(
@ActionInput(name = "holdClimateRef", description = "The holdClimateRef used to set the hold.") @Nullable String holdClimateRef) {
EcobeeThermostatBridgeHandler localHandler = handler;
@@ -372,14 +372,17 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
}
public static boolean setHold(@Nullable ThingActions actions, @Nullable String holdClimateRef) {
return invokeMethodOf(actions).setHold(holdClimateRef);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).setHold(holdClimateRef);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
* Set a hold using the supplied climateRef for the supplied number of hours.
*/
@Override
@RuleAction(label = "Set Hold", description = "The set hold function sets the thermostat into a hold with the specified climate ref.")
@RuleAction(label = "set the thermostat into hold", description = "The set hold function sets the thermostat into a hold with the specified climate ref.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean setHold(
@ActionInput(name = "holdClimateRef", description = "The holdClimateRef used to set the hold.") @Nullable String holdClimateRef,
@ActionInput(name = "holdHours", description = "The number of hours for the hold.") @Nullable Number holdHours) {
@@ -403,14 +406,17 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
public static boolean setHold(@Nullable ThingActions actions, @Nullable String holdClimateRef,
@Nullable Number holdHours) {
return invokeMethodOf(actions).setHold(holdClimateRef, holdHours);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).setHold(holdClimateRef, holdHours);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
* Set a hold
*/
@Override
@RuleAction(label = "Set Hold", description = "The set hold function sets the thermostat into a hold with the specified temperature or climate ref.")
@RuleAction(label = "set the thermostat into hold", description = "The set hold function sets the thermostat into a hold with the specified temperature or climate ref.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean setHold(
@ActionInput(name = "coolHoldTemp", description = "(opt) The temperature at which to set the cool hold.") @Nullable QuantityType<Temperature> coolHoldTemp,
@ActionInput(name = "heatHoldTemp", description = "(opt) The temperature at which to set the heat hold.") @Nullable QuantityType<Temperature> heatHoldTemp,
@@ -436,15 +442,18 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
@Nullable QuantityType<Temperature> heatHoldTemp, @Nullable String holdClimateRef,
@Nullable Date startDateTime, @Nullable Date endDateTime, @Nullable String holdType,
@Nullable Number holdHours) {
return invokeMethodOf(actions).setHold(coolHoldTemp, heatHoldTemp, holdClimateRef, startDateTime, endDateTime,
holdType, holdHours);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).setHold(coolHoldTemp, heatHoldTemp, holdClimateRef, startDateTime,
endDateTime, holdType, holdHours);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
* Set a hold by providing a parameter map
*/
@Override
@RuleAction(label = "Set Hold", description = "The set hold function sets the thermostat into a hold with the specified event parameters.")
@RuleAction(label = "set the thermostat into hold", description = "The set hold function sets the thermostat into a hold with the specified event parameters.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean setHold(
@ActionInput(name = "params", description = "The map of hold parameters.") @Nullable Map<String, Object> params,
@ActionInput(name = "holdType", description = "(opt) The hold duration type. Valid values: dateTime, nextTransition, indefinite, holdHours.") @Nullable String holdType,
@@ -522,7 +531,11 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
public static boolean setHold(@Nullable ThingActions actions, @Nullable Map<String, Object> params,
@Nullable String holdType, @Nullable Number holdHours, @Nullable Date startDateTime,
@Nullable Date endDateTime) {
return invokeMethodOf(actions).setHold(params, holdType, holdHours, startDateTime, endDateTime);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).setHold(params, holdType, holdHours, startDateTime, endDateTime);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
@@ -532,8 +545,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
* @see <a href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/SetOccupied.shtml">Set
* Occupied</a>
*/
@Override
@RuleAction(label = "Set Occupied", description = "The function switches a thermostat from occupied mode to unoccupied, or vice versa (EMS MODELS ONLY).")
@RuleAction(label = "switch the thermostat occupancy", description = "The function switches a thermostat from occupied mode to unoccupied, or vice versa (EMS MODELS ONLY).")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean setOccupied(
@ActionInput(name = "occupied", description = "The climate to use for the temperature, occupied (true) or unoccupied (false).") @Nullable Boolean occupied,
@ActionInput(name = "startDateTime", description = "(opt) The start date in thermostat time.") @Nullable Date startDateTime,
@@ -555,7 +567,11 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
public static boolean setOccupied(@Nullable ThingActions actions, @Nullable Boolean occupied,
@Nullable Date startDateTime, @Nullable Date endDateTime, @Nullable String holdType,
@Nullable Number holdHours) {
return invokeMethodOf(actions).setOccupied(occupied, startDateTime, endDateTime, holdType, holdHours);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).setOccupied(occupied, startDateTime, endDateTime, holdType, holdHours);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
@@ -564,8 +580,7 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
* @see <a href="https://www.ecobee.com/home/developer/api/documentation/v1/functions/UpdateSensor.shtml">Update
* Sensor</a>
*/
@Override
@RuleAction(label = "Update Sensor", description = "The update sensor function allows the caller to update the name of an ecobee3 remote sensor.")
@RuleAction(label = "update a remote sensor name", description = "The update sensor function allows the caller to update the name of an ecobee3 remote sensor.")
public @ActionOutput(name = "success", type = "java.lang.Boolean") Boolean updateSensor(
@ActionInput(name = "name", description = "The updated name to give the sensor. Has a max length of 32, but shorter is recommended.") @Nullable String name,
@ActionInput(name = "deviceId", description = "The deviceId for the sensor, typically this indicates the enclosure and corresponds to the ThermostatRemoteSensor.id field. For example: rs:100") @Nullable String deviceId,
@@ -582,14 +597,17 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
public static boolean updateSensor(@Nullable ThingActions actions, @Nullable String name, @Nullable String deviceId,
@Nullable String sensorId) {
return invokeMethodOf(actions).updateSensor(name, deviceId, sensorId);
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).updateSensor(name, deviceId, sensorId);
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
* Get the alerts list. Returns a JSON string containing all the alerts.
*/
@Override
@RuleAction(label = "Get Alerts", description = "Get the alerts list")
@RuleAction(label = "get the alerts", description = "Get the alerts list.")
public @ActionOutput(name = "alerts", type = "java.lang.String") @Nullable String getAlerts() {
LOGGER.debug("EcobeeActions: Action 'Get Alerts' called");
EcobeeThermostatBridgeHandler localHandler = handler;
@@ -601,14 +619,17 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
}
public static @Nullable String getAlerts(@Nullable ThingActions actions) {
return invokeMethodOf(actions).getAlerts();
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).getAlerts();
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
* Get the events list. Returns a JSON string contains all events.
*/
@Override
@RuleAction(label = "Get Events", description = "Get the events list")
@RuleAction(label = "get the events", description = "Get the events list.")
public @ActionOutput(name = "events", type = "java.lang.String") @Nullable String getEvents() {
LOGGER.debug("EcobeeActions: Action 'Get Events' called");
EcobeeThermostatBridgeHandler localHandler = handler;
@@ -620,14 +641,17 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
}
public static @Nullable String getEvents(@Nullable ThingActions actions) {
return invokeMethodOf(actions).getEvents();
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).getEvents();
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
/**
* Get a list of climates. Returns a JSON string contains all climates.
*/
@Override
@RuleAction(label = "Get Climates", description = "Get a list of climates")
@RuleAction(label = "get the climates", description = "Get a list of climates.")
public @ActionOutput(name = "climates", type = "java.lang.String") @Nullable String getClimates() {
LOGGER.debug("EcobeeActions: Action 'Get Climates' called");
EcobeeThermostatBridgeHandler localHandler = handler;
@@ -639,6 +663,10 @@ public class EcobeeActions implements ThingActions, IEcobeeActions {
}
public static @Nullable String getClimates(@Nullable ThingActions actions) {
return invokeMethodOf(actions).getClimates();
if (actions instanceof EcobeeActions) {
return ((EcobeeActions) actions).getClimates();
} else {
throw new IllegalArgumentException("Actions is not an instance of EcobeeActions");
}
}
}

View File

@@ -32,7 +32,7 @@ import javax.measure.Unit;
import org.apache.commons.lang.WordUtils;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.ecobee.action.EcobeeActions;
import org.openhab.binding.ecobee.internal.action.EcobeeActions;
import org.openhab.binding.ecobee.internal.api.EcobeeApi;
import org.openhab.binding.ecobee.internal.config.EcobeeThermostatConfiguration;
import org.openhab.binding.ecobee.internal.discovery.SensorDiscoveryService;