State and Event distribution

This commit is contained in:
Herb Paar 2021-01-26 00:32:30 +01:00
parent 7c71b48284
commit 4a9cde46e5
2 changed files with 20 additions and 19 deletions

View File

@ -672,7 +672,22 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
// Emit event button pressed
bool on = payload == "1";
if (thing->thingClassId() == shellyI3ThingClassId) {
thing->emitEvent(shellyI3PressEventTypeId, ParamList() << Param(shellyI3PressEventOriginParamTypeId, QString::number(channel +1)));
if (channel == 0) {
if (thing->stateValue(shellyI3Input1StateTypeId).toBool() != on) {
thing->setStateValue(shellyI3Input1StateTypeId, on);
emit emitEvent(Event(shellyI3Input1EventTypeId, thing->id()));
}
} else if (channel == 1) {
if (thing->stateValue(shellyI3Input2StateTypeId).toBool() != on) {
thing->setStateValue(shellyI3Input2StateTypeId, on);
emit emitEvent(Event(shellyI3Input2EventTypeId, thing->id()));
}
} else {
if (thing->stateValue(shellyI3Input3StateTypeId).toBool() != on) {
thing->setStateValue(shellyI3Input3StateTypeId, on);
emit emitEvent(Event(shellyI3Input3EventTypeId, thing->id()));
}
}
return;
}
foreach (Thing *child, myThings().filterByParentId(thing->id())) {
@ -864,7 +879,7 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
QString param = "";
EventTypeId eventTypeId = shellyI3LongPressedEventTypeId;;
ParamTypeId paramTypeId = shellyI3LongPressedEventButtonNameParamTypeId;
ParamTypeId param2TypeId = shellyI3LongPressedEventPressOriginParamTypeId;
ParamTypeId param2TypeId = shellyI3LongPressedEventOriginParamTypeId;
if (event == "L") {
param = "1";
} else if (event == "SL") {
@ -875,7 +890,7 @@ void IntegrationPluginShelly::onPublishReceived(MqttChannel *channel, const QStr
param = QString::number(event.length());
eventTypeId = shellyI3PressedEventTypeId;
paramTypeId = shellyI3PressedEventButtonNameParamTypeId;
param2TypeId = shellyI3PressedEventPressOriginParamTypeId;
param2TypeId = shellyI3PressedEventOriginParamTypeId;
}
QString usedSwitch = QString::number(channel + 1);
thing->emitEvent(eventTypeId, ParamList() << Param(paramTypeId, param) << Param(param2TypeId, usedSwitch));

View File

@ -1200,20 +1200,6 @@
}
],
"eventTypes": [
{
"id": "724d18ff-693b-4a9c-aa72-66557e0069d6",
"name": "press",
"displayName": "Press",
"paramTypes": [
{
"id": "ee2e1728-dfb3-4c0b-a131-0b7798415b2c",
"name": "origin",
"displayName": "Switch",
"type": "QString",
"allowedValues": ["1", "2", "3"]
}
]
},
{
"id": "79648810-b2f4-4aa5-902f-2875242e7bf8",
"name": "pressed",
@ -1228,7 +1214,7 @@
},
{
"id": "0ed31339-7457-443c-b6e3-3b8ce3fc2bd8",
"name": "pressOrigin",
"name": "origin",
"displayName": "Switch",
"type": "QString",
"allowedValues": ["1", "2", "3"]
@ -1249,7 +1235,7 @@
},
{
"id": "866d6db6-e989-4b19-93c3-cc4aa7453c9e",
"name": "pressOrigin",
"name": "origin",
"displayName": "Switch",
"type": "QString",
"allowedValues": ["1", "2", "3"]