made actions async

This commit is contained in:
Boernsman 2020-02-17 11:04:39 +05:00 committed by Michael Zanetti
parent 1dd0cdb6e6
commit 0e1aab8a61
2 changed files with 19 additions and 9 deletions

View File

@ -1,8 +1,14 @@
# DoorBird
This plug-in let'S you capture doorbell pressed and motion events,
you are also able to set the power of the IR and the relays.
This plugin integrates DoorBird video doorbells into nymea. All the communication between nymea and the DoorBird device happens locally and will work without internet connection.
It uses a local connection and will work without Internet.
Currently supported features are:
* Doorbell presses
* Motion events
* Enable/disable IR light
* Switching door relays
The user must have the permission to act as DoorBird API-operator.
You can check the permissions in the DoorBird app.

View File

@ -195,21 +195,25 @@ void DevicePluginDoorbird::executeAction(DeviceActionInfo *info)
if (device->deviceClassId() == doorBirdDeviceClassId) {
Doorbird *doorbird = m_doorbirdConnections.value(device->id());
if (!doorbird) {
qCWarning(dcDoorBird()) << "Doorbird object not found" << device->name();
info->finish(Device::DeviceErrorHardwareFailure);
return;
}
if (action.actionTypeId() == doorBirdOpenDoorActionTypeId) {
int number = action.param(doorBirdOpenDoorActionNumberParamTypeId).value().toInt();
doorbird->openDoor(number);
info->finish(Device::DeviceErrorNoError);
QUuid requestId = doorbird->openDoor(number);
m_asyncActions.insert(requestId, info);
connect(info, &DeviceActionInfo::aborted, this, [requestId, this] {m_asyncActions.remove(requestId);});
return;
} else if (action.actionTypeId() == doorBirdLightOnActionTypeId) {
doorbird->lightOn();
info->finish(Device::DeviceErrorNoError);
QUuid requestId = doorbird->lightOn();
m_asyncActions.insert(requestId, info);
connect(info, &DeviceActionInfo::aborted, this, [requestId, this] {m_asyncActions.remove(requestId);});
return;
} else if (action.actionTypeId() == doorBirdRestartActionTypeId) {
doorbird->restart();
info->finish(Device::DeviceErrorNoError);
QUuid requestId = doorbird->restart();
m_asyncActions.insert(requestId, info);
connect(info, &DeviceActionInfo::aborted, this, [requestId, this] {m_asyncActions.remove(requestId);});
return;
} else {
qCWarning(dcDoorBird()) << "Unhandled ActionTypeId:" << action.actionTypeId();