Fix shelly switch settings

master
Michael Zanetti 2022-03-18 00:48:22 +01:00
parent fc523cc7e6
commit 3e130a602f
1 changed files with 4 additions and 1 deletions

View File

@ -114,6 +114,7 @@ static QHash<ThingClassId, ParamTypeId> connectedDevice2ParamTypeMap = {
};
static QHash<ThingClassId, ParamTypeId> channelParamTypeMap = {
{shellySwitchThingClassId, shellySwitchThingChannelParamTypeId},
{shellyGenericThingClassId, shellyGenericThingChannelParamTypeId},
{shellyLightThingClassId, shellyLightThingChannelParamTypeId},
{shellySocketThingClassId, shellySocketThingChannelParamTypeId},
@ -1519,7 +1520,7 @@ void IntegrationPluginShelly::setupShellyChild(ThingSetupInfo *info)
url.setScheme("http");
url.setHost(address);
url.setPort(80);
url.setPath(QString("/settings/relay/%1").arg(thing->paramValue(channelParamTypeMap.value(thing->thingClassId())).toInt() + 1));
url.setPath(QString("/settings/relay/%0").arg(thing->paramValue(channelParamTypeMap.value(thing->thingClassId())).toInt() - 1));
url.setUserName(parentDevice->paramValue(usernameParamTypeMap.value(parentDevice->thingClassId())).toString());
url.setPassword(parentDevice->paramValue(passwordParamTypeMap.value(parentDevice->thingClassId())).toString());
@ -1536,6 +1537,8 @@ void IntegrationPluginShelly::setupShellyChild(ThingSetupInfo *info)
url.setQuery(query);
qCDebug(dcShelly) << "Setting configuration:" << url.toString();
QNetworkReply *reply = hardwareManager()->networkManager()->get(QNetworkRequest(url));
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
});