diff --git a/denon/avrconnection.cpp b/denon/avrconnection.cpp index 836242e6..b5b6d6e9 100644 --- a/denon/avrconnection.cpp +++ b/denon/avrconnection.cpp @@ -161,7 +161,7 @@ QUuid AvrConnection::setChannel(const QByteArray &channel) return sendCommand(cmd); } -QUuid AvrConnection::setVolume(int volume) +QUuid AvrConnection::setVolume(uint volume) { qCDebug(dcDenon) << "Set volume" << volume; QByteArray cmd = "MV" + QByteArray::number(volume) + "\r"; diff --git a/denon/avrconnection.h b/denon/avrconnection.h index 32529817..4b0478b9 100644 --- a/denon/avrconnection.h +++ b/denon/avrconnection.h @@ -73,7 +73,7 @@ public: QUuid getPlayBackInfo(); QUuid setChannel(const QByteArray &channel); - QUuid setVolume(int volume); + QUuid setVolume(uint volume); QUuid setMute(bool mute); QUuid setPower(bool power); QUuid setSurroundMode(const QByteArray &surroundMode); diff --git a/denon/integrationplugindenon.cpp b/denon/integrationplugindenon.cpp index fd25d827..89b65a29 100644 --- a/denon/integrationplugindenon.cpp +++ b/denon/integrationplugindenon.cpp @@ -337,13 +337,13 @@ void IntegrationPluginDenon::executeAction(ThingActionInfo *info) } else if (action.actionTypeId() == AVRX1000IncreaseVolumeActionTypeId) { uint step = action.paramValue(AVRX1000IncreaseVolumeActionStepParamTypeId).toUInt(); uint currentVolume = thing->stateValue(AVRX1000VolumeStateTypeId).toUInt(); - QUuid commandId = avrConnection->setVolume(currentVolume+step); + QUuid commandId = avrConnection->setVolume(qMin(100, currentVolume + step)); connect(info, &ThingActionInfo::aborted, [this, commandId] {m_avrPendingActions.remove(commandId);}); m_avrPendingActions.insert(commandId, info); } else if (action.actionTypeId() == AVRX1000DecreaseVolumeActionTypeId) { uint step = action.paramValue(AVRX1000DecreaseVolumeActionStepParamTypeId).toUInt(); uint currentVolume = thing->stateValue(AVRX1000VolumeStateTypeId).toUInt(); - QUuid commandId = avrConnection->setVolume(currentVolume-step); + QUuid commandId = avrConnection->setVolume(qMax(0, currentVolume - step)); connect(info, &ThingActionInfo::aborted, [this, commandId] {m_avrPendingActions.remove(commandId);}); m_avrPendingActions.insert(commandId, info); } else if (action.actionTypeId() == AVRX1000SurroundModeActionTypeId) {