Fix params on the shelly i3
This commit is contained in:
parent
02791d1411
commit
a4c6a9e52b
@ -1029,25 +1029,26 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
|
|||||||
qCWarning(dcShelly()) << "Failed to parse JSON from shelly:" << error.errorString() << qUtf8Printable(payload);
|
qCWarning(dcShelly()) << "Failed to parse JSON from shelly:" << error.errorString() << qUtf8Printable(payload);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString buttonName = QString::number(channel + 1);
|
||||||
QString event = jsonDoc.toVariant().toMap().value("event").toString();
|
QString event = jsonDoc.toVariant().toMap().value("event").toString();
|
||||||
QString param = "";
|
if (event == "S") {
|
||||||
EventTypeId eventTypeId = shellyI3LongPressedEventTypeId;
|
thing->emitEvent(shellyI3PressedEventTypeId, ParamList() << Param(shellyI3PressedEventButtonNameParamTypeId, buttonName) << Param(shellyI3PressedEventCountParamTypeId, 1));
|
||||||
ParamTypeId paramTypeId = shellyI3LongPressedEventButtonNameParamTypeId;
|
} else if (event == "L") {
|
||||||
ParamTypeId param2TypeId = shellyI3LongPressedEventOriginParamTypeId;
|
thing->emitEvent(shellyI3LongPressedEventTypeId, ParamList() << Param(shellyI3LongPressedEventButtonNameParamTypeId, buttonName));
|
||||||
if (event == "L") {
|
} else if (event == "SS") {
|
||||||
param = "1";
|
thing->emitEvent(shellyI3PressedEventTypeId, ParamList() << Param(shellyI3PressedEventButtonNameParamTypeId, buttonName) << Param(shellyI3PressedEventCountParamTypeId, 2));
|
||||||
|
} else if (event == "SSS") {
|
||||||
|
thing->emitEvent(shellyI3PressedEventTypeId, ParamList() << Param(shellyI3PressedEventButtonNameParamTypeId, buttonName) << Param(shellyI3PressedEventCountParamTypeId, 3));
|
||||||
} else if (event == "SL") {
|
} else if (event == "SL") {
|
||||||
param = "2";
|
thing->emitEvent(shellyI3PressedEventTypeId, ParamList() << Param(shellyI3PressedEventButtonNameParamTypeId, buttonName) << Param(shellyI3PressedEventCountParamTypeId, 1));
|
||||||
|
thing->emitEvent(shellyI3LongPressedEventTypeId, ParamList() << Param(shellyI3LongPressedEventButtonNameParamTypeId, buttonName));
|
||||||
} else if (event == "LS") {
|
} else if (event == "LS") {
|
||||||
param = "3";
|
thing->emitEvent(shellyI3LongPressedEventTypeId, ParamList() << Param(shellyI3LongPressedEventButtonNameParamTypeId, buttonName));
|
||||||
} else { // short press
|
thing->emitEvent(shellyI3PressedEventTypeId, ParamList() << Param(shellyI3PressedEventButtonNameParamTypeId, buttonName) << Param(shellyI3PressedEventCountParamTypeId, 1));
|
||||||
param = QString::number(event.length());
|
} else {
|
||||||
eventTypeId = shellyI3PressedEventTypeId;
|
qCDebug(dcShelly()) << "Invalid button code from shelly I3:" << event;
|
||||||
paramTypeId = shellyI3PressedEventButtonNameParamTypeId;
|
|
||||||
param2TypeId = shellyI3PressedEventOriginParamTypeId;
|
|
||||||
}
|
}
|
||||||
QString usedSwitch = QString::number(channel + 1);
|
|
||||||
thing->emitEvent(eventTypeId, ParamList() << Param(paramTypeId, param) << Param(param2TypeId, usedSwitch));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1268,16 +1268,15 @@
|
|||||||
{
|
{
|
||||||
"id": "146313a1-cfb6-4732-a1be-86ec575bcbdb",
|
"id": "146313a1-cfb6-4732-a1be-86ec575bcbdb",
|
||||||
"name": "buttonName",
|
"name": "buttonName",
|
||||||
"displayName": "Count",
|
"displayName": "Button name",
|
||||||
"type": "QString",
|
"type": "QString",
|
||||||
"allowedValues": ["1", "2", "3"]
|
"allowedValues": ["1", "2", "3"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "0ed31339-7457-443c-b6e3-3b8ce3fc2bd8",
|
"id": "0ed31339-7457-443c-b6e3-3b8ce3fc2bd8",
|
||||||
"name": "origin",
|
"name": "count",
|
||||||
"displayName": "Switch",
|
"displayName": "Press count",
|
||||||
"type": "QString",
|
"type": "uint"
|
||||||
"allowedValues": ["1", "2", "3"]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1289,14 +1288,7 @@
|
|||||||
{
|
{
|
||||||
"id": "99683cf9-930e-4f10-94f2-73bb32092639",
|
"id": "99683cf9-930e-4f10-94f2-73bb32092639",
|
||||||
"name": "buttonName",
|
"name": "buttonName",
|
||||||
"displayName": "Count",
|
"displayName": "Button name",
|
||||||
"type": "QString",
|
|
||||||
"allowedValues": ["1", "2", "3"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "866d6db6-e989-4b19-93c3-cc4aa7453c9e",
|
|
||||||
"name": "origin",
|
|
||||||
"displayName": "Switch",
|
|
||||||
"type": "QString",
|
"type": "QString",
|
||||||
"allowedValues": ["1", "2", "3"]
|
"allowedValues": ["1", "2", "3"]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user