Remove deprecated handleUpdate from ThingHandler (#8558)

The handleUpdate method was deprecated when profiles were introduced (see eclipse-archived/smarthome#4108).
Instead the "follow profile" can be used which forwards item updates as commands to handlers.
This profile works with any binding instead of only those that implement the handleUpdate method.

Related to openhab/openhab-core#1669

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2020-09-24 17:50:47 +02:00 committed by GitHub
parent 4d67ef2a6b
commit cc042dabff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 4 additions and 88 deletions

View File

@ -202,20 +202,20 @@ public class Cm11aBridgeHandler extends BaseBridgeHandler implements ReceivedDat
// Perform appropriate update based on X10Command received
// Handle ON/OFF commands
if (cmd == X10ReceivedData.X10COMMAND.ON) {
handleUpdate(channelUid, OnOffType.ON);
updateState(channelUid, OnOffType.ON);
handler.setCurrentState(OnOffType.ON);
} else if (cmd == X10ReceivedData.X10COMMAND.OFF) {
handleUpdate(channelUid, OnOffType.OFF);
updateState(channelUid, OnOffType.OFF);
handler.setCurrentState(OnOffType.OFF);
// Handle DIM/Bright commands
} else if (cmd == X10ReceivedData.X10COMMAND.DIM) {
State newState = handler.addDimsToCurrentState(dims);
handleUpdate(channelUid, newState);
updateState(channelUid, newState);
handler.setCurrentState(newState);
logger.debug("Current state set to: {}", handler.getCurrentState().toFullString());
} else if (cmd == X10ReceivedData.X10COMMAND.BRIGHT) {
State newState = handler.addBrightsToCurrentState(dims);
handleUpdate(channelUid, newState);
updateState(channelUid, newState);
handler.setCurrentState(newState);
logger.debug("Current state set to: {}", handler.getCurrentState().toFullString());
} else {
@ -223,16 +223,6 @@ public class Cm11aBridgeHandler extends BaseBridgeHandler implements ReceivedDat
}
}
/**
* The default implementation of this method doesn't do anything. We need it to update the ui as done by the
* updateState function.
* And, update state can not be called directly because it is protected
*/
@Override
public void handleUpdate(ChannelUID channelUID, State newState) {
updateState(channelUID, newState);
}
/**
* Get the X10Interface
*

View File

@ -27,7 +27,6 @@ import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.binding.BaseBridgeHandler;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import tuwien.auto.calimero.IndividualAddress;
import tuwien.auto.calimero.mgmt.Destination;
@ -51,11 +50,6 @@ public abstract class KNXBridgeBaseThingHandler extends BaseBridgeHandler implem
protected abstract KNXClient getClient();
@Override
public void handleUpdate(ChannelUID channelUID, State newState) {
// Nothing to do here
}
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
// Nothing to do here

View File

@ -27,7 +27,6 @@ import org.openhab.core.library.types.PercentType;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
/**
* Handler for RadioRA dimmers
@ -76,14 +75,6 @@ public class DimmerHandler extends LutronHandler {
}
}
@Override
public void handleUpdate(ChannelUID channelUID, State newState) {
if (LutronBindingConstants.CHANNEL_LIGHTLEVEL.equals(channelUID.getId())) {
PercentType percent = (PercentType) newState.as(PercentType.class);
updateInternalState(percent.intValue());
}
}
@Override
public void handleFeedback(RadioRAFeedback feedback) {
if (feedback instanceof LocalZoneChangeFeedback) {

View File

@ -22,7 +22,6 @@ import org.openhab.core.library.types.PercentType;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -127,28 +126,6 @@ public class XiaomiActorGatewayHandler extends XiaomiActorBaseHandler {
logger.debug("Changed volume to {}", lastVolume);
}
@Override
public void handleUpdate(ChannelUID channelUID, State newState) {
logger.debug("Update {} for channel {} received", newState, channelUID);
switch (channelUID.getId()) {
case CHANNEL_BRIGHTNESS:
if (newState instanceof PercentType) {
lastBrigthness = ((PercentType) newState).intValue();
}
break;
case CHANNEL_COLOR:
if (newState instanceof HSBType) {
lastColor = ((HSBType) newState).getRGB();
}
break;
case CHANNEL_GATEWAY_VOLUME:
if (newState instanceof DecimalType) {
updateLastVolume((DecimalType) newState);
}
break;
}
}
@Override
void parseReport(JsonObject data) {
parseDefault(data);

View File

@ -16,9 +16,7 @@ import java.util.Timer;
import java.util.TimerTask;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing;
import org.openhab.core.types.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -87,14 +85,4 @@ public abstract class XiaomiSensorBaseHandlerWithTimer extends XiaomiSensorBaseH
timerSetpoint = defaultTimer;
}
}
@Override
public void handleUpdate(ChannelUID channelUID, State newState) {
if (setpointChannel.equals(channelUID.getId())) {
if (newState instanceof DecimalType) {
logger.debug("Received update for timer setpoint channel: {}", newState);
timerSetpoint = ((DecimalType) newState).intValue();
}
}
}
}

View File

@ -20,7 +20,6 @@ import java.util.Map;
import java.util.Map.Entry;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.StopMoveType;
@ -125,14 +124,6 @@ public class PHCHandler extends BaseThingHandler {
}
}
@Override
public void handleUpdate(ChannelUID channelUID, State newState) {
if (CHANNELS_JRM_TIME.equals(channelUID.getGroupId())) {
times[Integer
.parseInt(channelUID.getIdWithoutGroup())] = (short) (((DecimalType) newState).floatValue() * 10);
}
}
@Override
public void handleConfigurationUpdate(Map<String, Object> configurationParameters) {
if (isInitialized()) { // prevents change of address

View File

@ -36,7 +36,6 @@ import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.thing.binding.BaseBridgeHandler;
import org.openhab.core.types.Command;
import org.openhab.core.types.RefreshType;
import org.openhab.core.types.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tellstick.device.TellstickDeviceEvent;
@ -247,11 +246,6 @@ public class TelldusLiveBridgeHandler extends BaseBridgeHandler implements Telld
super.handleRemoval();
}
@Override
public void handleUpdate(ChannelUID channelUID, State newState) {
super.handleUpdate(channelUID, newState);
}
@Override
public void thingUpdated(Thing thing) {
super.thingUpdated(thing);

View File

@ -82,7 +82,6 @@ public class ExecTransformationProfile implements StateProfile {
@Override
public void onStateUpdateFromItem(State state) {
callback.handleUpdate(state);
}
@Override

View File

@ -84,7 +84,6 @@ public class JavascriptTransformationProfile implements StateProfile {
@Override
public void onStateUpdateFromItem(State state) {
callback.handleUpdate(state);
}
@Override

View File

@ -83,7 +83,6 @@ public class JinjaTransformationProfile implements StateProfile {
@Override
public void onStateUpdateFromItem(State state) {
callback.handleUpdate(state);
}
@Override

View File

@ -84,7 +84,6 @@ public class JSonPathTransformationProfile implements StateProfile {
@Override
public void onStateUpdateFromItem(State state) {
callback.handleUpdate(state);
}
@Override

View File

@ -83,7 +83,6 @@ public class MapTransformationProfile implements StateProfile {
@Override
public void onStateUpdateFromItem(State state) {
callback.handleUpdate(state);
}
@Override

View File

@ -83,7 +83,6 @@ public class RegexTransformationProfile implements StateProfile {
@Override
public void onStateUpdateFromItem(State state) {
callback.handleUpdate(state);
}
@Override

View File

@ -83,7 +83,6 @@ public class ScaleTransformationProfile implements StateProfile {
@Override
public void onStateUpdateFromItem(State state) {
callback.handleUpdate(state);
}
@Override

View File

@ -83,7 +83,6 @@ public class XPathTransformationProfile implements StateProfile {
@Override
public void onStateUpdateFromItem(State state) {
callback.handleUpdate(state);
}
@Override

View File

@ -83,7 +83,6 @@ public class XSLTTransformationProfile implements StateProfile {
@Override
public void onStateUpdateFromItem(State state) {
callback.handleUpdate(state);
}
@Override