Adjust media plugins to new interfaces

This commit is contained in:
Michael Zanetti 2020-11-21 20:19:22 +01:00
parent 8d341a58b6
commit a2231102dc
10 changed files with 183 additions and 28 deletions

View File

@ -40,6 +40,7 @@
#include <QStringList>
#include <QJsonDocument>
#include <QTimer>
#include <QtGlobal>
IntegrationPluginBluOS::IntegrationPluginBluOS()
@ -207,6 +208,16 @@ void IntegrationPluginBluOS::executeAction(ThingActionInfo *info)
}
m_asyncActions.insert(requestId, info);
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
} else if (action.actionTypeId() == bluosPlayerIncreaseVolumeActionTypeId) {
uint step = action.param(bluosPlayerIncreaseVolumeActionStepParamTypeId).value().toUInt();
QUuid requestId = bluos->setVolume(qMin<uint>(100, thing->stateValue(bluosPlayerVolumeStateTypeId).toUInt() + step));
m_asyncActions.insert(requestId, info);
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
} else if (action.actionTypeId() == bluosPlayerDecreaseVolumeActionTypeId) {
uint step = action.param(bluosPlayerDecreaseVolumeActionStepParamTypeId).value().toUInt();
QUuid requestId = bluos->setVolume(qMax<uint>(0, thing->stateValue(bluosPlayerVolumeStateTypeId).toUInt() - step));
m_asyncActions.insert(requestId, info);
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
} else {
qCWarning(dcBluOS()) << "Execute Action, unhandled action type id" << action.actionTypeId();
return info->finish(Thing::ThingErrorThingClassNotFound);

View File

@ -13,7 +13,7 @@
"name": "bluosPlayer",
"displayName": "BluOS player",
"createMethods": ["discovery"],
"interfaces": ["mediaplayer", "extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "connectable"],
"interfaces": ["mediaplayer", "volumecontroller", "mediametadataprovider", "connectable"],
"browsable": true,
"paramTypes":[
{
@ -189,6 +189,38 @@
"id": "30930095-6f97-48ef-8bbf-597d734f0751",
"name": "skipNext",
"displayName": "Skip next"
},
{
"id": "83db3d84-9bbd-4a83-9f4e-97424db8979f",
"name": "increaseVolume",
"displayName": "Increase volume",
"paramTypes": [
{
"id": "d3660462-08ae-4ba5-b240-1ab20d19c504",
"name": "step",
"displayName": "Step size",
"type": "uint",
"minValue": 0,
"maxValue": 100,
"defaultValue": 5
}
]
},
{
"id": "dc04db5b-8396-44b1-afd7-9448f6be5453",
"name": "decreaseVolume",
"displayName": "Decrease volume",
"paramTypes": [
{
"id": "15ca69da-2b83-46e7-a474-c904c86de3c5",
"name": "step",
"displayName": "Step size",
"type": "uint",
"minValue": 0,
"maxValue": 100,
"defaultValue": 5
}
]
}
]
}

View File

@ -303,6 +303,16 @@ void IntegrationPluginBose::executeAction(ThingActionInfo *info)
QUuid requestId = soundTouch->setSpeaker(playInfo);
m_pendingActions.insert(requestId, info);
connect(info, &ThingActionInfo::aborted, this, [requestId, this] {m_pendingActions.remove(requestId);});
} else if (action.actionTypeId() == soundtouchIncreaseVolumeActionTypeId) {
int step = action.param(soundtouchIncreaseVolumeActionStepParamTypeId).value().toInt();
QUuid requestId = soundTouch->setVolume(qMin(100, thing->stateValue(soundtouchVolumeStateTypeId).toInt() + step));
m_pendingActions.insert(requestId, info);
connect(info, &ThingActionInfo::aborted, this, [requestId, this] {m_pendingActions.remove(requestId);});
} else if (action.actionTypeId() == soundtouchDecreaseVolumeActionTypeId) {
int step = action.param(soundtouchDecreaseVolumeActionStepParamTypeId).value().toInt();
QUuid requestId = soundTouch->setVolume(qMax(0, thing->stateValue(soundtouchVolumeStateTypeId).toInt() - step));
m_pendingActions.insert(requestId, info);
connect(info, &ThingActionInfo::aborted, this, [requestId, this] {m_pendingActions.remove(requestId);});
} else {
qCWarning(dcBose()) << "ActionTypeId not found" << action.actionTypeId();
return info->finish(Thing::ThingErrorActionTypeNotFound);

View File

@ -43,7 +43,7 @@
"id": "f9b7a3f5-6353-48b1-afc1-66f914412f82",
"name": "soundtouch",
"displayName": "SoundTouch",
"interfaces": ["extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "alert", "connectable"],
"interfaces": ["mediaplayer", "volumecontroller", "mediametadataprovider", "alert", "connectable"],
"createMethods": ["discovery"],
"browsable": true,
"paramTypes": [
@ -103,6 +103,15 @@
"defaultValue": 50,
"writable": true
},
{
"id": "f784072d-b8da-4c8f-9497-dccf38aa9b16",
"name": "playerType",
"displayName": "Player type",
"displayNameEvent": "Player type changed",
"type": "QString",
"possibleValues": ["audio", "video"],
"defaultValue": "audio"
},
{
"id": "2dd512b7-40c2-488e-8d4f-6519edaa6f74",
"name": "playbackStatus",
@ -286,6 +295,38 @@
"defaultValue": "40"
}
]
},
{
"id": "d0169ff4-f5a5-4db2-8ef0-b819d3022bde",
"name": "increaseVolume",
"displayName": "Increase volume",
"paramTypes": [
{
"id": "a5c6adeb-ea2a-4bcd-b844-e6fd2d946dbe",
"name": "step",
"displayName": "Step size",
"type": "uint",
"minValue": 0,
"maxValue": 100,
"defaultValue": 5
}
]
},
{
"id": "30873274-7662-42ec-ac31-2ef709e430ca",
"name": "decreaseVolume",
"displayName": "Decrease volume",
"paramTypes": [
{
"id": "0e8e1c20-ede5-4778-b36e-a8f72893e45b",
"name": "step",
"displayName": "Step size",
"type": "uint",
"minValue": 0,
"maxValue": 100,
"defaultValue": 5
}
]
}
]
}

View File

@ -329,8 +329,8 @@ void IntegrationPluginDenon::executeAction(ThingActionInfo *info)
QUuid commandId = avrConnection->setVolume(vol);
connect(info, &ThingActionInfo::aborted, [this, commandId] {m_avrPendingActions.remove(commandId);});
m_avrPendingActions.insert(commandId, info);
} else if (action.actionTypeId() == AVRX1000ChannelActionTypeId) {
QByteArray channel = action.param(AVRX1000ChannelActionChannelParamTypeId).value().toByteArray();
} else if (action.actionTypeId() == AVRX1000InputSourceActionTypeId) {
QByteArray channel = action.param(AVRX1000InputSourceActionInputSourceParamTypeId).value().toByteArray();
QUuid commandId = avrConnection->setChannel(channel);
connect(info, &ThingActionInfo::aborted, [this, commandId] {m_avrPendingActions.remove(commandId);});
m_avrPendingActions.insert(commandId, info);
@ -466,6 +466,14 @@ void IntegrationPluginDenon::executeAction(ThingActionInfo *info)
} else if (action.actionTypeId() == heosPlayerSkipNextActionTypeId) {
heos->playNext(playerId);
return info->finish(Thing::ThingErrorNoError);
} else if (action.actionTypeId() == heosPlayerIncreaseVolumeActionTypeId) {
heos->volumeUp(playerId, action.param(heosPlayerIncreaseVolumeActionStepParamTypeId).value().toInt());
info->finish(Thing::ThingErrorNoError);
return;
} else if (action.actionTypeId() == heosPlayerDecreaseVolumeActionTypeId) {
heos->volumeUp(playerId, action.param(heosPlayerDecreaseVolumeActionStepParamTypeId).value().toInt());
info->finish(Thing::ThingErrorNoError);
return;
} else {
qCWarning(dcDenon()) << "ActionType not found" << thing->thingClass().name() << action.actionTypeId() ;
return info->finish(Thing::ThingErrorActionTypeNotFound);
@ -603,7 +611,7 @@ void IntegrationPluginDenon::onAvrChannelChanged(const QString &channel)
return;
if (thing->thingClassId() == AVRX1000ThingClassId) {
thing->setStateValue(AVRX1000ChannelStateTypeId, channel);
thing->setStateValue(AVRX1000InputSourceStateTypeId, channel);
}
}

View File

@ -22,7 +22,7 @@
"name": "AVRX1000",
"displayName": "AVR X1000",
"createMethods": ["discovery"],
"interfaces": ["mediaplayer", "mediacontroller", "extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "connectable", "power"],
"interfaces": ["mediaplayer", "mediacontroller", "volumecontroller", "mediametadataprovider", "connectable", "power"],
"paramTypes": [
{
"id": "cb6eeeb0-3d75-43b6-8177-b5ac19648557",
@ -117,7 +117,7 @@
{
"displayName": "Channel",
"id": "f29ffa2c-31d6-4d88-b160-a38288c82ce1",
"name": "channel",
"name": "inputSource",
"displayNameEvent": "Channel changed",
"displayNameAction": "Set channel",
"type": "QString",
@ -255,28 +255,12 @@
{
"id": "4ae686d6-2307-40a0-bd38-2cd3a92342cc",
"displayName": "Increase volume",
"name": "increaseVolume",
"paramTypes": [
{
"id": "765c7e2a-9eb6-46fc-a880-4e96c81f8d1e",
"displayName": "Step",
"name": "step",
"type": "int"
}
]
"name": "increaseVolume"
},
{
"id": "d3752c32-92e3-4396-8e2f-ab5e57c6cfb1",
"displayName": "Decrease volume",
"name": "decreaseVolume",
"paramTypes": [
{
"id": "1d54fda8-336c-436f-ab2b-e8bd549f830c",
"displayName": "Step",
"name": "step",
"type": "int"
}
]
"name": "decreaseVolume"
},
{
"id": "3f2eb789-918c-475a-a295-14c0c24338b8",
@ -374,7 +358,7 @@
"name": "heosPlayer",
"displayName": "Heos player",
"createMethods": ["auto"],
"interfaces": ["mediaplayer", "mediacontroller", "extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "alert", "connectable"],
"interfaces": ["mediaplayer", "mediacontroller", "volumecontroller", "mediametadataprovider", "alert", "connectable"],
"browsable": true,
"paramTypes":[
{
@ -553,6 +537,38 @@
"id": "57697e9c-ce5e-4b8f-b42e-16662829ceb2",
"name": "skipNext",
"displayName": "Skip next"
},
{
"id": "ebdc35f8-24a2-4984-855e-4c1a158289b7",
"name": "increaseVolume",
"displayName": "Increase volume",
"paramTypes": [
{
"id": "0770da3f-61c3-4145-b0d8-348f42a8cf0d",
"name": "step",
"displayName": "Step size",
"type": "uint",
"minValue": 0,
"maxValue": 10,
"defaultValue": 5
}
]
},
{
"id": "e19cc4e0-00ef-4df4-8314-85902017d095",
"name": "decreaseVolume",
"displayName": "Decrease volume",
"paramTypes": [
{
"id": "ef5a252b-3d28-4817-a668-1dacf0ed1f8a",
"name": "step",
"displayName": "Step size",
"type": "uint",
"minValue": 0,
"maxValue": 10,
"defaultValue": 5
}
]
}
],
"browserItemActionTypes": [

View File

@ -324,6 +324,10 @@ void IntegrationPluginKodi::executeAction(ThingActionInfo *info)
commandId = kodi->navigate("skipnext");
} else if (action.actionTypeId() == kodiShuffleActionTypeId) {
commandId = kodi->setShuffle(action.param(kodiShuffleActionShuffleParamTypeId).value().toBool());
} else if (action.actionTypeId() == kodiIncreaseVolumeActionTypeId) {
commandId = kodi->setVolume(qMin(100, thing->stateValue(kodiVolumeStateTypeId).toInt() + 5));
} else if (action.actionTypeId() == kodiDecreaseVolumeActionTypeId) {
commandId = kodi->setVolume(qMax(0, thing->stateValue(kodiVolumeStateTypeId).toInt() - 5));
} else if (action.actionTypeId() == kodiRepeatActionTypeId) {
QString repeat = action.param(kodiRepeatActionRepeatParamTypeId).value().toString();
if (repeat == "One") {

View File

@ -12,7 +12,7 @@
"id": "d09953e3-c5bd-415b-973b-0d0bf2be3f69",
"name": "kodi",
"displayName": "Kodi",
"interfaces": ["mediaplayer", "extendedmediacontroller", "extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "notifications", "extendednavigationpad", "connectable"],
"interfaces": ["mediaplayer", "mediacontroller", "volumecontroller", "mediametadataprovider", "notifications", "extendednavigationpad", "connectable"],
"createMethods": ["user", "discovery"],
"browsable": true,
"paramTypes": [
@ -204,6 +204,16 @@
"name": "skipNext",
"displayName": "skipNext"
},
{
"id": "3ec57983-01e7-4cc4-b266-8de86dfca82d",
"name": "increaseVolume",
"displayName": "Increase volume"
},
{
"id": "54497942-9bf8-492a-8f9c-9820a03e754e",
"name": "decreaseVolume",
"displayName": "Decrease volume"
},
{
"id": "dc0aa3b5-4eae-4e58-a4ac-d4c124da53f1",
"name": "notify",

View File

@ -342,6 +342,19 @@ void IntegrationPluginSonos::executeAction(ThingActionInfo *info)
}
return;
}
if (action.actionTypeId() == sonosGroupIncreaseVolumeActionTypeId) {
int volume = qMin(100, thing->stateValue(sonosGroupVolumeStateTypeId).toInt() + 5);
m_pendingActions.insert(sonos->setGroupVolume(groupId, volume), QPointer<ThingActionInfo>(info));
return;
}
if (action.actionTypeId() == sonosGroupDecreaseVolumeActionTypeId) {
int volume = qMax(0, thing->stateValue(sonosGroupVolumeStateTypeId).toInt() - 5);
m_pendingActions.insert(sonos->setGroupVolume(groupId, volume), QPointer<ThingActionInfo>(info));
return;
}
return info->finish(Thing::ThingErrorActionTypeNotFound);
}
info->finish(Thing::ThingErrorThingClassNotFound);

View File

@ -50,7 +50,7 @@
"id": "72d9332b-2b25-4136-87a6-e534eae4cc80",
"name": "sonosGroup",
"displayName": "Sonos group",
"interfaces": ["extendedvolumecontroller", "mediametadataprovider", "shufflerepeat", "connectable"],
"interfaces": ["mediacontroller", "volumecontroller", "mediametadataprovider", "connectable"],
"createMethods": ["auto"],
"browsable": true,
"paramTypes": [
@ -211,6 +211,16 @@
"id": "85d7126a-b123-4a28-aeb4-d84bcfb4d14f",
"name": "skipNext",
"displayName": "Skip Next"
},
{
"id": "02abbda5-d23c-4fde-84cf-09782f319804",
"name": "increaseVolume",
"displayName": "Increase volume"
},
{
"id": "7f71d0f7-3950-46fb-a785-f16f9c3fd85f",
"name": "decreaseVolume",
"displayName": "Decrease volume"
}
],
"browserItemActionTypes": [