add mqtt client plugin to debian files and rename it
parent
933cd77d6d
commit
0363694c2c
|
|
@ -285,6 +285,22 @@ Description: nymea.io plugin for mailnotification
|
||||||
This package will install the nymea.io plugin for mailnotification
|
This package will install the nymea.io plugin for mailnotification
|
||||||
|
|
||||||
|
|
||||||
|
Package: nymea-plugin-mqttclient
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends},
|
||||||
|
${misc:Depends},
|
||||||
|
nymea-plugins-translations,
|
||||||
|
Replaces: guh-plugin-mqtt
|
||||||
|
Description: nymea.io plugin for a generic MQTT client
|
||||||
|
The nymea daemon is a plugin based IoT (Internet of Things) server. The
|
||||||
|
server works like a translator for devices, things and services and
|
||||||
|
allows them to interact.
|
||||||
|
With the powerful rule engine you are able to connect any device available
|
||||||
|
in the system and create individual scenes and behaviors for your environment.
|
||||||
|
.
|
||||||
|
This package will install a generic MQTT client plugin for nymea.io
|
||||||
|
|
||||||
|
|
||||||
Package: nymea-plugin-netatmo
|
Package: nymea-plugin-netatmo
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: ${shlibs:Depends},
|
Depends: ${shlibs:Depends},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_devicepluginmqttclient.so
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
include(../plugins.pri)
|
|
||||||
|
|
||||||
QT += network
|
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_devicepluginmqtt)
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
devicepluginmqtt.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
devicepluginmqtt.h
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -48,22 +48,22 @@
|
||||||
|
|
||||||
For more details how to read this JSON file please check out the documentation for \l{The plugin JSON File}.
|
For more details how to read this JSON file please check out the documentation for \l{The plugin JSON File}.
|
||||||
|
|
||||||
\quotefile plugins/deviceplugins/mqtt/devicepluginmqtt.json
|
\quotefile plugins/deviceplugins/mqtt/devicepluginmqttclient.json
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "devicepluginmqtt.h"
|
#include "devicepluginmqttclient.h"
|
||||||
#include "plugin/device.h"
|
#include "plugin/device.h"
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "network/mqtt/mqttprovider.h"
|
#include "network/mqtt/mqttprovider.h"
|
||||||
|
|
||||||
#include "nymea-mqtt/mqttclient.h"
|
#include "nymea-mqtt/mqttclient.h"
|
||||||
|
|
||||||
DevicePluginMqtt::DevicePluginMqtt()
|
DevicePluginMqttClient::DevicePluginMqttClient()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceManager::DeviceSetupStatus DevicePluginMqtt::setupDevice(Device *device)
|
DeviceManager::DeviceSetupStatus DevicePluginMqttClient::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
MqttClient *client = nullptr;
|
MqttClient *client = nullptr;
|
||||||
if (device->deviceClassId() == internalMqttClientDeviceClassId) {
|
if (device->deviceClassId() == internalMqttClientDeviceClassId) {
|
||||||
|
|
@ -83,8 +83,8 @@ DeviceManager::DeviceSetupStatus DevicePluginMqtt::setupDevice(Device *device)
|
||||||
Q_UNUSED(packetId)
|
Q_UNUSED(packetId)
|
||||||
emit deviceSetupFinished(device, returnCodes.first() == Mqtt::SubscribeReturnCodeFailure ? DeviceManager::DeviceSetupStatusFailure : DeviceManager::DeviceSetupStatusSuccess);
|
emit deviceSetupFinished(device, returnCodes.first() == Mqtt::SubscribeReturnCodeFailure ? DeviceManager::DeviceSetupStatusFailure : DeviceManager::DeviceSetupStatusSuccess);
|
||||||
});
|
});
|
||||||
connect(client, &MqttClient::publishReceived, this, &DevicePluginMqtt::publishReceived);
|
connect(client, &MqttClient::publishReceived, this, &DevicePluginMqttClient::publishReceived);
|
||||||
connect(client, &MqttClient::published, this, &DevicePluginMqtt::published);
|
connect(client, &MqttClient::published, this, &DevicePluginMqttClient::published);
|
||||||
// In case we're already connected, manually call subscribe now
|
// In case we're already connected, manually call subscribe now
|
||||||
if (client->isConnected()) {
|
if (client->isConnected()) {
|
||||||
subscribe(device);
|
subscribe(device);
|
||||||
|
|
@ -94,7 +94,7 @@ DeviceManager::DeviceSetupStatus DevicePluginMqtt::setupDevice(Device *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DeviceManager::DeviceError DevicePluginMqtt::executeAction(Device *device, const Action &action)
|
DeviceManager::DeviceError DevicePluginMqttClient::executeAction(Device *device, const Action &action)
|
||||||
{
|
{
|
||||||
ParamTypeId topicParamTypeId = internalMqttClientTriggerActionTopicParamTypeId;
|
ParamTypeId topicParamTypeId = internalMqttClientTriggerActionTopicParamTypeId;
|
||||||
ParamTypeId payloadParamTypeId = internalMqttClientTriggerActionDataParamTypeId;
|
ParamTypeId payloadParamTypeId = internalMqttClientTriggerActionDataParamTypeId;
|
||||||
|
|
@ -134,7 +134,7 @@ DeviceManager::DeviceError DevicePluginMqtt::executeAction(Device *device, const
|
||||||
return DeviceManager::DeviceErrorAsync;
|
return DeviceManager::DeviceErrorAsync;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePluginMqtt::subscribe(Device *device)
|
void DevicePluginMqttClient::subscribe(Device *device)
|
||||||
{
|
{
|
||||||
MqttClient *client = m_clients.value(device);
|
MqttClient *client = m_clients.value(device);
|
||||||
if (!client) {
|
if (!client) {
|
||||||
|
|
@ -148,7 +148,7 @@ void DevicePluginMqtt::subscribe(Device *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePluginMqtt::publishReceived(const QString &topic, const QByteArray &payload, bool retained)
|
void DevicePluginMqttClient::publishReceived(const QString &topic, const QByteArray &payload, bool retained)
|
||||||
{
|
{
|
||||||
qCDebug(dcMqttclient()) << "Publish received" << topic << payload << retained;
|
qCDebug(dcMqttclient()) << "Publish received" << topic << payload << retained;
|
||||||
|
|
||||||
|
|
@ -171,7 +171,7 @@ void DevicePluginMqtt::publishReceived(const QString &topic, const QByteArray &p
|
||||||
emitEvent(Event(eventTypeId, device->id(), ParamList() << Param(topicParamTypeId, topic) << Param(payloadParamTypeId, payload)));
|
emitEvent(Event(eventTypeId, device->id(), ParamList() << Param(topicParamTypeId, topic) << Param(payloadParamTypeId, payload)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePluginMqtt::published(quint16 packetId)
|
void DevicePluginMqttClient::published(quint16 packetId)
|
||||||
{
|
{
|
||||||
if (!m_pendingPublishes.contains(packetId)) {
|
if (!m_pendingPublishes.contains(packetId)) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -180,7 +180,7 @@ void DevicePluginMqtt::published(quint16 packetId)
|
||||||
emit actionExecutionFinished(m_pendingPublishes.take(packetId).id(), DeviceManager::DeviceErrorNoError);
|
emit actionExecutionFinished(m_pendingPublishes.take(packetId).id(), DeviceManager::DeviceErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DevicePluginMqtt::deviceRemoved(Device *device)
|
void DevicePluginMqttClient::deviceRemoved(Device *device)
|
||||||
{
|
{
|
||||||
qCDebug(dcMqttclient) << device;
|
qCDebug(dcMqttclient) << device;
|
||||||
m_clients.take(device)->deleteLater();
|
m_clients.take(device)->deleteLater();
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
* *
|
* *
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#ifndef DEVICEPLUGINMQTT_H
|
#ifndef DEVICEPLUGINMQTTCLIENT_H
|
||||||
#define DEVICEPLUGINMQTT_H
|
#define DEVICEPLUGINMQTTCLIENT_H
|
||||||
|
|
||||||
#include "plugin/deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
|
|
||||||
|
|
@ -31,14 +31,14 @@
|
||||||
|
|
||||||
class MqttClient;
|
class MqttClient;
|
||||||
|
|
||||||
class DevicePluginMqtt: public DevicePlugin
|
class DevicePluginMqttClient: public DevicePlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID "io.nymea.DevicePlugin" FILE "devicepluginmqtt.json")
|
Q_PLUGIN_METADATA(IID "io.nymea.DevicePlugin" FILE "devicepluginmqttclient.json")
|
||||||
Q_INTERFACES(DevicePlugin)
|
Q_INTERFACES(DevicePlugin)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DevicePluginMqtt();
|
explicit DevicePluginMqttClient();
|
||||||
|
|
||||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||||
void deviceRemoved(Device *device) override;
|
void deviceRemoved(Device *device) override;
|
||||||
|
|
@ -58,4 +58,4 @@ private:
|
||||||
QHash<quint16, Action> m_pendingPublishes;
|
QHash<quint16, Action> m_pendingPublishes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEVICEPLUGINMQTT_H
|
#endif // DEVICEPLUGINMQTTCLIENT_H
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
include(../plugins.pri)
|
||||||
|
|
||||||
|
QT += network
|
||||||
|
|
||||||
|
TARGET = $$qtLibraryTarget(nymea_devicepluginmqttclient)
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
devicepluginmqttclient.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
devicepluginmqttclient.h
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ PLUGIN_DIRS = \
|
||||||
leynew \
|
leynew \
|
||||||
lgsmarttv \
|
lgsmarttv \
|
||||||
mailnotification \
|
mailnotification \
|
||||||
mqtt \
|
mqttclient \
|
||||||
netatmo \
|
netatmo \
|
||||||
networkdetector \
|
networkdetector \
|
||||||
openweathermap \
|
openweathermap \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue