Skip to content

Commit

Permalink
Protects against volume settings out of range, catches exceptions whe…
Browse files Browse the repository at this point in the history
…n sending commands. Fixes openhab#1306 (openhab#1307)

Signed-off-by: Dan Cunningham <[email protected]>
  • Loading branch information
digitaldan authored and kaikreuzer committed Oct 9, 2016
1 parent 7d6e1d0 commit 4c28982
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ public void modeChangeEvent(String mac, String mode) {

@Override
public void volumeChangeEvent(String mac, int volume) {
volume = Math.min(100, volume);
volume = Math.max(0, volume);
updateChannel(mac, CHANNEL_VOLUME, new PercentType(volume));
}

Expand Down Expand Up @@ -409,7 +411,11 @@ private void updateChannel(String mac, String channelID, State state) {
if (prevState == null || !prevState.equals(state)) {
logger.trace("Updating channel {} for thing {} with mac {} to state {}", channelID, getThing().getUID(),
mac, state);
updateState(channelID, state);
try {
updateState(channelID, state);
} catch (Exception e) {
logger.error("Could not update channel", e);
}
}
}
}
Expand Down

0 comments on commit 4c28982

Please sign in to comment.