Fix min/max for stepSize

This commit is contained in:
Michael Zanetti 2020-12-11 17:55:05 +01:00
parent 4101dfb617
commit 63068c6db7
3 changed files with 4 additions and 4 deletions

View File

@ -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";

View File

@ -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);

View File

@ -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<uint>(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<uint>(0, currentVolume - step));
connect(info, &ThingActionInfo::aborted, [this, commandId] {m_avrPendingActions.remove(commandId);});
m_avrPendingActions.insert(commandId, info);
} else if (action.actionTypeId() == AVRX1000SurroundModeActionTypeId) {