initial work on moving plugin description to json
This commit is contained in:
parent
06b64534de
commit
dcd2fdc049
@ -82,6 +82,7 @@
|
|||||||
#include "plugin/deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
|
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
|
#include <QStaticPlugin>
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -499,11 +500,11 @@ QPair<DeviceManager::DeviceError, QString> DeviceManager::executeAction(const Ac
|
|||||||
|
|
||||||
void DeviceManager::loadPlugins()
|
void DeviceManager::loadPlugins()
|
||||||
{
|
{
|
||||||
foreach (QObject *pluginObject, QPluginLoader::staticInstances()) {
|
foreach (const QStaticPlugin &staticPlugin, QPluginLoader::staticPlugins()) {
|
||||||
DevicePlugin *pluginIface = qobject_cast<DevicePlugin*>(pluginObject);
|
DevicePlugin *pluginIface = qobject_cast<DevicePlugin*>(staticPlugin.instance());
|
||||||
if (pluginIface) {
|
if (verifyPluginMetadata(staticPlugin.metaData().value("MetaData").toObject()) && pluginIface) {
|
||||||
|
pluginIface->initPlugin(staticPlugin.metaData().value("MetaData").toObject(), this);
|
||||||
qDebug() << "*** Loaded plugin" << pluginIface->pluginName();
|
qDebug() << "*** Loaded plugin" << pluginIface->pluginName();
|
||||||
pluginIface->initPlugin(this);
|
|
||||||
foreach (const Vendor &vendor, pluginIface->supportedVendors()) {
|
foreach (const Vendor &vendor, pluginIface->supportedVendors()) {
|
||||||
qDebug() << "* Loaded vendor:" << vendor.name();
|
qDebug() << "* Loaded vendor:" << vendor.name();
|
||||||
if (m_supportedVendors.contains(vendor.id())) {
|
if (m_supportedVendors.contains(vendor.id())) {
|
||||||
@ -826,6 +827,20 @@ void DeviceManager::timerEvent()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DeviceManager::verifyPluginMetadata(const QJsonObject &data)
|
||||||
|
{
|
||||||
|
QStringList requiredFields;
|
||||||
|
requiredFields << "name" << "id" << "vendors";
|
||||||
|
|
||||||
|
foreach (const QString &field, requiredFields) {
|
||||||
|
if (!data.contains("name")) {
|
||||||
|
qWarning() << "Error loading plugin. Incomplete metadata. Missing field:" << field;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus,QString> DeviceManager::setupDevice(Device *device)
|
QPair<DeviceManager::DeviceSetupStatus,QString> DeviceManager::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
DeviceClass deviceClass = findDeviceClass(device->deviceClassId());
|
DeviceClass deviceClass = findDeviceClass(device->deviceClassId());
|
||||||
|
|||||||
@ -122,6 +122,7 @@ private slots:
|
|||||||
void timerEvent();
|
void timerEvent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool verifyPluginMetadata(const QJsonObject &data);
|
||||||
QPair<DeviceError, QString> addConfiguredDeviceInternal(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
QPair<DeviceError, QString> addConfiguredDeviceInternal(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
||||||
QPair<DeviceSetupStatus, QString> setupDevice(Device *device);
|
QPair<DeviceSetupStatus, QString> setupDevice(Device *device);
|
||||||
QPair<DeviceError, QString> verifyParams(const QList<ParamType> paramTypes, ParamList ¶ms, bool requireAll = true);
|
QPair<DeviceError, QString> verifyParams(const QList<ParamType> paramTypes, ParamList ¶ms, bool requireAll = true);
|
||||||
|
|||||||
@ -28,11 +28,6 @@ pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId(
|
|||||||
\l{DevicePlugin::supportedDevices()} and \l{DevicePlugin::requiredHardware()}
|
\l{DevicePlugin::supportedDevices()} and \l{DevicePlugin::requiredHardware()}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn QString DevicePlugin::pluginName() const
|
|
||||||
Return the name of the plugin. A String presented to the user.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QUuid DevicePlugin::pluginId() const
|
\fn QUuid DevicePlugin::pluginId() const
|
||||||
When implementing a plugin, generate a new uuid and return it here. Always return the
|
When implementing a plugin, generate a new uuid and return it here. Always return the
|
||||||
@ -110,13 +105,14 @@ pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId(
|
|||||||
#include "hardware/radio433/radio433.h"
|
#include "hardware/radio433/radio433.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QJsonArray>
|
||||||
|
|
||||||
/*! DevicePlugin constructor. DevicePlugins will be instantiated by the DeviceManager, its \a parent. */
|
/*! DevicePlugin constructor. DevicePlugins will be instantiated by the DeviceManager, its \a parent. */
|
||||||
DevicePlugin::DevicePlugin(QObject *parent):
|
DevicePlugin::DevicePlugin(QObject *parent):
|
||||||
QObject(parent),
|
QObject(parent)
|
||||||
m_deviceManager(0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Virtual destructor... */
|
/*! Virtual destructor... */
|
||||||
@ -125,6 +121,89 @@ DevicePlugin::~DevicePlugin()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DevicePlugin::pluginName() const
|
||||||
|
{
|
||||||
|
return m_metaData.value("name").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginId DevicePlugin::pluginId() const
|
||||||
|
{
|
||||||
|
return m_metaData.value("id").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DevicePlugin::supportedVendors() const
|
||||||
|
{
|
||||||
|
QList<Vendor> vendors;
|
||||||
|
foreach (const QJsonValue &vendorJson, m_metaData.value("vendors").toArray()) {
|
||||||
|
Vendor vendor(vendorJson.toObject().value("id").toString(), vendorJson.toObject().value("name").toString());
|
||||||
|
vendors.append(vendor);
|
||||||
|
}
|
||||||
|
return vendors;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<DeviceClass> DevicePlugin::supportedDevices() const
|
||||||
|
{
|
||||||
|
QList<DeviceClass> deviceClasses;
|
||||||
|
foreach (const QJsonValue &vendorJson, m_metaData.value("vendors").toArray()) {
|
||||||
|
VendorId vendorId = vendorJson.toObject().value("id").toString();
|
||||||
|
foreach (const QJsonValue &deviceClassJson, vendorJson.toObject().value("deviceClasses").toArray()) {
|
||||||
|
QJsonObject jo = deviceClassJson.toObject();
|
||||||
|
DeviceClass deviceClass(pluginId(), vendorId, jo.value("deviceClassId").toString());
|
||||||
|
deviceClass.setName(jo.value("name").toString());
|
||||||
|
QString createMethod = jo.value("createMethod").toString();
|
||||||
|
if (createMethod == "discovery") {
|
||||||
|
deviceClass.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
||||||
|
} else if (createMethod == "auto") {
|
||||||
|
deviceClass.setCreateMethod(DeviceClass::CreateMethodAuto);
|
||||||
|
} else {
|
||||||
|
deviceClass.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||||
|
}
|
||||||
|
QString setupMethod = jo.value("setupMethod").toString();
|
||||||
|
if (setupMethod == "pushButton") {
|
||||||
|
deviceClass.setSetupMethod(DeviceClass::SetupMethodPushButton);
|
||||||
|
} else if (setupMethod == "displayPin") {
|
||||||
|
deviceClass.setSetupMethod(DeviceClass::SetupMethodDisplayPin);
|
||||||
|
} else if (setupMethod == "enterPin") {
|
||||||
|
deviceClass.setSetupMethod(DeviceClass::SetupMethodEnterPin);
|
||||||
|
} else {
|
||||||
|
deviceClass.setSetupMethod(DeviceClass::SetupMethodJustAdd);
|
||||||
|
}
|
||||||
|
deviceClass.setPairingInfo(jo.value("pairingInfo").toString());
|
||||||
|
|
||||||
|
QList<ParamType> paramTypes;
|
||||||
|
foreach (const QJsonValue ¶mTypesJson, jo.value("paramTypes").toArray()) {
|
||||||
|
QJsonObject pt = paramTypesJson.toObject();
|
||||||
|
QVariant::Type t = QVariant::nameToType(pt.value("type").toString().toLatin1().data());
|
||||||
|
ParamType paramType(pt.value("name").toString(), t, pt.value("defaultValue").toVariant());
|
||||||
|
QVariantList allowedValues;
|
||||||
|
foreach (const QJsonValue &allowedTypesJson, pt.value("allowedValues").toArray()) {
|
||||||
|
allowedValues.append(allowedTypesJson.toVariant());
|
||||||
|
}
|
||||||
|
paramType.setAllowedValues(allowedValues);
|
||||||
|
paramType.setLimits(pt.value("minValue").toVariant(), pt.value("maxValue").toVariant());
|
||||||
|
paramTypes.append(paramType);
|
||||||
|
}
|
||||||
|
deviceClass.setParamTypes(paramTypes);
|
||||||
|
|
||||||
|
QList<StateType> stateTypes;
|
||||||
|
qDebug() << "############### s" << jo;
|
||||||
|
foreach (const QJsonValue &stateTypesJson, jo.value("stateTypes").toArray()) {
|
||||||
|
QJsonObject st = stateTypesJson.toObject();
|
||||||
|
QVariant::Type t = QVariant::nameToType(st.value("type").toString().toLatin1().data());
|
||||||
|
StateType stateType(st.value("id").toString());
|
||||||
|
stateType.setName(st.value("name").toString());
|
||||||
|
stateType.setType(t);
|
||||||
|
stateType.setDefaultValue(st.value("defaultValue").toVariant());
|
||||||
|
stateTypes.append(stateType);
|
||||||
|
}
|
||||||
|
deviceClass.setStateTypes(stateTypes);
|
||||||
|
|
||||||
|
deviceClasses.append(deviceClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return deviceClasses;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Override this if your plugin supports Device with DeviceClass::CreationMethodAuto.
|
/*! Override this if your plugin supports Device with DeviceClass::CreationMethodAuto.
|
||||||
This will be called at startup, after the configured devices have been loaded.
|
This will be called at startup, after the configured devices have been loaded.
|
||||||
This is the earliest time you should start emitting autoDevicesAppeared(). If you
|
This is the earliest time you should start emitting autoDevicesAppeared(). If you
|
||||||
@ -188,8 +267,9 @@ QList<ParamType> DevicePlugin::configurationDescription() const
|
|||||||
|
|
||||||
/*! This will be called when the DeviceManager initializes the plugin and set up the things behind the scenes.
|
/*! This will be called when the DeviceManager initializes the plugin and set up the things behind the scenes.
|
||||||
When implementing a new plugin, use \l{DevicePlugin::init()} instead in order to do initialisation work. */
|
When implementing a new plugin, use \l{DevicePlugin::init()} instead in order to do initialisation work. */
|
||||||
void DevicePlugin::initPlugin(DeviceManager *deviceManager)
|
void DevicePlugin::initPlugin(const QJsonObject &metaData, DeviceManager *deviceManager)
|
||||||
{
|
{
|
||||||
|
m_metaData = metaData;
|
||||||
m_deviceManager = deviceManager;
|
m_deviceManager = deviceManager;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
#include "types/param.h"
|
#include "types/param.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
class DeviceManager;
|
class DeviceManager;
|
||||||
class Device;
|
class Device;
|
||||||
@ -42,11 +43,11 @@ public:
|
|||||||
|
|
||||||
virtual void init() {}
|
virtual void init() {}
|
||||||
|
|
||||||
virtual QString pluginName() const = 0;
|
QString pluginName() const;
|
||||||
virtual PluginId pluginId() const = 0;
|
PluginId pluginId() const;
|
||||||
|
QList<Vendor> supportedVendors() const;
|
||||||
|
QList<DeviceClass> supportedDevices() const;
|
||||||
|
|
||||||
virtual QList<Vendor> supportedVendors() const = 0;
|
|
||||||
virtual QList<DeviceClass> supportedDevices() const = 0;
|
|
||||||
virtual DeviceManager::HardwareResources requiredHardware() const = 0;
|
virtual DeviceManager::HardwareResources requiredHardware() const = 0;
|
||||||
|
|
||||||
virtual void startMonitoringAutoDevices();
|
virtual void startMonitoringAutoDevices();
|
||||||
@ -93,12 +94,14 @@ protected:
|
|||||||
QPair<DeviceManager::DeviceError, QString> report(DeviceManager::DeviceError error = DeviceManager::DeviceErrorNoError, const QString &message = QString());
|
QPair<DeviceManager::DeviceError, QString> report(DeviceManager::DeviceError error = DeviceManager::DeviceErrorNoError, const QString &message = QString());
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> reportDeviceSetup(DeviceManager::DeviceSetupStatus status = DeviceManager::DeviceSetupStatusSuccess, const QString &message = QString());
|
QPair<DeviceManager::DeviceSetupStatus, QString> reportDeviceSetup(DeviceManager::DeviceSetupStatus status = DeviceManager::DeviceSetupStatusSuccess, const QString &message = QString());
|
||||||
private:
|
private:
|
||||||
void initPlugin(DeviceManager *deviceManager);
|
void initPlugin(const QJsonObject &metaData, DeviceManager *deviceManager);
|
||||||
|
|
||||||
DeviceManager *m_deviceManager;
|
DeviceManager *m_deviceManager;
|
||||||
|
|
||||||
ParamList m_config;
|
ParamList m_config;
|
||||||
|
|
||||||
|
QJsonObject m_metaData;
|
||||||
|
|
||||||
friend class DeviceManager;
|
friend class DeviceManager;
|
||||||
};
|
};
|
||||||
Q_DECLARE_INTERFACE(DevicePlugin, "guru.guh.DevicePlugin")
|
Q_DECLARE_INTERFACE(DevicePlugin, "guru.guh.DevicePlugin")
|
||||||
|
|||||||
@ -60,7 +60,6 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
VendorId conradVendorId = VendorId("986cf06f-3ef1-4271-b2a3-2cc277ebecb6");
|
|
||||||
DeviceClassId conradRemoteId = DeviceClassId("17cd2492-28ab-4827-ba6e-5ef35be23f1b");
|
DeviceClassId conradRemoteId = DeviceClassId("17cd2492-28ab-4827-ba6e-5ef35be23f1b");
|
||||||
EventTypeId conradRemoteButtonEventTypeId = EventTypeId("1f4050f5-4c90-4799-8d6d-e4069f3a2519");
|
EventTypeId conradRemoteButtonEventTypeId = EventTypeId("1f4050f5-4c90-4799-8d6d-e4069f3a2519");
|
||||||
ActionTypeId conradRemoteActionTypeId = ActionTypeId("2a3638b4-fbd6-4fdb-a3c9-7fa49705d1a3");
|
ActionTypeId conradRemoteActionTypeId = ActionTypeId("2a3638b4-fbd6-4fdb-a3c9-7fa49705d1a3");
|
||||||
@ -68,87 +67,55 @@ DevicePluginConrad::DevicePluginConrad()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginConrad::supportedVendors() const
|
//QList<DeviceClass> DevicePluginConrad::supportedDevices() const
|
||||||
{
|
//{
|
||||||
QList<Vendor> ret;
|
// // TODO: load list from config with static uuid
|
||||||
ret.append(Vendor(conradVendorId, "Conrad Electronic SE"));
|
// QList<DeviceClass> ret;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginConrad::supportedDevices() const
|
// // =======================================
|
||||||
{
|
// // Remote
|
||||||
// TODO: load list from config with static uuid
|
// DeviceClass deviceClassConradRemote(pluginId(), supportedVendors().first().id(), conradRemoteId);
|
||||||
QList<DeviceClass> ret;
|
// deviceClassConradRemote.setName("Conrad Remote");
|
||||||
|
|
||||||
// =======================================
|
// // Params
|
||||||
// Remote
|
// QList<ParamType> deviceParamsRemote;
|
||||||
DeviceClass deviceClassConradRemote(pluginId(), conradVendorId, conradRemoteId);
|
|
||||||
deviceClassConradRemote.setName("Conrad Remote");
|
|
||||||
|
|
||||||
// Params
|
// QVariantList deviceParamRemote;
|
||||||
QList<ParamType> deviceParamsRemote;
|
// QVariantMap nameParam;
|
||||||
|
// nameParam.insert("name", "name");
|
||||||
|
// nameParam.insert("type", "string");
|
||||||
|
// deviceParamRemote.append(nameParam);
|
||||||
|
|
||||||
QVariantList deviceParamRemote;
|
// // Events
|
||||||
QVariantMap nameParam;
|
// QList<EventType> buttonEvents;
|
||||||
nameParam.insert("name", "name");
|
|
||||||
nameParam.insert("type", "string");
|
|
||||||
deviceParamRemote.append(nameParam);
|
|
||||||
|
|
||||||
QList<ParamType> actionParamsRemote;
|
// QList<ParamType> paramsRemote;
|
||||||
ParamType actionParamRemote("power", QVariant::Bool);
|
// ParamType paramButton("button", QVariant::Int);
|
||||||
actionParamsRemote.append(actionParamRemote);
|
// paramsRemote.append(paramButton);
|
||||||
|
|
||||||
|
// ParamType paramGroup("group", QVariant::Int);
|
||||||
|
// paramsRemote.append(paramGroup);
|
||||||
|
|
||||||
// Actions
|
// ParamType paramPower("power", QVariant::Bool);
|
||||||
QList<ActionType> remoteActions;
|
// paramsRemote.append(paramPower);
|
||||||
|
|
||||||
ActionType powerAction(conradRemoteActionTypeId);
|
// EventType buttonEvent(conradRemoteButtonEventTypeId);
|
||||||
powerAction.setName("power");
|
// buttonEvent.setName("Button Pressed");
|
||||||
powerAction.setParameters(actionParamsRemote);
|
// buttonEvent.setParameters(paramsRemote);
|
||||||
remoteActions.append(powerAction);
|
// buttonEvents.append(buttonEvent);
|
||||||
|
|
||||||
deviceClassConradRemote.setActions(remoteActions);
|
// deviceClassConradRemote.setParamTypes(deviceParamsRemote);
|
||||||
|
// deviceClassConradRemote.setEventTypes(buttonEvents);
|
||||||
|
// ret.append(deviceClassConradRemote);
|
||||||
|
|
||||||
// Events
|
// return ret;
|
||||||
QList<EventType> buttonEvents;
|
//}
|
||||||
|
|
||||||
QList<ParamType> paramsRemote;
|
|
||||||
ParamType paramButton("button", QVariant::Int);
|
|
||||||
paramsRemote.append(paramButton);
|
|
||||||
|
|
||||||
ParamType paramGroup("group", QVariant::Int);
|
|
||||||
paramsRemote.append(paramGroup);
|
|
||||||
|
|
||||||
ParamType paramPower("power", QVariant::Bool);
|
|
||||||
paramsRemote.append(paramPower);
|
|
||||||
|
|
||||||
EventType buttonEvent(conradRemoteButtonEventTypeId);
|
|
||||||
buttonEvent.setName("Button Pressed");
|
|
||||||
buttonEvent.setParameters(paramsRemote);
|
|
||||||
buttonEvents.append(buttonEvent);
|
|
||||||
|
|
||||||
deviceClassConradRemote.setParamTypes(deviceParamsRemote);
|
|
||||||
deviceClassConradRemote.setEventTypes(buttonEvents);
|
|
||||||
ret.append(deviceClassConradRemote);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginConrad::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginConrad::requiredHardware() const
|
||||||
{
|
{
|
||||||
return DeviceManager::HardwareResourceRadio433;
|
return DeviceManager::HardwareResourceRadio433;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginConrad::pluginName() const
|
|
||||||
{
|
|
||||||
return "Conrad";
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginConrad::pluginId() const
|
|
||||||
{
|
|
||||||
return PluginId("1fd1a076-f229-4ec6-b501-48ddd15935e4");
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceError, QString> DevicePluginConrad::executeAction(Device *device, const Action &action)
|
QPair<DeviceManager::DeviceError, QString> DevicePluginConrad::executeAction(Device *device, const Action &action)
|
||||||
{
|
{
|
||||||
QList<int> rawData;
|
QList<int> rawData;
|
||||||
|
|||||||
@ -31,14 +31,9 @@ class DevicePluginConrad : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginConrad();
|
explicit DevicePluginConrad();
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
void radioData(QList<int> rawData) override;
|
||||||
PluginId pluginId() const override;
|
|
||||||
|
|
||||||
void radioData(const QList<int> &rawData) override;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
||||||
|
|||||||
@ -1 +1,10 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "Conrad",
|
||||||
|
"id": "1fd1a076-f229-4ec6-b501-48ddd15935e4",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "Conrad Electronic SE",
|
||||||
|
"id": "986cf06f-3ef1-4271-b2a3-2cc277ebecb6"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -72,144 +72,140 @@ DevicePluginElro::DevicePluginElro()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginElro::supportedVendors() const
|
//QList<Vendor> DevicePluginElro::supportedVendors() const
|
||||||
{
|
//{
|
||||||
QList<Vendor> ret;
|
// QList<Vendor> ret;
|
||||||
ret.append(Vendor(elroVendorId, "Elro"));
|
// ret.append(Vendor(elroVendorId, "Elro"));
|
||||||
return ret;
|
// ret.append(Vendor(mumbiVendorId, "Mumbi"));
|
||||||
}
|
// ret.append(Vendor(vivancoVendorId, "Vivanco"));
|
||||||
|
// ret.append(Vendor(brennenstuhlVendorId, "Brennenstuhl"));
|
||||||
|
// ret.append(Vendor(batVendorId, "BAT"));
|
||||||
|
// return ret;
|
||||||
|
//}
|
||||||
|
//QList<DeviceClass> DevicePluginElro::supportedDevices() const
|
||||||
|
//{
|
||||||
|
// // TODO: load list from config with static uuid
|
||||||
|
// QList<DeviceClass> ret;
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginElro::supportedDevices() const
|
// // =======================================
|
||||||
{
|
// // Remote
|
||||||
// TODO: load list from config with static uuid
|
// qDebug() << "have supported vendors" << supportedVendors().count();
|
||||||
QList<DeviceClass> ret;
|
// DeviceClass deviceClassElroRemote(pluginId(), supportedVendors().first().id(), elroRemoteId);
|
||||||
|
// deviceClassElroRemote.setName("Elro Remote");
|
||||||
// =======================================
|
|
||||||
// Remote
|
|
||||||
DeviceClass deviceClassElroRemote(pluginId(), elroVendorId, elroRemoteId);
|
|
||||||
deviceClassElroRemote.setName("Elro Remote");
|
|
||||||
|
|
||||||
QList<ParamType> deviceParamsRemote;
|
// QList<ParamType> deviceParamsRemote;
|
||||||
ParamType channelParam = ParamType("channel 1", QVariant::Bool);
|
// ParamType channelParam = ParamType("channel1", QVariant::Bool);
|
||||||
deviceParamsRemote.append(channelParam);
|
// deviceParamsRemote.append(channelParam);
|
||||||
channelParam = ParamType("channel 2", QVariant::Bool);
|
// channelParam = ParamType("channel2", QVariant::Bool);
|
||||||
deviceParamsRemote.append(channelParam);
|
// deviceParamsRemote.append(channelParam);
|
||||||
channelParam = ParamType("channel 3", QVariant::Bool);
|
// channelParam = ParamType("channel3", QVariant::Bool);
|
||||||
deviceParamsRemote.append(channelParam);
|
// deviceParamsRemote.append(channelParam);
|
||||||
channelParam = ParamType("channel 4", QVariant::Bool);
|
// channelParam = ParamType("channel4", QVariant::Bool);
|
||||||
deviceParamsRemote.append(channelParam);
|
// deviceParamsRemote.append(channelParam);
|
||||||
channelParam = ParamType("channel 5", QVariant::Bool);
|
// channelParam = ParamType("channel5", QVariant::Bool);
|
||||||
deviceParamsRemote.append(channelParam);
|
// deviceParamsRemote.append(channelParam);
|
||||||
|
|
||||||
deviceClassElroRemote.setParamTypes(deviceParamsRemote);
|
// deviceClassElroRemote.setParamTypes(deviceParamsRemote);
|
||||||
|
|
||||||
QList<EventType> buttonEvents;
|
// QList<EventType> buttonEvents;
|
||||||
|
|
||||||
QList<ParamType> paramsRemote;
|
// QList<ParamType> paramsRemote;
|
||||||
ParamType param("power", QVariant::Bool);
|
// ParamType param("power", QVariant::Bool);
|
||||||
paramsRemote.append(param);
|
// paramsRemote.append(param);
|
||||||
|
|
||||||
EventType buttonAEvent(EventTypeId("9dd3f862-35f3-4b69-954e-fa3c8bd68e39"));
|
// EventType buttonAEvent(EventTypeId("9dd3f862-35f3-4b69-954e-fa3c8bd68e39"));
|
||||||
buttonAEvent.setName("A");
|
// buttonAEvent.setName("A");
|
||||||
buttonAEvent.setParameters(paramsRemote);
|
// buttonAEvent.setParameters(paramsRemote);
|
||||||
buttonEvents.append(buttonAEvent);
|
// buttonEvents.append(buttonAEvent);
|
||||||
|
|
||||||
EventType buttonBEvent(EventTypeId("733226eb-91ba-4e37-9d78-12c87eb5e763"));
|
// EventType buttonBEvent(EventTypeId("733226eb-91ba-4e37-9d78-12c87eb5e763"));
|
||||||
buttonBEvent.setName("B");
|
// buttonBEvent.setName("B");
|
||||||
buttonBEvent.setParameters(paramsRemote);
|
// buttonBEvent.setParameters(paramsRemote);
|
||||||
buttonEvents.append(buttonBEvent);
|
// buttonEvents.append(buttonBEvent);
|
||||||
|
|
||||||
EventType buttonCEvent(EventTypeId("47aaeaec-485a-4775-a543-33f339fd28c8"));
|
// EventType buttonCEvent(EventTypeId("47aaeaec-485a-4775-a543-33f339fd28c8"));
|
||||||
buttonCEvent.setName("C");
|
// buttonCEvent.setName("C");
|
||||||
buttonCEvent.setParameters(paramsRemote);
|
// buttonCEvent.setParameters(paramsRemote);
|
||||||
buttonEvents.append(buttonCEvent);
|
// buttonEvents.append(buttonCEvent);
|
||||||
|
|
||||||
EventType buttonDEvent(EventTypeId("db3d484c-add9-44ab-80a4-a0664e0c87c8"));
|
// EventType buttonDEvent(EventTypeId("db3d484c-add9-44ab-80a4-a0664e0c87c8"));
|
||||||
buttonDEvent.setName("D");
|
// buttonDEvent.setName("D");
|
||||||
buttonDEvent.setParameters(paramsRemote);
|
// buttonDEvent.setParameters(paramsRemote);
|
||||||
buttonEvents.append(buttonDEvent);
|
// buttonEvents.append(buttonDEvent);
|
||||||
|
|
||||||
EventType buttonEEvent(EventTypeId("eb914aac-fb73-4ee2-9f1b-c34b2f6cc24a"));
|
// EventType buttonEEvent(EventTypeId("eb914aac-fb73-4ee2-9f1b-c34b2f6cc24a"));
|
||||||
buttonEEvent.setName("E");
|
// buttonEEvent.setName("E");
|
||||||
buttonEEvent.setParameters(paramsRemote);
|
// buttonEEvent.setParameters(paramsRemote);
|
||||||
buttonEvents.append(buttonEEvent);
|
// buttonEvents.append(buttonEEvent);
|
||||||
|
|
||||||
deviceClassElroRemote.setEventTypes(buttonEvents);
|
// deviceClassElroRemote.setEventTypes(buttonEvents);
|
||||||
ret.append(deviceClassElroRemote);
|
// ret.append(deviceClassElroRemote);
|
||||||
|
|
||||||
// =======================================
|
// // =======================================
|
||||||
// Motion Detector
|
// // Motion Detector
|
||||||
|
|
||||||
DeviceClass deviceClassElroMotionDetector(pluginId(), elroVendorId, elroMotionDetectorId);
|
// DeviceClass deviceClassElroMotionDetector(pluginId(), supportedVendors().first().id(), elroMotionDetectorId);
|
||||||
deviceClassElroMotionDetector.setName("Elro Motion Detector");
|
// deviceClassElroMotionDetector.setName("Elro Motion Detector");
|
||||||
deviceClassElroMotionDetector.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
// deviceClassElroMotionDetector.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
||||||
|
|
||||||
QList<EventType> motionDetectorEvents;
|
// QList<EventType> motionDetectorEvents;
|
||||||
QList<ParamType> deviceParamsMotionDetector;
|
// QList<ParamType> deviceParamsMotionDetector;
|
||||||
|
|
||||||
|
|
||||||
// =======================================
|
|
||||||
// Switch
|
|
||||||
DeviceClass deviceClassElroSwitch(pluginId(), elroVendorId, elroSwitchId);
|
|
||||||
deviceClassElroSwitch.setName("Elro Power Switch");
|
// // =======================================
|
||||||
|
// // Switch
|
||||||
|
// DeviceClass deviceClassElroSwitch(pluginId(), supportedVendors().first().id(), elroSwitchId);
|
||||||
|
// deviceClassElroSwitch.setName("Elro Power Switch");
|
||||||
|
|
||||||
QList<ParamType> deviceParamsSwitch;
|
// QList<ParamType> deviceParamsSwitch;
|
||||||
ParamType paramSwitch = ParamType("channel 1", QVariant::Bool);
|
// ParamType paramSwitch = ParamType("channel1", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
paramSwitch = ParamType("channel 2", QVariant::Bool);
|
// paramSwitch = ParamType("channel2", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
paramSwitch = ParamType("channel 3", QVariant::Bool);
|
// paramSwitch = ParamType("channel3", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
paramSwitch = ParamType("channel 4", QVariant::Bool);
|
// paramSwitch = ParamType("channel4", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
paramSwitch = ParamType("channel 5", QVariant::Bool);
|
// paramSwitch = ParamType("channel5", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
paramSwitch = ParamType("A", QVariant::Bool);
|
// paramSwitch = ParamType("A", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
paramSwitch = ParamType("B", QVariant::Bool);
|
// paramSwitch = ParamType("B", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
paramSwitch = ParamType("C", QVariant::Bool);
|
// paramSwitch = ParamType("C", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
paramSwitch = ParamType("D", QVariant::Bool);
|
// paramSwitch = ParamType("D", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
paramSwitch = ParamType("E", QVariant::Bool);
|
// paramSwitch = ParamType("E", QVariant::Bool);
|
||||||
deviceParamsSwitch.append(paramSwitch);
|
// deviceParamsSwitch.append(paramSwitch);
|
||||||
|
|
||||||
deviceClassElroSwitch.setParamTypes(deviceParamsSwitch);
|
// deviceClassElroSwitch.setParamTypes(deviceParamsSwitch);
|
||||||
|
|
||||||
|
|
||||||
QList<ParamType> actionParamsSwitch;
|
// QList<ParamType> actionParamsSwitch;
|
||||||
ParamType actionParamSwitch("power", QVariant::Bool);
|
// ParamType actionParamSwitch("power", QVariant::Bool);
|
||||||
actionParamsSwitch.append(actionParamSwitch);
|
// actionParamsSwitch.append(actionParamSwitch);
|
||||||
|
|
||||||
|
// QList<ActionType> switchActions;
|
||||||
|
|
||||||
QList<ActionType> switchActions;
|
// ActionType powerAction(ActionTypeId("31c9758e-6567-4f89-85bb-29e1a7c55d44"));
|
||||||
|
// powerAction.setName("power");
|
||||||
|
// powerAction.setParameters(actionParamsSwitch);
|
||||||
|
// switchActions.append(powerAction);
|
||||||
|
|
||||||
ActionType powerAction(ActionTypeId("31c9758e-6567-4f89-85bb-29e1a7c55d44"));
|
// deviceClassElroSwitch.setActions(switchActions);
|
||||||
powerAction.setName("power");
|
// ret.append(deviceClassElroSwitch);
|
||||||
powerAction.setParameters(actionParamsSwitch);
|
// return ret;
|
||||||
switchActions.append(powerAction);
|
//}
|
||||||
|
|
||||||
deviceClassElroSwitch.setActions(switchActions);
|
|
||||||
ret.append(deviceClassElroSwitch);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginElro::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginElro::requiredHardware() const
|
||||||
{
|
{
|
||||||
return DeviceManager::HardwareResourceRadio433;
|
return DeviceManager::HardwareResourceRadio433;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginElro::pluginName() const
|
|
||||||
{
|
|
||||||
return QStringLiteral("Elro");
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginElro::pluginId() const
|
|
||||||
{
|
|
||||||
return PluginId("2b267f81-d9ae-4f4f-89a0-7386b547cfd3");
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceError, QString> DevicePluginElro::executeAction(Device *device, const Action &action)
|
QPair<DeviceManager::DeviceError, QString> DevicePluginElro::executeAction(Device *device, const Action &action)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -31,14 +31,9 @@ class DevicePluginElro : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginElro();
|
explicit DevicePluginElro();
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
void radioData(QList<int> rawData) override;
|
||||||
PluginId pluginId() const override;
|
|
||||||
|
|
||||||
void radioData(const QList<int> &rawData) override;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
||||||
|
|||||||
@ -1 +1,14 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "Elro",
|
||||||
|
"id": "2b267f81-d9ae-4f4f-89a0-7386b547cfd3",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "Electronic Roos",
|
||||||
|
"id": "435a13a0-65ca-4f0c-94c1-e5873b258db5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mumbi",
|
||||||
|
"id": "5f91c01c-0168-4bdf-a5ed-37cb6971b775"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -163,7 +163,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
VendorId intertechnoVendorId = VendorId("6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba");
|
|
||||||
DeviceClassId intertechnoRemote = DeviceClassId("ab73ad2f-6594-45a3-9063-8f72d365c5e5");
|
DeviceClassId intertechnoRemote = DeviceClassId("ab73ad2f-6594-45a3-9063-8f72d365c5e5");
|
||||||
DeviceClassId intertechnoSwitch = DeviceClassId("324219e8-7c53-41b5-b314-c2900cd15252");
|
DeviceClassId intertechnoSwitch = DeviceClassId("324219e8-7c53-41b5-b314-c2900cd15252");
|
||||||
|
|
||||||
@ -171,179 +170,161 @@ DevicePluginIntertechno::DevicePluginIntertechno()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginIntertechno::supportedVendors() const
|
//QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
||||||
{
|
//{
|
||||||
QList<Vendor> ret;
|
// QList<DeviceClass> ret;
|
||||||
Vendor intertechno(intertechnoVendorId, "Intertechno");
|
|
||||||
ret.append(intertechno);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
// // =======================================
|
||||||
{
|
// // Remote
|
||||||
QList<DeviceClass> ret;
|
// DeviceClass deviceClassIntertechnoRemote(pluginId(), supportedVendors().first().id(), intertechnoRemote);
|
||||||
|
// deviceClassIntertechnoRemote.setName("Intertechno Remote");
|
||||||
// =======================================
|
|
||||||
// Remote
|
|
||||||
DeviceClass deviceClassIntertechnoRemote(pluginId(), intertechnoVendorId, intertechnoRemote);
|
|
||||||
deviceClassIntertechnoRemote.setName("Intertechno Remote");
|
|
||||||
|
|
||||||
QList<ParamType> remoteParams;
|
// QList<ParamType> remoteParams;
|
||||||
// family code = A-P
|
// // family code = A-P
|
||||||
ParamType familyParam("familyCode", QVariant::String);
|
// ParamType familyParam("familyCode", QVariant::String);
|
||||||
remoteParams.append(familyParam);
|
// remoteParams.append(familyParam);
|
||||||
|
|
||||||
deviceClassIntertechnoRemote.setParamTypes(remoteParams);
|
// deviceClassIntertechnoRemote.setParamTypes(remoteParams);
|
||||||
|
|
||||||
QList<EventType> buttonEvents;
|
// QList<EventType> buttonEvents;
|
||||||
|
|
||||||
QList<ParamType> paramsRemote;
|
// QList<ParamType> paramsRemote;
|
||||||
// on = true
|
// // on = true
|
||||||
// off = false
|
// // off = false
|
||||||
ParamType paramRemote("power", QVariant::Bool);
|
// ParamType paramRemote("power", QVariant::Bool);
|
||||||
paramsRemote.append(paramRemote);
|
// paramsRemote.append(paramRemote);
|
||||||
|
|
||||||
/* 1-16
|
// /* 1-16
|
||||||
* ________________
|
// * ________________
|
||||||
* | I | II|III| IV |
|
// * | I | II|III| IV |
|
||||||
* |---|---|---|----|
|
// * |---|---|---|----|
|
||||||
* 1 | 1 | 5 | 9 | 13 |
|
// * 1 | 1 | 5 | 9 | 13 |
|
||||||
* 2 | 2 | 6 | 10| 14 |
|
// * 2 | 2 | 6 | 10| 14 |
|
||||||
* 3 | 3 | 7 | 11| 15 |
|
// * 3 | 3 | 7 | 11| 15 |
|
||||||
* 4 | 4 | 8 | 12| 16 |
|
// * 4 | 4 | 8 | 12| 16 |
|
||||||
* |___|___|___|____|
|
// * |___|___|___|____|
|
||||||
*/
|
// */
|
||||||
|
|
||||||
EventType button1Event(EventTypeId("785c1b30-a3f2-4696-af7c-d532acf3d6f7"));
|
// EventType button1Event(EventTypeId("785c1b30-a3f2-4696-af7c-d532acf3d6f7"));
|
||||||
button1Event.setName("1");
|
// button1Event.setName("1");
|
||||||
button1Event.setParameters(paramsRemote);
|
// button1Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button1Event);
|
// buttonEvents.append(button1Event);
|
||||||
|
|
||||||
EventType button2Event(EventTypeId("1d42c850-7b43-452f-b205-e1aac14eb3ee"));
|
// EventType button2Event(EventTypeId("1d42c850-7b43-452f-b205-e1aac14eb3ee"));
|
||||||
button2Event.setName("2");
|
// button2Event.setName("2");
|
||||||
button2Event.setParameters(paramsRemote);
|
// button2Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button2Event);
|
// buttonEvents.append(button2Event);
|
||||||
|
|
||||||
EventType button3Event(EventTypeId("77a4780e-2355-4a77-870d-2f675bf986ce"));
|
// EventType button3Event(EventTypeId("77a4780e-2355-4a77-870d-2f675bf986ce"));
|
||||||
button3Event.setName("3");
|
// button3Event.setName("3");
|
||||||
button3Event.setParameters(paramsRemote);
|
// button3Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button3Event);
|
// buttonEvents.append(button3Event);
|
||||||
|
|
||||||
EventType button4Event(EventTypeId("bd6a8b4b-f946-4f3b-992f-e7cff10187b8"));
|
// EventType button4Event(EventTypeId("bd6a8b4b-f946-4f3b-992f-e7cff10187b8"));
|
||||||
button4Event.setName("4");
|
// button4Event.setName("4");
|
||||||
button4Event.setParameters(paramsRemote);
|
// button4Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button4Event);
|
// buttonEvents.append(button4Event);
|
||||||
|
|
||||||
EventType button5Event(EventTypeId("0f20782e-0acc-45f1-8c42-5dc5f5b29f1b"));
|
// EventType button5Event(EventTypeId("0f20782e-0acc-45f1-8c42-5dc5f5b29f1b"));
|
||||||
button5Event.setName("5");
|
// button5Event.setName("5");
|
||||||
button5Event.setParameters(paramsRemote);
|
// button5Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button5Event);
|
// buttonEvents.append(button5Event);
|
||||||
|
|
||||||
EventType button6Event(EventTypeId("f7cb439a-0528-4905-9583-06b6bfeb3ba1"));
|
// EventType button6Event(EventTypeId("f7cb439a-0528-4905-9583-06b6bfeb3ba1"));
|
||||||
button6Event.setName("6");
|
// button6Event.setName("6");
|
||||||
button6Event.setParameters(paramsRemote);
|
// button6Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button6Event);
|
// buttonEvents.append(button6Event);
|
||||||
|
|
||||||
EventType button7Event(EventTypeId("a0b0d8d8-2b43-4897-98e0-05b6b408a950"));
|
// EventType button7Event(EventTypeId("a0b0d8d8-2b43-4897-98e0-05b6b408a950"));
|
||||||
button7Event.setName("7");
|
// button7Event.setName("7");
|
||||||
button7Event.setParameters(paramsRemote);
|
// button7Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button7Event);
|
// buttonEvents.append(button7Event);
|
||||||
|
|
||||||
EventType button8Event(EventTypeId("ae5833a2-bc43-4462-ae47-e45dac1fb0ce"));
|
// EventType button8Event(EventTypeId("ae5833a2-bc43-4462-ae47-e45dac1fb0ce"));
|
||||||
button8Event.setName("8");
|
// button8Event.setName("8");
|
||||||
button8Event.setParameters(paramsRemote);
|
// button8Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button8Event);
|
// buttonEvents.append(button8Event);
|
||||||
|
|
||||||
EventType button9Event(EventTypeId("52c13828-d047-4256-b488-0bf84abbc87c"));
|
// EventType button9Event(EventTypeId("52c13828-d047-4256-b488-0bf84abbc87c"));
|
||||||
button9Event.setName("9");
|
// button9Event.setName("9");
|
||||||
button9Event.setParameters(paramsRemote);
|
// button9Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button9Event);
|
// buttonEvents.append(button9Event);
|
||||||
|
|
||||||
EventType button10Event(EventTypeId("22c5afbc-835e-47cc-8211-4429eb9d9fee"));
|
// EventType button10Event(EventTypeId("22c5afbc-835e-47cc-8211-4429eb9d9fee"));
|
||||||
button10Event.setName("10");
|
// button10Event.setName("10");
|
||||||
button10Event.setParameters(paramsRemote);
|
// button10Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button10Event);
|
// buttonEvents.append(button10Event);
|
||||||
|
|
||||||
EventType button11Event(EventTypeId("6bec5cbc-8bfb-4c6c-8ac8-f8e7723fd5aa"));
|
// EventType button11Event(EventTypeId("6bec5cbc-8bfb-4c6c-8ac8-f8e7723fd5aa"));
|
||||||
button11Event.setName("11");
|
// button11Event.setName("11");
|
||||||
button11Event.setParameters(paramsRemote);
|
// button11Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button11Event);
|
// buttonEvents.append(button11Event);
|
||||||
|
|
||||||
EventType button12Event(EventTypeId("8b71edd2-8135-4c8b-bf44-380efadf1942"));
|
// EventType button12Event(EventTypeId("8b71edd2-8135-4c8b-bf44-380efadf1942"));
|
||||||
button12Event.setName("12");
|
// button12Event.setName("12");
|
||||||
button12Event.setParameters(paramsRemote);
|
// button12Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button12Event);
|
// buttonEvents.append(button12Event);
|
||||||
|
|
||||||
EventType button13Event(EventTypeId("192f36a4-1e58-41aa-9618-83d46e329a4b"));
|
// EventType button13Event(EventTypeId("192f36a4-1e58-41aa-9618-83d46e329a4b"));
|
||||||
button13Event.setName("13");
|
// button13Event.setName("13");
|
||||||
button13Event.setParameters(paramsRemote);
|
// button13Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button13Event);
|
// buttonEvents.append(button13Event);
|
||||||
|
|
||||||
EventType button14Event(EventTypeId("6c76de60-5e19-4a29-b027-e71e66caa2d6"));
|
// EventType button14Event(EventTypeId("6c76de60-5e19-4a29-b027-e71e66caa2d6"));
|
||||||
button14Event.setName("14");
|
// button14Event.setName("14");
|
||||||
button14Event.setParameters(paramsRemote);
|
// button14Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button14Event);
|
// buttonEvents.append(button14Event);
|
||||||
|
|
||||||
EventType button15Event(EventTypeId("c2f56c10-1f81-4477-88fa-fc0f4a6383df"));
|
// EventType button15Event(EventTypeId("c2f56c10-1f81-4477-88fa-fc0f4a6383df"));
|
||||||
button15Event.setName("15");
|
// button15Event.setName("15");
|
||||||
button15Event.setParameters(paramsRemote);
|
// button15Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button15Event);
|
// buttonEvents.append(button15Event);
|
||||||
|
|
||||||
EventType button16Event(EventTypeId("5d2eb3f8-4cd4-4c71-9c0c-e0b685e168e4"));
|
// EventType button16Event(EventTypeId("5d2eb3f8-4cd4-4c71-9c0c-e0b685e168e4"));
|
||||||
button16Event.setName("16");
|
// button16Event.setName("16");
|
||||||
button16Event.setParameters(paramsRemote);
|
// button16Event.setParameters(paramsRemote);
|
||||||
buttonEvents.append(button16Event);
|
// buttonEvents.append(button16Event);
|
||||||
|
|
||||||
deviceClassIntertechnoRemote.setEventTypes(buttonEvents);
|
// deviceClassIntertechnoRemote.setEventTypes(buttonEvents);
|
||||||
ret.append(deviceClassIntertechnoRemote);
|
// ret.append(deviceClassIntertechnoRemote);
|
||||||
|
|
||||||
|
|
||||||
// =======================================
|
// // =======================================
|
||||||
// Switch
|
// // Switch
|
||||||
DeviceClass deviceClassIntertechnoSwitch(pluginId(), intertechnoVendorId, intertechnoSwitch);
|
// DeviceClass deviceClassIntertechnoSwitch(pluginId(), supportedVendors().last().id(), intertechnoSwitch);
|
||||||
deviceClassIntertechnoSwitch.setName("Intertechno Switch");
|
// deviceClassIntertechnoSwitch.setName("Intertechno Switch");
|
||||||
|
|
||||||
QList<ParamType> switchDeviceParams;
|
// QList<ParamType> switchDeviceParams;
|
||||||
// button code = 1-16
|
// // button code = 1-16
|
||||||
ParamType buttonParam("buttonCode", QVariant::Int);
|
// ParamType buttonParam("buttonCode", QVariant::Int);
|
||||||
|
|
||||||
switchDeviceParams.append(familyParam);
|
// switchDeviceParams.append(familyParam);
|
||||||
switchDeviceParams.append(buttonParam);
|
// switchDeviceParams.append(buttonParam);
|
||||||
|
|
||||||
deviceClassIntertechnoSwitch.setParamTypes(switchDeviceParams);
|
// deviceClassIntertechnoSwitch.setParamTypes(switchDeviceParams);
|
||||||
|
|
||||||
QList<ActionType> switchActions;
|
// QList<ActionType> switchActions;
|
||||||
|
|
||||||
QList<ParamType> paramsSwitch;
|
// QList<ParamType> paramsSwitch;
|
||||||
ParamType paramSwitch("power", QVariant::Bool);
|
// ParamType paramSwitch("power", QVariant::Bool);
|
||||||
paramsSwitch.append(paramSwitch);
|
// paramsSwitch.append(paramSwitch);
|
||||||
|
|
||||||
ActionType switchActionPower(ActionTypeId("df19fb51-c3cd-4b95-8d88-ebbb535f4789"));
|
// ActionType switchActionPower(ActionTypeId("df19fb51-c3cd-4b95-8d88-ebbb535f4789"));
|
||||||
switchActionPower.setName("power");
|
// switchActionPower.setName("power");
|
||||||
switchActionPower.setParameters(paramsSwitch);
|
// switchActionPower.setParameters(paramsSwitch);
|
||||||
switchActions.append(switchActionPower);
|
// switchActions.append(switchActionPower);
|
||||||
|
|
||||||
deviceClassIntertechnoSwitch.setActions(switchActions);
|
// deviceClassIntertechnoSwitch.setActions(switchActions);
|
||||||
ret.append(deviceClassIntertechnoSwitch);
|
// ret.append(deviceClassIntertechnoSwitch);
|
||||||
|
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
//}
|
||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginIntertechno::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginIntertechno::requiredHardware() const
|
||||||
{
|
{
|
||||||
return DeviceManager::HardwareResourceRadio433;
|
return DeviceManager::HardwareResourceRadio433;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginIntertechno::pluginName() const
|
|
||||||
{
|
|
||||||
return "Intertechno";
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginIntertechno::pluginId() const
|
|
||||||
{
|
|
||||||
return PluginId("e998d934-0397-42c1-ad63-9141bcac8563");
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceError, QString> DevicePluginIntertechno::executeAction(Device *device, const Action &action)
|
QPair<DeviceManager::DeviceError, QString> DevicePluginIntertechno::executeAction(Device *device, const Action &action)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -31,14 +31,9 @@ class DevicePluginIntertechno : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginIntertechno();
|
explicit DevicePluginIntertechno();
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
void radioData(QList<int> rawData) override;
|
||||||
PluginId pluginId() const override;
|
|
||||||
|
|
||||||
void radioData(const QList<int> &rawData) override;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
||||||
|
|||||||
@ -1 +1,10 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "Intertechno",
|
||||||
|
"id": "e998d934-0397-42c1-ad63-9141bcac8563",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "Intertechno",
|
||||||
|
"id": "6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -26,9 +26,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
VendorId lircdVendorId = VendorId("9a53049c-8828-4b87-b3f6-7bc7708196cd");
|
|
||||||
|
|
||||||
PluginId lircdPluginUuid = PluginId("075f734f-4d76-4ce3-9ef8-34c212285676");
|
|
||||||
DeviceClassId lircdDeviceClassId = DeviceClassId("5c2bc4cd-ba6c-4052-b6cd-1db83323ea22");
|
DeviceClassId lircdDeviceClassId = DeviceClassId("5c2bc4cd-ba6c-4052-b6cd-1db83323ea22");
|
||||||
EventTypeId LircKeypressEventTypeId = EventTypeId("8711471a-fa0e-410b-b174-dfc3d2aeffb1");
|
EventTypeId LircKeypressEventTypeId = EventTypeId("8711471a-fa0e-410b-b174-dfc3d2aeffb1");
|
||||||
|
|
||||||
@ -40,77 +37,59 @@ DevicePluginLircd::DevicePluginLircd()
|
|||||||
connect(m_lircClient, &LircClient::buttonPressed, this, &DevicePluginLircd::buttonPressed);
|
connect(m_lircClient, &LircClient::buttonPressed, this, &DevicePluginLircd::buttonPressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginLircd::supportedVendors() const
|
//QList<DeviceClass> DevicePluginLircd::supportedDevices() const
|
||||||
{
|
//{
|
||||||
QList<Vendor> ret;
|
// QList<DeviceClass> ret;
|
||||||
Vendor guh(lircdVendorId, "Lircd");
|
|
||||||
ret.append(guh);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginLircd::supportedDevices() const
|
// DeviceClass deviceClassLircd(pluginId(), supportedVendors().first().id(), lircdDeviceClassId);
|
||||||
{
|
// deviceClassLircd.setName("IR Receiver");
|
||||||
QList<DeviceClass> ret;
|
|
||||||
|
|
||||||
DeviceClass deviceClassLircd(pluginId(), lircdVendorId, lircdDeviceClassId);
|
// QList<ParamType> params;
|
||||||
deviceClassLircd.setName("IR Receiver");
|
// ParamType remoteNameParam("remoteName", QVariant::String);
|
||||||
|
// params.append(remoteNameParam);
|
||||||
QList<ParamType> params;
|
// deviceClassLircd.setParamTypes(params);
|
||||||
ParamType remoteNameParam("remoteName", QVariant::String);
|
|
||||||
params.append(remoteNameParam);
|
|
||||||
deviceClassLircd.setParamTypes(params);
|
|
||||||
|
|
||||||
// TODO: find a way to load this stuff from a json file, really!
|
// // TODO: find a way to load this stuff from a json file, really!
|
||||||
// Ideally that file can be generated from /usr/share/lirc/remotes/*
|
// // Ideally that file can be generated from /usr/share/lirc/remotes/*
|
||||||
// Note that the IDs need to be kept static!
|
// // Note that the IDs need to be kept static!
|
||||||
QList<ParamType> repeatParam;
|
// QList<ParamType> repeatParam;
|
||||||
ParamType repeatParamMap("repeat", QVariant::Int);
|
// ParamType repeatParamMap("repeat", QVariant::Int);
|
||||||
repeatParam.append(repeatParamMap);
|
// repeatParam.append(repeatParamMap);
|
||||||
|
|
||||||
QList<EventType> events;
|
// QList<EventType> events;
|
||||||
EventType powerButton(EventTypeId("d62d779f-e5c6-4767-98e6-efe9c062b662"));
|
// EventType powerButton(EventTypeId("d62d779f-e5c6-4767-98e6-efe9c062b662"));
|
||||||
powerButton.setName("Power");
|
// powerButton.setName("Power");
|
||||||
powerButton.setParameters(repeatParam);
|
// powerButton.setParameters(repeatParam);
|
||||||
events.append(powerButton);
|
// events.append(powerButton);
|
||||||
EventType yellowButton(EventTypeId("3313f62e-ea20-47f5-85af-28897d6ac440"));
|
// EventType yellowButton(EventTypeId("3313f62e-ea20-47f5-85af-28897d6ac440"));
|
||||||
yellowButton.setName("Yellow");
|
// yellowButton.setName("Yellow");
|
||||||
yellowButton.setParameters(repeatParam);
|
// yellowButton.setParameters(repeatParam);
|
||||||
events.append(yellowButton);
|
// events.append(yellowButton);
|
||||||
EventType blueButton(EventTypeId("9a395d93-e482-4fa2-b4bc-e60bb4bf8652"));
|
// EventType blueButton(EventTypeId("9a395d93-e482-4fa2-b4bc-e60bb4bf8652"));
|
||||||
blueButton.setName("Blue");
|
// blueButton.setName("Blue");
|
||||||
blueButton.setParameters(repeatParam);
|
// blueButton.setParameters(repeatParam);
|
||||||
events.append(blueButton);
|
// events.append(blueButton);
|
||||||
EventType greenButton(EventTypeId("e8aaf18e-dc11-40da-980d-4eec42c58267"));
|
// EventType greenButton(EventTypeId("e8aaf18e-dc11-40da-980d-4eec42c58267"));
|
||||||
greenButton.setName("Green");
|
// greenButton.setName("Green");
|
||||||
greenButton.setParameters(repeatParam);
|
// greenButton.setParameters(repeatParam);
|
||||||
events.append(greenButton);
|
// events.append(greenButton);
|
||||||
EventType redButton(EventTypeId("b8518755-55a0-4cd4-8856-1680848edcb7"));
|
// EventType redButton(EventTypeId("b8518755-55a0-4cd4-8856-1680848edcb7"));
|
||||||
redButton.setName("Red");
|
// redButton.setName("Red");
|
||||||
redButton.setParameters(repeatParam);
|
// redButton.setParameters(repeatParam);
|
||||||
events.append(redButton);
|
// events.append(redButton);
|
||||||
|
|
||||||
deviceClassLircd.setEventTypes(events);
|
// deviceClassLircd.setEventTypes(events);
|
||||||
|
|
||||||
ret.append(deviceClassLircd);
|
// ret.append(deviceClassLircd);
|
||||||
|
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
//}
|
||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginLircd::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginLircd::requiredHardware() const
|
||||||
{
|
{
|
||||||
return DeviceManager::HardwareResourceNone;
|
return DeviceManager::HardwareResourceNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginLircd::pluginName() const
|
|
||||||
{
|
|
||||||
return "Lircd receiver";
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginLircd::pluginId() const
|
|
||||||
{
|
|
||||||
return lircdPluginUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginLircd::buttonPressed(const QString &remoteName, const QString &buttonName, int repeat)
|
void DevicePluginLircd::buttonPressed(const QString &remoteName, const QString &buttonName, int repeat)
|
||||||
{
|
{
|
||||||
Device *remote = nullptr;
|
Device *remote = nullptr;
|
||||||
|
|||||||
@ -35,13 +35,8 @@ class DevicePluginLircd: public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginLircd();
|
explicit DevicePluginLircd();
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
|
||||||
PluginId pluginId() const override;
|
|
||||||
|
|
||||||
// QVariantMap configuration() const override;
|
// QVariantMap configuration() const override;
|
||||||
// void setConfiguration(const QVariantMap &configuration) override;
|
// void setConfiguration(const QVariantMap &configuration) override;
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,10 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "Lirc receiver",
|
||||||
|
"id": "075f734f-4d76-4ce3-9ef8-34c212285676",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "Lirc",
|
||||||
|
"id": "9a53049c-8828-4b87-b3f6-7bc7708196cd"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -229,8 +229,6 @@
|
|||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
extern VendorId guhVendorId;
|
|
||||||
|
|
||||||
DeviceClassId googleMailDeviceClassId = DeviceClassId("3869884a-1592-4b8f-84a7-994be18ff555");
|
DeviceClassId googleMailDeviceClassId = DeviceClassId("3869884a-1592-4b8f-84a7-994be18ff555");
|
||||||
DeviceClassId customMailDeviceClassId = DeviceClassId("f4844c97-7ca6-4349-904e-ff9749a9fe74");
|
DeviceClassId customMailDeviceClassId = DeviceClassId("f4844c97-7ca6-4349-904e-ff9749a9fe74");
|
||||||
|
|
||||||
@ -247,91 +245,83 @@ DevicePluginMailNotification::~DevicePluginMailNotification()
|
|||||||
m_smtpClient->deleteLater();
|
m_smtpClient->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginMailNotification::supportedVendors() const
|
//QList<DeviceClass> DevicePluginMailNotification::supportedDevices() const
|
||||||
{
|
//{
|
||||||
QList<Vendor> ret;
|
// QList<DeviceClass> ret;
|
||||||
Vendor mail(guhVendorId, "guh");
|
|
||||||
ret.append(mail);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginMailNotification::supportedDevices() const
|
// // General Action
|
||||||
{
|
// QList<ActionType> mailActions;
|
||||||
QList<DeviceClass> ret;
|
|
||||||
|
|
||||||
// General Action
|
// QList<ParamType> actionParamsMail;
|
||||||
QList<ActionType> mailActions;
|
// ParamType actionParamSubject("subject", QVariant::String);
|
||||||
|
// actionParamsMail.append(actionParamSubject);
|
||||||
|
|
||||||
QList<ParamType> actionParamsMail;
|
// ParamType actionParamBody("body", QVariant::String);
|
||||||
ParamType actionParamSubject("subject", QVariant::String);
|
// actionParamsMail.append(actionParamBody);
|
||||||
actionParamsMail.append(actionParamSubject);
|
|
||||||
|
|
||||||
ParamType actionParamBody("body", QVariant::String);
|
// ActionType sendMailAction(sendMailActionTypeId);
|
||||||
actionParamsMail.append(actionParamBody);
|
// sendMailAction.setName("send mail");
|
||||||
|
// sendMailAction.setParameters(actionParamsMail);
|
||||||
ActionType sendMailAction(sendMailActionTypeId);
|
// mailActions.append(sendMailAction);
|
||||||
sendMailAction.setName("send mail");
|
|
||||||
sendMailAction.setParameters(actionParamsMail);
|
|
||||||
mailActions.append(sendMailAction);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Google Mail
|
// // Google Mail
|
||||||
// ---------------------------------------------------------------
|
// // ---------------------------------------------------------------
|
||||||
DeviceClass deviceClassGoogleMail(pluginId(), guhVendorId, googleMailDeviceClassId);
|
// DeviceClass deviceClassGoogleMail(pluginId(), supportedVendors().first().id(), googleMailDeviceClassId);
|
||||||
deviceClassGoogleMail.setName("Google Mail Notification");
|
// deviceClassGoogleMail.setName("Google Mail Notification");
|
||||||
deviceClassGoogleMail.setCreateMethod(DeviceClass::CreateMethodUser);
|
// deviceClassGoogleMail.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||||
|
|
||||||
// Params
|
// // Params
|
||||||
QList<ParamType> googleMailParams;
|
// QList<ParamType> googleMailParams;
|
||||||
|
|
||||||
ParamType userGoogleParam("user", QVariant::String);
|
// ParamType userGoogleParam("user", QVariant::String);
|
||||||
googleMailParams.append(userGoogleParam);
|
// googleMailParams.append(userGoogleParam);
|
||||||
|
|
||||||
ParamType passwordGoogleParam("password", QVariant::String);
|
// ParamType passwordGoogleParam("password", QVariant::String);
|
||||||
googleMailParams.append(passwordGoogleParam);
|
// googleMailParams.append(passwordGoogleParam);
|
||||||
|
|
||||||
ParamType recipientGoogleParam("recipient", QVariant::String);
|
// ParamType recipientGoogleParam("recipient", QVariant::String);
|
||||||
googleMailParams.append(recipientGoogleParam);
|
// googleMailParams.append(recipientGoogleParam);
|
||||||
|
|
||||||
deviceClassGoogleMail.setActions(mailActions);
|
// deviceClassGoogleMail.setActions(mailActions);
|
||||||
deviceClassGoogleMail.setParamTypes(googleMailParams);
|
// deviceClassGoogleMail.setParamTypes(googleMailParams);
|
||||||
|
|
||||||
// Custom Mail
|
// // Custom Mail
|
||||||
// ---------------------------------------------------------------
|
// // ---------------------------------------------------------------
|
||||||
DeviceClass deviceClassCustomMail(pluginId(), guhVendorId, customMailDeviceClassId);
|
// DeviceClass deviceClassCustomMail(pluginId(), supportedVendors().first().id(), customMailDeviceClassId);
|
||||||
deviceClassCustomMail.setName("Custom Mail Notification");
|
// deviceClassCustomMail.setName("Custom Mail Notification");
|
||||||
deviceClassCustomMail.setCreateMethod(DeviceClass::CreateMethodUser);
|
// deviceClassCustomMail.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||||
|
|
||||||
// Params
|
// // Params
|
||||||
QList<ParamType> customMailParams;
|
// QList<ParamType> customMailParams;
|
||||||
|
|
||||||
ParamType userCustomParam("user", QVariant::String);
|
// ParamType userCustomParam("user", QVariant::String);
|
||||||
customMailParams.append(userCustomParam);
|
// customMailParams.append(userCustomParam);
|
||||||
|
|
||||||
ParamType passwordCustomParam("password", QVariant::String);
|
// ParamType passwordCustomParam("password", QVariant::String);
|
||||||
customMailParams.append(passwordCustomParam);
|
// customMailParams.append(passwordCustomParam);
|
||||||
|
|
||||||
ParamType recipientCustomParam("recipient", QVariant::String);
|
// ParamType recipientCustomParam("recipient", QVariant::String);
|
||||||
customMailParams.append(recipientCustomParam);
|
// customMailParams.append(recipientCustomParam);
|
||||||
|
|
||||||
ParamType hostCustomParam("host", QVariant::String);
|
// ParamType hostCustomParam("host", QVariant::String);
|
||||||
customMailParams.append(hostCustomParam);
|
// customMailParams.append(hostCustomParam);
|
||||||
|
|
||||||
ParamType portCustomParam("port", QVariant::Int);
|
// ParamType portCustomParam("port", QVariant::Int);
|
||||||
customMailParams.append(portCustomParam);
|
// customMailParams.append(portCustomParam);
|
||||||
|
|
||||||
ParamType authCustomParam("auth", QVariant::String);
|
// ParamType authCustomParam("auth", QVariant::String);
|
||||||
authCustomParam.setAllowedValues(QVariantList() << "PLAIN" << "LOGIN");
|
// authCustomParam.setAllowedValues(QVariantList() << "PLAIN" << "LOGIN");
|
||||||
customMailParams.append(authCustomParam);
|
// customMailParams.append(authCustomParam);
|
||||||
|
|
||||||
deviceClassCustomMail.setActions(mailActions);
|
// deviceClassCustomMail.setActions(mailActions);
|
||||||
deviceClassCustomMail.setParamTypes(customMailParams);
|
// deviceClassCustomMail.setParamTypes(customMailParams);
|
||||||
|
|
||||||
ret.append(deviceClassGoogleMail);
|
// ret.append(deviceClassGoogleMail);
|
||||||
ret.append(deviceClassCustomMail);
|
// ret.append(deviceClassCustomMail);
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
//}
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginMailNotification::setupDevice(Device *device)
|
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginMailNotification::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
@ -384,14 +374,3 @@ QPair<DeviceManager::DeviceError, QString> DevicePluginMailNotification::execute
|
|||||||
|
|
||||||
return report();
|
return report();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginMailNotification::pluginName() const
|
|
||||||
{
|
|
||||||
return "Mail notification";
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginMailNotification::pluginId() const
|
|
||||||
{
|
|
||||||
return PluginId("72aef158-07a3-4714-93b5-fec2f9d912d1");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -33,16 +33,10 @@ public:
|
|||||||
explicit DevicePluginMailNotification();
|
explicit DevicePluginMailNotification();
|
||||||
~DevicePluginMailNotification();
|
~DevicePluginMailNotification();
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
|
||||||
PluginId pluginId() const override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SmtpClient *m_smtpClient;
|
SmtpClient *m_smtpClient;
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,10 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "Mail notification",
|
||||||
|
"id": "72aef158-07a3-4714-93b5-fec2f9d912d1",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "guh",
|
||||||
|
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -25,8 +25,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
|
|
||||||
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
|
||||||
DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
|
DeviceClassId mockDeviceClassId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
|
||||||
DeviceClassId mockDeviceAutoClassId = DeviceClassId("ab4257b3-7548-47ee-9bd4-7dc3004fd197");
|
DeviceClassId mockDeviceAutoClassId = DeviceClassId("ab4257b3-7548-47ee-9bd4-7dc3004fd197");
|
||||||
DeviceClassId mockDeviceDiscoveryClassId = DeviceClassId("1bbaf751-36b7-4d3d-b05a-58dab2a3be8c");
|
DeviceClassId mockDeviceDiscoveryClassId = DeviceClassId("1bbaf751-36b7-4d3d-b05a-58dab2a3be8c");
|
||||||
@ -51,161 +49,153 @@ DevicePluginMock::~DevicePluginMock()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginMock::supportedVendors() const
|
//QList<DeviceClass> DevicePluginMock::supportedDevices() const
|
||||||
{
|
//{
|
||||||
QList<Vendor> ret;
|
// QList<DeviceClass> ret;
|
||||||
Vendor guh(guhVendorId, "guh");
|
|
||||||
ret.append(guh);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginMock::supportedDevices() const
|
// DeviceClass deviceClassMock(pluginId(), supportedVendors().first().id(), mockDeviceClassId);
|
||||||
{
|
// deviceClassMock.setName("Mock Device");
|
||||||
QList<DeviceClass> ret;
|
|
||||||
|
|
||||||
DeviceClass deviceClassMock(pluginId(), guhVendorId, mockDeviceClassId);
|
// QList<ParamType> mockParams;
|
||||||
deviceClassMock.setName("Mock Device");
|
// ParamType portParam("httpport", QVariant::Int);
|
||||||
|
// mockParams.append(portParam);
|
||||||
|
|
||||||
QList<ParamType> mockParams;
|
// deviceClassMock.setParamTypes(mockParams);
|
||||||
ParamType portParam("httpport", QVariant::Int);
|
|
||||||
mockParams.append(portParam);
|
|
||||||
|
|
||||||
deviceClassMock.setParamTypes(mockParams);
|
// QList<StateType> mockStates;
|
||||||
|
|
||||||
QList<StateType> mockStates;
|
// StateType intState(mockIntStateId);
|
||||||
|
// intState.setName("Dummy int state");
|
||||||
|
// intState.setType(QVariant::Int);
|
||||||
|
// intState.setDefaultValue(10);
|
||||||
|
// mockStates.append(intState);
|
||||||
|
|
||||||
StateType intState(mockIntStateId);
|
// StateType boolState(mockBoolStateId);
|
||||||
intState.setName("Dummy int state");
|
// boolState.setName("Dummy bool state");
|
||||||
intState.setType(QVariant::Int);
|
// boolState.setType(QVariant::Int);
|
||||||
intState.setDefaultValue(10);
|
// boolState.setDefaultValue(false);
|
||||||
mockStates.append(intState);
|
// mockStates.append(boolState);
|
||||||
|
|
||||||
StateType boolState(mockBoolStateId);
|
// deviceClassMock.setStateTypes(mockStates);
|
||||||
boolState.setName("Dummy bool state");
|
|
||||||
boolState.setType(QVariant::Int);
|
|
||||||
boolState.setDefaultValue(false);
|
|
||||||
mockStates.append(boolState);
|
|
||||||
|
|
||||||
deviceClassMock.setStateTypes(mockStates);
|
// QList<EventType> mockEvents;
|
||||||
|
|
||||||
QList<EventType> mockEvents;
|
|
||||||
|
|
||||||
EventType event1(mockEvent1Id);
|
// EventType event1(mockEvent1Id);
|
||||||
event1.setName("Mock Event 1");
|
// event1.setName("Mock Event 1");
|
||||||
mockEvents.append(event1);
|
// mockEvents.append(event1);
|
||||||
|
|
||||||
EventType event2(mockEvent2Id);
|
// EventType event2(mockEvent2Id);
|
||||||
event2.setName("Mock Event 2");
|
// event2.setName("Mock Event 2");
|
||||||
QList<ParamType> event2ParamTypes;
|
// QList<ParamType> event2ParamTypes;
|
||||||
ParamType event2Param1Type("mockParamInt", QVariant::Int, 42);
|
// ParamType event2Param1Type("mockParamInt", QVariant::Int, 42);
|
||||||
event2ParamTypes.append(event2Param1Type);
|
// event2ParamTypes.append(event2Param1Type);
|
||||||
event2.setParameters(event2ParamTypes);
|
// event2.setParameters(event2ParamTypes);
|
||||||
mockEvents.append(event2);
|
// mockEvents.append(event2);
|
||||||
|
|
||||||
deviceClassMock.setEventTypes(mockEvents);
|
// deviceClassMock.setEventTypes(mockEvents);
|
||||||
|
|
||||||
QList<ActionType> mockActions;
|
// QList<ActionType> mockActions;
|
||||||
|
|
||||||
mockParams.clear();
|
// mockParams.clear();
|
||||||
ActionType action1(mockActionIdWithParams);
|
// ActionType action1(mockActionIdWithParams);
|
||||||
action1.setName("Mock Action 1 (with params)");
|
// action1.setName("Mock Action 1 (with params)");
|
||||||
ParamType mockActionParam1("mockActionParam1", QVariant::Int);
|
// ParamType mockActionParam1("mockActionParam1", QVariant::Int);
|
||||||
mockParams.append(mockActionParam1);
|
// mockParams.append(mockActionParam1);
|
||||||
ParamType mockActionParam2("mockActionParam2", QVariant::Bool);
|
// ParamType mockActionParam2("mockActionParam2", QVariant::Bool);
|
||||||
mockParams.append(mockActionParam2);
|
// mockParams.append(mockActionParam2);
|
||||||
action1.setParameters(mockParams);
|
// action1.setParameters(mockParams);
|
||||||
mockActions.append(action1);
|
// mockActions.append(action1);
|
||||||
|
|
||||||
ActionType action2(mockActionIdNoParams);
|
// ActionType action2(mockActionIdNoParams);
|
||||||
action2.setName("Mock Action 3 (without params)");
|
// action2.setName("Mock Action 3 (without params)");
|
||||||
mockActions.append(action2);
|
// mockActions.append(action2);
|
||||||
|
|
||||||
ActionType action3(mockActionIdAsync);
|
// ActionType action3(mockActionIdAsync);
|
||||||
action3.setName("Mock Action 3 (async)");
|
// action3.setName("Mock Action 3 (async)");
|
||||||
mockActions.append(action3);
|
// mockActions.append(action3);
|
||||||
|
|
||||||
ActionType action4(mockActionIdFailing);
|
// ActionType action4(mockActionIdFailing);
|
||||||
action4.setName("Mock Action 4 (broken)");
|
// action4.setName("Mock Action 4 (broken)");
|
||||||
mockActions.append(action4);
|
// mockActions.append(action4);
|
||||||
|
|
||||||
ActionType action5(mockActionIdAsyncFailing);
|
// ActionType action5(mockActionIdAsyncFailing);
|
||||||
action5.setName("Mock Action 5 (async, broken)");
|
// action5.setName("Mock Action 5 (async, broken)");
|
||||||
mockActions.append(action4);
|
// mockActions.append(action4);
|
||||||
|
|
||||||
deviceClassMock.setActions(mockActions);
|
// deviceClassMock.setActions(mockActions);
|
||||||
|
|
||||||
ret.append(deviceClassMock);
|
// ret.append(deviceClassMock);
|
||||||
|
|
||||||
// Auto created mock device
|
// // Auto created mock device
|
||||||
DeviceClass deviceClassMockAuto(pluginId(), guhVendorId, mockDeviceAutoClassId);
|
// DeviceClass deviceClassMockAuto(pluginId(), supportedVendors().first().id(), mockDeviceAutoClassId);
|
||||||
deviceClassMockAuto.setName("Mock Device (Auto created)");
|
// deviceClassMockAuto.setName("Mock Device (Auto created)");
|
||||||
deviceClassMockAuto.setCreateMethod(DeviceClass::CreateMethodAuto);
|
// deviceClassMockAuto.setCreateMethod(DeviceClass::CreateMethodAuto);
|
||||||
|
|
||||||
mockParams.clear();
|
// mockParams.clear();
|
||||||
deviceClassMockAuto.setParamTypes(mockParams);
|
// deviceClassMockAuto.setParamTypes(mockParams);
|
||||||
deviceClassMockAuto.setStateTypes(mockStates);
|
// deviceClassMockAuto.setStateTypes(mockStates);
|
||||||
deviceClassMockAuto.setEventTypes(mockEvents);
|
// deviceClassMockAuto.setEventTypes(mockEvents);
|
||||||
deviceClassMockAuto.setActions(mockActions);
|
// deviceClassMockAuto.setActions(mockActions);
|
||||||
|
|
||||||
ret.append(deviceClassMockAuto);
|
// ret.append(deviceClassMockAuto);
|
||||||
|
|
||||||
// Discovery created device
|
// // Discovery created device
|
||||||
DeviceClass deviceClassMockDiscovery(pluginId(), guhVendorId, mockDeviceDiscoveryClassId);
|
// DeviceClass deviceClassMockDiscovery(pluginId(), supportedVendors().first().id(), mockDeviceDiscoveryClassId);
|
||||||
deviceClassMockDiscovery.setName("Mock Device (Discovery created)");
|
// deviceClassMockDiscovery.setName("Mock Device (Discovery created)");
|
||||||
deviceClassMockDiscovery.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
// deviceClassMockDiscovery.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
||||||
QList<ParamType> paramTypes;
|
// QList<ParamType> paramTypes;
|
||||||
ParamType paramType = ParamType("resultCount", QVariant::Int, 2);
|
// ParamType paramType = ParamType("resultCount", QVariant::Int, 2);
|
||||||
paramType.setAllowedValues(QList<QVariant>() << 1 << 2);
|
// paramType.setAllowedValues(QList<QVariant>() << 1 << 2);
|
||||||
paramTypes.append(paramType);
|
// paramTypes.append(paramType);
|
||||||
deviceClassMockDiscovery.setDiscoveryParamTypes(paramTypes);
|
// deviceClassMockDiscovery.setDiscoveryParamTypes(paramTypes);
|
||||||
|
|
||||||
mockParams.clear();
|
// mockParams.clear();
|
||||||
mockParams.append(portParam);
|
// mockParams.append(portParam);
|
||||||
deviceClassMockDiscovery.setParamTypes(mockParams);
|
// deviceClassMockDiscovery.setParamTypes(mockParams);
|
||||||
deviceClassMockDiscovery.setStateTypes(mockStates);
|
// deviceClassMockDiscovery.setStateTypes(mockStates);
|
||||||
deviceClassMockDiscovery.setEventTypes(mockEvents);
|
// deviceClassMockDiscovery.setEventTypes(mockEvents);
|
||||||
deviceClassMockDiscovery.setActions(mockActions);
|
// deviceClassMockDiscovery.setActions(mockActions);
|
||||||
|
|
||||||
ret.append(deviceClassMockDiscovery);
|
// ret.append(deviceClassMockDiscovery);
|
||||||
|
|
||||||
// Async setup device
|
// // Async setup device
|
||||||
DeviceClass deviceClassMockAsync(pluginId(), guhVendorId, mockDeviceAsyncSetupClassId);
|
// DeviceClass deviceClassMockAsync(pluginId(), supportedVendors().first().id(), mockDeviceAsyncSetupClassId);
|
||||||
deviceClassMockAsync.setName("Mock Device (Async)");
|
// deviceClassMockAsync.setName("Mock Device (Async)");
|
||||||
deviceClassMockAsync.setCreateMethod(DeviceClass::CreateMethodUser);
|
// deviceClassMockAsync.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||||
|
|
||||||
deviceClassMockAsync.setParamTypes(mockParams);
|
// deviceClassMockAsync.setParamTypes(mockParams);
|
||||||
deviceClassMockAsync.setStateTypes(mockStates);
|
// deviceClassMockAsync.setStateTypes(mockStates);
|
||||||
deviceClassMockAsync.setEventTypes(mockEvents);
|
// deviceClassMockAsync.setEventTypes(mockEvents);
|
||||||
deviceClassMockAsync.setActions(mockActions);
|
// deviceClassMockAsync.setActions(mockActions);
|
||||||
|
|
||||||
ret.append(deviceClassMockAsync);
|
// ret.append(deviceClassMockAsync);
|
||||||
|
|
||||||
// Async setup device
|
// // Async setup device
|
||||||
DeviceClass deviceClassMockBroken(pluginId(), guhVendorId, mockDeviceBrokenClassId);
|
// DeviceClass deviceClassMockBroken(pluginId(), supportedVendors().first().id(), mockDeviceBrokenClassId);
|
||||||
deviceClassMockBroken.setName("Mock Device (Broken setup)");
|
// deviceClassMockBroken.setName("Mock Device (Broken setup)");
|
||||||
deviceClassMockBroken.setCreateMethod(DeviceClass::CreateMethodUser);
|
// deviceClassMockBroken.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||||
|
|
||||||
deviceClassMockBroken.setParamTypes(mockParams);
|
// deviceClassMockBroken.setParamTypes(mockParams);
|
||||||
deviceClassMockBroken.setStateTypes(mockStates);
|
// deviceClassMockBroken.setStateTypes(mockStates);
|
||||||
deviceClassMockBroken.setEventTypes(mockEvents);
|
// deviceClassMockBroken.setEventTypes(mockEvents);
|
||||||
deviceClassMockBroken.setActions(mockActions);
|
// deviceClassMockBroken.setActions(mockActions);
|
||||||
|
|
||||||
ret.append(deviceClassMockBroken);
|
// ret.append(deviceClassMockBroken);
|
||||||
|
|
||||||
// Broken Async setup device
|
// // Broken Async setup device
|
||||||
DeviceClass deviceClassMockBrokenAsyncSetup(pluginId(), guhVendorId, mockDeviceBrokenAsyncSetupClassId);
|
// DeviceClass deviceClassMockBrokenAsyncSetup(pluginId(), supportedVendors().first().id(), mockDeviceBrokenAsyncSetupClassId);
|
||||||
deviceClassMockBrokenAsyncSetup.setName("Mock Device (Async Broken setup)");
|
// deviceClassMockBrokenAsyncSetup.setName("Mock Device (Async Broken setup)");
|
||||||
deviceClassMockBrokenAsyncSetup.setCreateMethod(DeviceClass::CreateMethodUser);
|
// deviceClassMockBrokenAsyncSetup.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||||
|
|
||||||
deviceClassMockBrokenAsyncSetup.setParamTypes(mockParams);
|
// deviceClassMockBrokenAsyncSetup.setParamTypes(mockParams);
|
||||||
deviceClassMockBrokenAsyncSetup.setStateTypes(mockStates);
|
// deviceClassMockBrokenAsyncSetup.setStateTypes(mockStates);
|
||||||
deviceClassMockBrokenAsyncSetup.setEventTypes(mockEvents);
|
// deviceClassMockBrokenAsyncSetup.setEventTypes(mockEvents);
|
||||||
deviceClassMockBrokenAsyncSetup.setActions(mockActions);
|
// deviceClassMockBrokenAsyncSetup.setActions(mockActions);
|
||||||
|
|
||||||
ret.append(deviceClassMockBrokenAsyncSetup);
|
// ret.append(deviceClassMockBrokenAsyncSetup);
|
||||||
|
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
//}
|
||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginMock::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginMock::requiredHardware() const
|
||||||
{
|
{
|
||||||
@ -221,16 +211,6 @@ QPair<DeviceManager::DeviceError, QString> DevicePluginMock::discoverDevices(con
|
|||||||
return report(DeviceManager::DeviceErrorNoError);
|
return report(DeviceManager::DeviceErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginMock::pluginName() const
|
|
||||||
{
|
|
||||||
return "Mock Devices";
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginMock::pluginId() const
|
|
||||||
{
|
|
||||||
return mockPluginId;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginMock::setupDevice(Device *device)
|
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginMock::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
qDebug() << "Mockdevice created returning true" << device->paramValue("httpport").toInt();
|
qDebug() << "Mockdevice created returning true" << device->paramValue("httpport").toInt();
|
||||||
|
|||||||
@ -36,14 +36,9 @@ public:
|
|||||||
explicit DevicePluginMock();
|
explicit DevicePluginMock();
|
||||||
~DevicePluginMock();
|
~DevicePluginMock();
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
QPair<DeviceManager::DeviceError, QString> discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
QPair<DeviceManager::DeviceError, QString> discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
|
||||||
PluginId pluginId() const override;
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
||||||
void deviceRemoved(Device *device) override;
|
void deviceRemoved(Device *device) override;
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,11 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "Mock Devices",
|
||||||
|
"id": "727a4a9a-c187-446f-aadf-f1b2220607d1",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "guh",
|
||||||
|
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6"
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -278,7 +278,7 @@
|
|||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
VendorId openweathermapVendorId = VendorId("bf1e96f0-9650-4e7c-a56c-916d54d18e7a");
|
VendorId openweathermapVendorId = VendorId("");
|
||||||
DeviceClassId openweathermapDeviceClassId = DeviceClassId("985195aa-17ad-4530-88a4-cdd753d747d7");
|
DeviceClassId openweathermapDeviceClassId = DeviceClassId("985195aa-17ad-4530-88a4-cdd753d747d7");
|
||||||
|
|
||||||
ActionTypeId updateWeatherActionTypeId = ActionTypeId("cfbc6504-d86f-4856-8dfa-97b6fbb385e4");
|
ActionTypeId updateWeatherActionTypeId = ActionTypeId("cfbc6504-d86f-4856-8dfa-97b6fbb385e4");
|
||||||
@ -304,125 +304,6 @@ DevicePluginOpenweathermap::DevicePluginOpenweathermap()
|
|||||||
connect(m_openweaher, SIGNAL(weatherDataReady(QByteArray)), this, SLOT(weatherDataReady(QByteArray)));
|
connect(m_openweaher, SIGNAL(weatherDataReady(QByteArray)), this, SLOT(weatherDataReady(QByteArray)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginOpenweathermap::supportedVendors() const
|
|
||||||
{
|
|
||||||
QList<Vendor> ret;
|
|
||||||
Vendor openweathermap(openweathermapVendorId, "Openweathermap");
|
|
||||||
ret.append(openweathermap);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginOpenweathermap::supportedDevices() const
|
|
||||||
{
|
|
||||||
QList<DeviceClass> ret;
|
|
||||||
|
|
||||||
DeviceClass deviceClassOpenweathermap(pluginId(), openweathermapVendorId, openweathermapDeviceClassId);
|
|
||||||
deviceClassOpenweathermap.setName("Weather from openweathermap.org");
|
|
||||||
deviceClassOpenweathermap.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
|
||||||
|
|
||||||
// Params
|
|
||||||
QList<ParamType> params;
|
|
||||||
ParamType locationParam("location", QVariant::String);
|
|
||||||
params.append(locationParam);
|
|
||||||
|
|
||||||
//Location is all we need for discovery.
|
|
||||||
deviceClassOpenweathermap.setDiscoveryParamTypes(params);
|
|
||||||
|
|
||||||
ParamType countryParam("country", QVariant::String);
|
|
||||||
params.append(countryParam);
|
|
||||||
|
|
||||||
ParamType idParam("id", QVariant::String);
|
|
||||||
params.append(idParam);
|
|
||||||
|
|
||||||
deviceClassOpenweathermap.setParamTypes(params);
|
|
||||||
|
|
||||||
// Actions
|
|
||||||
QList<ActionType> weatherActions;
|
|
||||||
ActionType updateWeather(updateWeatherActionTypeId);
|
|
||||||
updateWeather.setName("refresh");
|
|
||||||
weatherActions.append(updateWeather);
|
|
||||||
|
|
||||||
// States
|
|
||||||
QList<StateType> weatherStates;
|
|
||||||
StateType updateTimeState(updateTimeStateTypeId);
|
|
||||||
updateTimeState.setName("last update [unixtime]");
|
|
||||||
updateTimeState.setType(QVariant::UInt);
|
|
||||||
updateTimeState.setDefaultValue(0);
|
|
||||||
weatherStates.append(updateTimeState);
|
|
||||||
|
|
||||||
StateType temperatureState(temperatureStateTypeId);
|
|
||||||
temperatureState.setName("temperature [Celsius]");
|
|
||||||
temperatureState.setType(QVariant::Double);
|
|
||||||
temperatureState.setDefaultValue(-999.9);
|
|
||||||
weatherStates.append(temperatureState);
|
|
||||||
|
|
||||||
StateType temperatureMinState(temperatureMinStateTypeId);
|
|
||||||
temperatureMinState.setName("temperature minimum [Celsius]");
|
|
||||||
temperatureMinState.setType(QVariant::Double);
|
|
||||||
temperatureMinState.setDefaultValue(-999.9);
|
|
||||||
weatherStates.append(temperatureMinState);
|
|
||||||
|
|
||||||
StateType temperatureMaxState(temperatureMaxStateTypeId);
|
|
||||||
temperatureMaxState.setName("temperature maximum [Celsius]");
|
|
||||||
temperatureMaxState.setType(QVariant::Double);
|
|
||||||
temperatureMaxState.setDefaultValue(999.9);
|
|
||||||
weatherStates.append(temperatureMaxState);
|
|
||||||
|
|
||||||
StateType humidityState(humidityStateTypeId);
|
|
||||||
humidityState.setName("humidity [%]");
|
|
||||||
humidityState.setType(QVariant::Int);
|
|
||||||
humidityState.setDefaultValue(-1);
|
|
||||||
weatherStates.append(humidityState);
|
|
||||||
|
|
||||||
StateType pressureState(pressureStateTypeId);
|
|
||||||
pressureState.setName("pressure [hPa]");
|
|
||||||
pressureState.setType(QVariant::Double);
|
|
||||||
pressureState.setDefaultValue(-1);
|
|
||||||
weatherStates.append(pressureState);
|
|
||||||
|
|
||||||
StateType windSpeedState(windSpeedStateTypeId);
|
|
||||||
windSpeedState.setName("wind speed [m/s]");
|
|
||||||
windSpeedState.setType(QVariant::Double);
|
|
||||||
windSpeedState.setDefaultValue(-1);
|
|
||||||
weatherStates.append(windSpeedState);
|
|
||||||
|
|
||||||
StateType windDirectionState(windDirectionStateTypeId);
|
|
||||||
windDirectionState.setName("wind direction [degree]");
|
|
||||||
windDirectionState.setType(QVariant::Int);
|
|
||||||
windDirectionState.setDefaultValue(-1);
|
|
||||||
weatherStates.append(windDirectionState);
|
|
||||||
|
|
||||||
StateType cloudinessState(cloudinessStateTypeId);
|
|
||||||
cloudinessState.setName("cloudiness [%]");
|
|
||||||
cloudinessState.setType(QVariant::Int);
|
|
||||||
cloudinessState.setDefaultValue(-1);
|
|
||||||
weatherStates.append(cloudinessState);
|
|
||||||
|
|
||||||
StateType weatherDescriptionState(weatherDescriptionStateTypeId);
|
|
||||||
weatherDescriptionState.setName("weather description");
|
|
||||||
weatherDescriptionState.setType(QVariant::String);
|
|
||||||
weatherDescriptionState.setDefaultValue("");
|
|
||||||
weatherStates.append(weatherDescriptionState);
|
|
||||||
|
|
||||||
StateType sunsetState(sunsetStateTypeId);
|
|
||||||
sunsetState.setName("sunset [unixtime]");
|
|
||||||
sunsetState.setType(QVariant::UInt);
|
|
||||||
sunsetState.setDefaultValue(0);
|
|
||||||
weatherStates.append(sunsetState);
|
|
||||||
|
|
||||||
StateType sunriseState(sunriseStateTypeId);
|
|
||||||
sunriseState.setName("sunrise [unixtime]");
|
|
||||||
sunriseState.setType(QVariant::UInt);
|
|
||||||
sunriseState.setDefaultValue(0);
|
|
||||||
weatherStates.append(sunriseState);
|
|
||||||
|
|
||||||
deviceClassOpenweathermap.setActions(weatherActions);
|
|
||||||
deviceClassOpenweathermap.setStateTypes(weatherStates);
|
|
||||||
|
|
||||||
ret.append(deviceClassOpenweathermap);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceError, QString> DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
QPair<DeviceManager::DeviceError, QString> DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||||
{
|
{
|
||||||
if(deviceClassId == openweathermapDeviceClassId){
|
if(deviceClassId == openweathermapDeviceClassId){
|
||||||
@ -472,16 +353,6 @@ QPair<DeviceManager::DeviceError, QString> DevicePluginOpenweathermap::executeAc
|
|||||||
return report();
|
return report();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginOpenweathermap::pluginName() const
|
|
||||||
{
|
|
||||||
return "Openweathermap";
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginOpenweathermap::pluginId() const
|
|
||||||
{
|
|
||||||
return PluginId("bc6af567-2338-41d5-aac1-462dec6e4783");
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginOpenweathermap::guhTimer()
|
void DevicePluginOpenweathermap::guhTimer()
|
||||||
{
|
{
|
||||||
foreach (Device *device, deviceManager()->findConfiguredDevices(openweathermapDeviceClassId)) {
|
foreach (Device *device, deviceManager()->findConfiguredDevices(openweathermapDeviceClassId)) {
|
||||||
|
|||||||
@ -35,17 +35,11 @@ public:
|
|||||||
|
|
||||||
OpenWeatherMap *m_openweaher;
|
OpenWeatherMap *m_openweaher;
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceError, QString> discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
QPair<DeviceManager::DeviceError, QString> discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
|
||||||
PluginId pluginId() const override;
|
|
||||||
|
|
||||||
void guhTimer() override;
|
void guhTimer() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
@ -1 +1,11 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "Openweathermap",
|
||||||
|
"id": "bc6af567-2338-41d5-aac1-462dec6e4783",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "Openweathermap",
|
||||||
|
"id": "bf1e96f0-9650-4e7c-a56c-916d54d18e7a"
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -27,9 +27,8 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
VendorId hueVendorId = VendorId("0ae1e001-2aa6-47ed-b8c0-334c3728a68f");
|
VendorId hueVendorId = VendorId("");
|
||||||
|
|
||||||
PluginId huePluginUuid = PluginId("5f2e634b-b7f3-48ee-976a-b5ae22aa5c55");
|
|
||||||
DeviceClassId hueDeviceClassId = DeviceClassId("d8f4c397-e05e-47c1-8917-8e72d4d0d47c");
|
DeviceClassId hueDeviceClassId = DeviceClassId("d8f4c397-e05e-47c1-8917-8e72d4d0d47c");
|
||||||
DeviceClassId hueDeviceClassAutoId = DeviceClassId("9cce5981-50a1-4873-a374-c53c095feb3b");
|
DeviceClassId hueDeviceClassAutoId = DeviceClassId("9cce5981-50a1-4873-a374-c53c095feb3b");
|
||||||
|
|
||||||
@ -54,109 +53,75 @@ DevicePluginPhilipsHue::DevicePluginPhilipsHue():
|
|||||||
connect(m_bridge, &HueBridgeConnection::getFinished, this, &DevicePluginPhilipsHue::getFinished);
|
connect(m_bridge, &HueBridgeConnection::getFinished, this, &DevicePluginPhilipsHue::getFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginPhilipsHue::supportedVendors() const
|
//QList<DeviceClass> DevicePluginPhilipsHue::supportedDevices() const
|
||||||
{
|
//{
|
||||||
QList<Vendor> ret;
|
// QList<DeviceClass> ret;
|
||||||
Vendor philips(hueVendorId, "Philips");
|
|
||||||
ret.append(philips);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginPhilipsHue::supportedDevices() const
|
|
||||||
{
|
|
||||||
QList<DeviceClass> ret;
|
|
||||||
|
|
||||||
DeviceClass deviceClassHue(pluginId(), hueVendorId, hueDeviceClassId);
|
|
||||||
deviceClassHue.setName("Hue");
|
|
||||||
deviceClassHue.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
|
||||||
|
|
||||||
deviceClassHue.setSetupMethod(DeviceClass::SetupMethodPushButton);
|
|
||||||
deviceClassHue.setPairingInfo("Please press the button on the Hue bridge and then press OK");
|
|
||||||
|
|
||||||
QList<ParamType> paramTypes;
|
|
||||||
ParamType ipParam("ip", QVariant::String);
|
|
||||||
paramTypes.append(ipParam);
|
|
||||||
ParamType usernameParam("username", QVariant::String);
|
|
||||||
paramTypes.append(usernameParam);
|
|
||||||
ParamType numberParam("number", QVariant::Int, -1);
|
|
||||||
paramTypes.append(numberParam);
|
|
||||||
deviceClassHue.setParamTypes(paramTypes);
|
|
||||||
|
|
||||||
QList<StateType> hueStates;
|
|
||||||
|
|
||||||
StateType reachableState(hueReachableStateTypeId);
|
|
||||||
reachableState.setName("reachable");
|
|
||||||
reachableState.setType(QVariant::Bool);
|
|
||||||
hueStates.append(reachableState);
|
|
||||||
|
|
||||||
StateType colorState(hueColorStateTypeId);
|
|
||||||
colorState.setName("color");
|
|
||||||
colorState.setType(QVariant::Color);
|
|
||||||
colorState.setDefaultValue(QColor(Qt::black));
|
|
||||||
hueStates.append(colorState);
|
|
||||||
|
|
||||||
StateType powerState(huePowerStateTypeId);
|
|
||||||
powerState.setName("power");
|
|
||||||
powerState.setType(QVariant::Bool);
|
|
||||||
powerState.setDefaultValue(false);
|
|
||||||
hueStates.append(powerState);
|
|
||||||
|
|
||||||
StateType brightnessState(hueBrightnessStateTypeId);
|
|
||||||
brightnessState.setName("brightness");
|
|
||||||
brightnessState.setType(QVariant::Int);
|
|
||||||
brightnessState.setDefaultValue(255);
|
|
||||||
hueStates.append(brightnessState);
|
|
||||||
|
|
||||||
deviceClassHue.setStateTypes(hueStates);
|
|
||||||
|
|
||||||
QList<ActionType> hueActons;
|
|
||||||
|
|
||||||
ActionType setColorAction(hueSetColorActionTypeId);
|
|
||||||
setColorAction.setName("Set color");
|
|
||||||
QList<ParamType> actionParamsSetColor;
|
|
||||||
ParamType actionParamSetColor("color", QVariant::Color);
|
|
||||||
actionParamsSetColor.append(actionParamSetColor);
|
|
||||||
setColorAction.setParameters(actionParamsSetColor);
|
|
||||||
hueActons.append(setColorAction);
|
|
||||||
|
|
||||||
ActionType setPowerAction(hueSetPowerActionTypeId);
|
|
||||||
setPowerAction.setName("Power");
|
|
||||||
QList<ParamType> actionParamsSetPower;
|
|
||||||
ParamType actionParamSetPower("power", QVariant::Bool);
|
|
||||||
actionParamsSetPower.append(actionParamSetPower);
|
|
||||||
setPowerAction.setParameters(actionParamsSetPower);
|
|
||||||
hueActons.append(setPowerAction);
|
|
||||||
|
|
||||||
ActionType setBrightnessAction(hueSetBrightnessActionTypeId);
|
|
||||||
setBrightnessAction.setName("Brightness");
|
|
||||||
QList<ParamType> actionParamsSetBrightness;
|
|
||||||
ParamType actionParamSetBrightness("brightness", QVariant::Int);
|
|
||||||
actionParamSetBrightness.setMinValue(0);
|
|
||||||
actionParamSetBrightness.setMaxValue(255);
|
|
||||||
actionParamsSetBrightness.append(actionParamSetBrightness);
|
|
||||||
setBrightnessAction.setParameters(actionParamsSetBrightness);
|
|
||||||
hueActons.append(setBrightnessAction);
|
|
||||||
|
|
||||||
deviceClassHue.setActions(hueActons);
|
|
||||||
|
|
||||||
ret.append(deviceClassHue);
|
|
||||||
|
|
||||||
// Now create the same device again with CreateMethodAuto
|
|
||||||
// When we pair a bridge, one discovered device is created.
|
|
||||||
// The other light bulbs connected to the bridge will
|
|
||||||
// then appear as auto devices.
|
|
||||||
DeviceClass deviceClassHueAuto(pluginId(), hueVendorId, hueDeviceClassAutoId);
|
|
||||||
deviceClassHueAuto.setName("Hue");
|
|
||||||
deviceClassHueAuto.setCreateMethod(DeviceClass::CreateMethodAuto);
|
|
||||||
deviceClassHueAuto.setParamTypes(paramTypes);
|
|
||||||
deviceClassHueAuto.setStateTypes(hueStates);
|
|
||||||
deviceClassHueAuto.setActions(hueActons);
|
|
||||||
|
|
||||||
ret.append(deviceClassHueAuto);
|
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
// QList<StateType> hueStates;
|
||||||
}
|
|
||||||
|
// StateType powerState(huePowerStateTypeId);
|
||||||
|
// powerState.setName("power");
|
||||||
|
// powerState.setType(QVariant::Bool);
|
||||||
|
// powerState.setDefaultValue(false);
|
||||||
|
// hueStates.append(powerState);
|
||||||
|
|
||||||
|
// StateType brightnessState(hueBrightnessStateTypeId);
|
||||||
|
// brightnessState.setName("brightness");
|
||||||
|
// brightnessState.setType(QVariant::Int);
|
||||||
|
// brightnessState.setDefaultValue(255);
|
||||||
|
// hueStates.append(brightnessState);
|
||||||
|
|
||||||
|
// deviceClassHue.setStateTypes(hueStates);
|
||||||
|
|
||||||
|
// QList<ActionType> hueActons;
|
||||||
|
|
||||||
|
// ActionType setColorAction(hueSetColorActionTypeId);
|
||||||
|
// setColorAction.setName("Set color");
|
||||||
|
// QList<ParamType> actionParamsSetColor;
|
||||||
|
// ParamType actionParamSetColor("color", QVariant::Color);
|
||||||
|
// actionParamsSetColor.append(actionParamSetColor);
|
||||||
|
// setColorAction.setParameters(actionParamsSetColor);
|
||||||
|
// hueActons.append(setColorAction);
|
||||||
|
|
||||||
|
// ActionType setPowerAction(hueSetPowerActionTypeId);
|
||||||
|
// setPowerAction.setName("Power");
|
||||||
|
// QList<ParamType> actionParamsSetPower;
|
||||||
|
// ParamType actionParamSetPower("power", QVariant::Bool);
|
||||||
|
// actionParamsSetPower.append(actionParamSetPower);
|
||||||
|
// setPowerAction.setParameters(actionParamsSetPower);
|
||||||
|
// hueActons.append(setPowerAction);
|
||||||
|
|
||||||
|
// ActionType setBrightnessAction(hueSetBrightnessActionTypeId);
|
||||||
|
// setBrightnessAction.setName("Brightness");
|
||||||
|
// QList<ParamType> actionParamsSetBrightness;
|
||||||
|
// ParamType actionParamSetBrightness("brightness", QVariant::Int);
|
||||||
|
// actionParamSetBrightness.setMinValue(0);
|
||||||
|
// actionParamSetBrightness.setMaxValue(255);
|
||||||
|
// actionParamsSetBrightness.append(actionParamSetBrightness);
|
||||||
|
// setBrightnessAction.setParameters(actionParamsSetBrightness);
|
||||||
|
// hueActons.append(setBrightnessAction);
|
||||||
|
|
||||||
|
// deviceClassHue.setActions(hueActons);
|
||||||
|
|
||||||
|
// ret.append(deviceClassHue);
|
||||||
|
|
||||||
|
// // Now create the same device again with CreateMethodAuto
|
||||||
|
// // When we pair a bridge, one discovered device is created.
|
||||||
|
// // The other light bulbs connected to the bridge will
|
||||||
|
// // then appear as auto devices.
|
||||||
|
// DeviceClass deviceClassHueAuto(pluginId(), hueVendorId, hueDeviceClassAutoId);
|
||||||
|
// deviceClassHueAuto.setName("Hue");
|
||||||
|
// deviceClassHueAuto.setCreateMethod(DeviceClass::CreateMethodAuto);
|
||||||
|
// deviceClassHueAuto.setParamTypes(paramTypes);
|
||||||
|
// deviceClassHueAuto.setStateTypes(hueStates);
|
||||||
|
// deviceClassHueAuto.setActions(hueActons);
|
||||||
|
|
||||||
|
// ret.append(deviceClassHueAuto);
|
||||||
|
|
||||||
|
|
||||||
|
// return ret;
|
||||||
|
//}
|
||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginPhilipsHue::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginPhilipsHue::requiredHardware() const
|
||||||
{
|
{
|
||||||
@ -169,16 +134,6 @@ void DevicePluginPhilipsHue::startMonitoringAutoDevices()
|
|||||||
// Although we maybe want to think of a user triggered approach to do such things.
|
// Although we maybe want to think of a user triggered approach to do such things.
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginPhilipsHue::pluginName() const
|
|
||||||
{
|
|
||||||
return "Philips Hue";
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginPhilipsHue::pluginId() const
|
|
||||||
{
|
|
||||||
return huePluginUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<ParamType> DevicePluginPhilipsHue::configurationDescription() const
|
QList<ParamType> DevicePluginPhilipsHue::configurationDescription() const
|
||||||
{
|
{
|
||||||
QList<ParamType> params;
|
QList<ParamType> params;
|
||||||
|
|||||||
@ -36,15 +36,10 @@ class DevicePluginPhilipsHue: public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginPhilipsHue();
|
explicit DevicePluginPhilipsHue();
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
void startMonitoringAutoDevices() override;
|
void startMonitoringAutoDevices() override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
|
||||||
PluginId pluginId() const override;
|
|
||||||
|
|
||||||
QList<ParamType> configurationDescription() const override;
|
QList<ParamType> configurationDescription() const override;
|
||||||
QPair<DeviceManager::DeviceError, QString> discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
QPair<DeviceManager::DeviceError, QString> discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,46 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "Philips Hue",
|
||||||
|
"id": "5f2e634b-b7f3-48ee-976a-b5ae22aa5c55",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"id": "0ae1e001-2aa6-47ed-b8c0-334c3728a68f",
|
||||||
|
"name": "Philips",
|
||||||
|
"deviceClasses": [
|
||||||
|
{
|
||||||
|
"deviceClassId": "d8f4c397-e05e-47c1-8917-8e72d4d0d47c",
|
||||||
|
"name": "Hue",
|
||||||
|
"createMethod": "discovery",
|
||||||
|
"setupMethod": "pushButton",
|
||||||
|
"pairingInfo": "Please press the button on the Hue bridge and then press OK",
|
||||||
|
"paramTypes": [
|
||||||
|
{
|
||||||
|
"name": "ip",
|
||||||
|
"type" : "QString"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "username",
|
||||||
|
"type" : "QString"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "lightId",
|
||||||
|
"type" : "int"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateTypes": [
|
||||||
|
{
|
||||||
|
"id": "15794d26-fde8-4a61-8f83-d7830534975f",
|
||||||
|
"name": "reachable",
|
||||||
|
"type": "bool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "d25423e7-b924-4b20-80b6-77eecc65d089",
|
||||||
|
"name": "color",
|
||||||
|
"type": "color",
|
||||||
|
"defaultValue": "black"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -123,7 +123,6 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
|
|
||||||
extern VendorId guhVendorId;
|
|
||||||
DeviceClassId wolDeviceClassId = DeviceClassId("3c8f2447-dcd0-4882-8c09-99e579e4d24c");
|
DeviceClassId wolDeviceClassId = DeviceClassId("3c8f2447-dcd0-4882-8c09-99e579e4d24c");
|
||||||
ActionTypeId wolActionTypeId = ActionTypeId("fb9b9d87-218f-4f0d-9e16-39f8a105029a");
|
ActionTypeId wolActionTypeId = ActionTypeId("fb9b9d87-218f-4f0d-9e16-39f8a105029a");
|
||||||
|
|
||||||
@ -131,55 +130,37 @@ DevicePluginWakeOnLan::DevicePluginWakeOnLan()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginWakeOnLan::supportedVendors() const
|
//QList<DeviceClass> DevicePluginWakeOnLan::supportedDevices() const
|
||||||
{
|
//{
|
||||||
QList<Vendor> ret;
|
// QList<DeviceClass> ret;
|
||||||
Vendor guh(guhVendorId, "guh");
|
|
||||||
ret.append(guh);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginWakeOnLan::supportedDevices() const
|
// DeviceClass deviceClassWakeOnLan(pluginId(), supportedVendors().first().id(), wolDeviceClassId);
|
||||||
{
|
// deviceClassWakeOnLan.setName("Wake On Lan");
|
||||||
QList<DeviceClass> ret;
|
|
||||||
|
|
||||||
DeviceClass deviceClassWakeOnLan(pluginId(), guhVendorId, wolDeviceClassId);
|
|
||||||
deviceClassWakeOnLan.setName("Wake On Lan");
|
|
||||||
|
|
||||||
QList<ParamType> wolParams;
|
// QList<ParamType> wolParams;
|
||||||
ParamType nameParam("name", QVariant::String);
|
// ParamType nameParam("name", QVariant::String);
|
||||||
wolParams.append(nameParam);
|
// wolParams.append(nameParam);
|
||||||
ParamType wolParam("mac", QVariant::String);
|
// ParamType wolParam("mac", QVariant::String);
|
||||||
wolParams.append(wolParam);
|
// wolParams.append(wolParam);
|
||||||
|
|
||||||
|
|
||||||
QList<ActionType> wolActions;
|
// QList<ActionType> wolActions;
|
||||||
ActionType wolAction(wolActionTypeId);
|
// ActionType wolAction(wolActionTypeId);
|
||||||
wolAction.setName("wakeup");
|
// wolAction.setName("wakeup");
|
||||||
wolActions.append(wolAction);
|
// wolActions.append(wolAction);
|
||||||
|
|
||||||
deviceClassWakeOnLan.setParamTypes(wolParams);
|
// deviceClassWakeOnLan.setParamTypes(wolParams);
|
||||||
deviceClassWakeOnLan.setActions(wolActions);
|
// deviceClassWakeOnLan.setActions(wolActions);
|
||||||
|
|
||||||
ret.append(deviceClassWakeOnLan);
|
// ret.append(deviceClassWakeOnLan);
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
//}
|
||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginWakeOnLan::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginWakeOnLan::requiredHardware() const
|
||||||
{
|
{
|
||||||
return DeviceManager::HardwareResourceNone;
|
return DeviceManager::HardwareResourceNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginWakeOnLan::pluginName() const
|
|
||||||
{
|
|
||||||
return "Wake On Lan";
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginWakeOnLan::pluginId() const
|
|
||||||
{
|
|
||||||
return PluginId("b5a87848-de56-451e-84a6-edd26ad4958f");
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceError, QString> DevicePluginWakeOnLan::executeAction(Device *device, const Action &action)
|
QPair<DeviceManager::DeviceError, QString> DevicePluginWakeOnLan::executeAction(Device *device, const Action &action)
|
||||||
{
|
{
|
||||||
qDebug() << "execute action " << action.actionTypeId().toString();
|
qDebug() << "execute action " << action.actionTypeId().toString();
|
||||||
|
|||||||
@ -33,12 +33,8 @@ class DevicePluginWakeOnLan : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginWakeOnLan();
|
explicit DevicePluginWakeOnLan();
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
|
||||||
PluginId pluginId() const override;
|
|
||||||
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1 +1,11 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "Wake on Lan",
|
||||||
|
"id": "b5a87848-de56-451e-84a6-edd26ad4958f",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "guh",
|
||||||
|
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6"
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -24,8 +24,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
extern VendorId guhVendorId;
|
|
||||||
PluginId pluginUuid = PluginId("8e0f791e-b273-4267-8605-b7c2f55a68ab");
|
|
||||||
DeviceClassId detectorId = DeviceClassId("bd216356-f1ec-4324-9785-6982d2174e17");
|
DeviceClassId detectorId = DeviceClassId("bd216356-f1ec-4324-9785-6982d2174e17");
|
||||||
StateTypeId inRangeStateTypeId = StateTypeId("cb43e1b5-4f61-4538-bfa2-c33055c542cf");
|
StateTypeId inRangeStateTypeId = StateTypeId("cb43e1b5-4f61-4538-bfa2-c33055c542cf");
|
||||||
|
|
||||||
@ -33,57 +31,39 @@ DevicePluginWifiDetector::DevicePluginWifiDetector()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Vendor> DevicePluginWifiDetector::supportedVendors() const
|
//QList<DeviceClass> DevicePluginWifiDetector::supportedDevices() const
|
||||||
{
|
//{
|
||||||
QList<Vendor> ret;
|
// QList<DeviceClass> ret;
|
||||||
Vendor guh(guhVendorId, "guh");
|
|
||||||
ret.append(guh);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginWifiDetector::supportedDevices() const
|
// DeviceClass deviceClassWifiDetector(pluginId(), supportedVendors().first().id(), detectorId);
|
||||||
{
|
// deviceClassWifiDetector.setName("WiFi Device");
|
||||||
QList<DeviceClass> ret;
|
|
||||||
|
|
||||||
DeviceClass deviceClassWifiDetector(pluginId(), guhVendorId, detectorId);
|
|
||||||
deviceClassWifiDetector.setName("WiFi Device");
|
|
||||||
|
|
||||||
QList<ParamType> detectorParams;
|
// QList<ParamType> detectorParams;
|
||||||
ParamType macParam("mac", QVariant::String);
|
// ParamType macParam("mac", QVariant::String);
|
||||||
detectorParams.append(macParam);
|
// detectorParams.append(macParam);
|
||||||
|
|
||||||
deviceClassWifiDetector.setParamTypes(detectorParams);
|
// deviceClassWifiDetector.setParamTypes(detectorParams);
|
||||||
|
|
||||||
QList<StateType> detectorStates;
|
// QList<StateType> detectorStates;
|
||||||
|
|
||||||
StateType inRangeState(inRangeStateTypeId);
|
// StateType inRangeState(inRangeStateTypeId);
|
||||||
inRangeState.setName("inRange");
|
// inRangeState.setName("inRange");
|
||||||
inRangeState.setType(QVariant::Bool);
|
// inRangeState.setType(QVariant::Bool);
|
||||||
inRangeState.setDefaultValue(false);
|
// inRangeState.setDefaultValue(false);
|
||||||
detectorStates.append(inRangeState);
|
// detectorStates.append(inRangeState);
|
||||||
|
|
||||||
deviceClassWifiDetector.setStateTypes(detectorStates);
|
// deviceClassWifiDetector.setStateTypes(detectorStates);
|
||||||
|
|
||||||
ret.append(deviceClassWifiDetector);
|
// ret.append(deviceClassWifiDetector);
|
||||||
|
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
//}
|
||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginWifiDetector::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginWifiDetector::requiredHardware() const
|
||||||
{
|
{
|
||||||
return DeviceManager::HardwareResourceTimer;
|
return DeviceManager::HardwareResourceTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DevicePluginWifiDetector::pluginName() const
|
|
||||||
{
|
|
||||||
return "WiFi Detector";
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginId DevicePluginWifiDetector::pluginId() const
|
|
||||||
{
|
|
||||||
return pluginUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginWifiDetector::guhTimer()
|
void DevicePluginWifiDetector::guhTimer()
|
||||||
{
|
{
|
||||||
QProcess *p = new QProcess(this);
|
QProcess *p = new QProcess(this);
|
||||||
|
|||||||
@ -33,13 +33,8 @@ class DevicePluginWifiDetector : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginWifiDetector();
|
explicit DevicePluginWifiDetector();
|
||||||
|
|
||||||
QList<Vendor> supportedVendors() const override;
|
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
QString pluginName() const override;
|
|
||||||
PluginId pluginId() const override;
|
|
||||||
|
|
||||||
void guhTimer() override;
|
void guhTimer() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
@ -1 +1,11 @@
|
|||||||
{}
|
{
|
||||||
|
"name": "WiFi Detector",
|
||||||
|
"id": "8e0f791e-b273-4267-8605-b7c2f55a68ab",
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "guh",
|
||||||
|
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6"
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@ -27,8 +27,6 @@
|
|||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
extern PluginId mockPluginId;
|
|
||||||
extern VendorId guhVendorId;
|
|
||||||
extern DeviceClassId mockDeviceClassId;
|
extern DeviceClassId mockDeviceClassId;
|
||||||
extern DeviceClassId mockDeviceAutoClassId;
|
extern DeviceClassId mockDeviceAutoClassId;
|
||||||
extern DeviceClassId mockDeviceDiscoveryClassId;
|
extern DeviceClassId mockDeviceDiscoveryClassId;
|
||||||
@ -63,6 +61,9 @@ protected:
|
|||||||
void restartServer();
|
void restartServer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
|
||||||
|
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
||||||
|
|
||||||
MockTcpServer *m_mockTcpServer;
|
MockTcpServer *m_mockTcpServer;
|
||||||
QUuid m_clientId;
|
QUuid m_clientId;
|
||||||
int m_commandId;
|
int m_commandId;
|
||||||
|
|||||||
Reference in New Issue
Block a user