Skip to content

Commit

Permalink
[atlona] Make volume a whole number & remove StringUtils (openhab#9631)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Lobstein <[email protected]>
  • Loading branch information
mlobstein authored and thinkingstone committed Nov 7, 2021
1 parent 8517b8f commit 9093378
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import org.apache.commons.lang.StringUtils;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.openhab.core.types.State;
Expand Down Expand Up @@ -88,7 +87,7 @@ public void statusChanged(ThingStatus status, ThingStatusDetail detail, String m
*/
@Override
public void stateChanged(String channelId, State state) {
if (StringUtils.isEmpty(channelId)) {
if (channelId == null || "".equals(channelId)) {
return;
}

Expand Down Expand Up @@ -116,7 +115,7 @@ public void stateChanged(String channelId, State state) {
* @param channelId the channel id to remove state
*/
public void removeState(String channelId) {
if (StringUtils.isEmpty(channelId)) {
if (channelId == null || "".equals(channelId)) {
return;
}
state.remove(channelId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
break;
case AtlonaPro3Constants.CHANNEL_VOLUME:
if (command instanceof DecimalType) {
final double level = ((DecimalType) command).doubleValue();
final int level = ((DecimalType) command).intValue();
atlonaHandler.setVolume(portNbr, level);
} else {
logger.debug("Received a VOLUME channel command with a non DecimalType: {}", command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;
import org.openhab.binding.atlona.internal.AtlonaHandlerCallback;
import org.openhab.binding.atlona.internal.net.SocketSession;
import org.openhab.binding.atlona.internal.net.SocketSessionListener;
Expand Down Expand Up @@ -599,7 +598,7 @@ void removePortMirror(int hdmiPortNbr) {
* @param portNbr a greater than zero port number
* @param level a volume level in decibels (must range from -79 to +15)
*/
void setVolume(int portNbr, double level) {
void setVolume(int portNbr, int level) {
if (portNbr <= 0) {
throw new IllegalArgumentException("portNbr must be greater than 0");
}
Expand Down Expand Up @@ -906,7 +905,7 @@ private void handleMirrorResponse(Matcher m, String resp) {
int hdmiPortNbr = Integer.parseInt(m.group(1));

// could be "off" (if mirror off), "on"/"Out" (with 3rd group representing out)
String oper = StringUtils.trimToEmpty(m.group(2)).toLowerCase();
String oper = (m.group(2) == null ? "" : m.group(2).trim()).toLowerCase();

if (oper.equals("off")) {
callback.stateChanged(AtlonaPro3Utilities.createChannelID(AtlonaPro3Constants.GROUP_MIRROR,
Expand Down

0 comments on commit 9093378

Please sign in to comment.