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 <QPluginLoader>
|
||||
#include <QStaticPlugin>
|
||||
#include <QtPlugin>
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
@ -499,11 +500,11 @@ QPair<DeviceManager::DeviceError, QString> DeviceManager::executeAction(const Ac
|
||||
|
||||
void DeviceManager::loadPlugins()
|
||||
{
|
||||
foreach (QObject *pluginObject, QPluginLoader::staticInstances()) {
|
||||
DevicePlugin *pluginIface = qobject_cast<DevicePlugin*>(pluginObject);
|
||||
if (pluginIface) {
|
||||
foreach (const QStaticPlugin &staticPlugin, QPluginLoader::staticPlugins()) {
|
||||
DevicePlugin *pluginIface = qobject_cast<DevicePlugin*>(staticPlugin.instance());
|
||||
if (verifyPluginMetadata(staticPlugin.metaData().value("MetaData").toObject()) && pluginIface) {
|
||||
pluginIface->initPlugin(staticPlugin.metaData().value("MetaData").toObject(), this);
|
||||
qDebug() << "*** Loaded plugin" << pluginIface->pluginName();
|
||||
pluginIface->initPlugin(this);
|
||||
foreach (const Vendor &vendor, pluginIface->supportedVendors()) {
|
||||
qDebug() << "* Loaded vendor:" << vendor.name();
|
||||
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)
|
||||
{
|
||||
DeviceClass deviceClass = findDeviceClass(device->deviceClassId());
|
||||
|
||||
@ -122,6 +122,7 @@ private slots:
|
||||
void timerEvent();
|
||||
|
||||
private:
|
||||
bool verifyPluginMetadata(const QJsonObject &data);
|
||||
QPair<DeviceError, QString> addConfiguredDeviceInternal(const DeviceClassId &deviceClassId, const ParamList ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
||||
QPair<DeviceSetupStatus, QString> setupDevice(Device *device);
|
||||
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()}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString DevicePlugin::pluginName() const
|
||||
Return the name of the plugin. A String presented to the user.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QUuid DevicePlugin::pluginId() const
|
||||
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 <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QFile>
|
||||
#include <QJsonArray>
|
||||
|
||||
/*! DevicePlugin constructor. DevicePlugins will be instantiated by the DeviceManager, its \a parent. */
|
||||
DevicePlugin::DevicePlugin(QObject *parent):
|
||||
QObject(parent),
|
||||
m_deviceManager(0)
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*! 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.
|
||||
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
|
||||
@ -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.
|
||||
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;
|
||||
init();
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "types/param.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QJsonObject>
|
||||
|
||||
class DeviceManager;
|
||||
class Device;
|
||||
@ -42,11 +43,11 @@ public:
|
||||
|
||||
virtual void init() {}
|
||||
|
||||
virtual QString pluginName() const = 0;
|
||||
virtual PluginId pluginId() const = 0;
|
||||
QString pluginName() const;
|
||||
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 void startMonitoringAutoDevices();
|
||||
@ -93,12 +94,14 @@ protected:
|
||||
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());
|
||||
private:
|
||||
void initPlugin(DeviceManager *deviceManager);
|
||||
void initPlugin(const QJsonObject &metaData, DeviceManager *deviceManager);
|
||||
|
||||
DeviceManager *m_deviceManager;
|
||||
|
||||
ParamList m_config;
|
||||
|
||||
QJsonObject m_metaData;
|
||||
|
||||
friend class DeviceManager;
|
||||
};
|
||||
Q_DECLARE_INTERFACE(DevicePlugin, "guru.guh.DevicePlugin")
|
||||
|
||||
@ -60,7 +60,6 @@
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
VendorId conradVendorId = VendorId("986cf06f-3ef1-4271-b2a3-2cc277ebecb6");
|
||||
DeviceClassId conradRemoteId = DeviceClassId("17cd2492-28ab-4827-ba6e-5ef35be23f1b");
|
||||
EventTypeId conradRemoteButtonEventTypeId = EventTypeId("1f4050f5-4c90-4799-8d6d-e4069f3a2519");
|
||||
ActionTypeId conradRemoteActionTypeId = ActionTypeId("2a3638b4-fbd6-4fdb-a3c9-7fa49705d1a3");
|
||||
@ -68,87 +67,55 @@ DevicePluginConrad::DevicePluginConrad()
|
||||
{
|
||||
}
|
||||
|
||||
QList<Vendor> DevicePluginConrad::supportedVendors() const
|
||||
{
|
||||
QList<Vendor> ret;
|
||||
ret.append(Vendor(conradVendorId, "Conrad Electronic SE"));
|
||||
return ret;
|
||||
}
|
||||
//QList<DeviceClass> DevicePluginConrad::supportedDevices() const
|
||||
//{
|
||||
// // TODO: load list from config with static uuid
|
||||
// QList<DeviceClass> ret;
|
||||
|
||||
QList<DeviceClass> DevicePluginConrad::supportedDevices() const
|
||||
{
|
||||
// TODO: load list from config with static uuid
|
||||
QList<DeviceClass> ret;
|
||||
// // =======================================
|
||||
// // Remote
|
||||
// DeviceClass deviceClassConradRemote(pluginId(), supportedVendors().first().id(), conradRemoteId);
|
||||
// deviceClassConradRemote.setName("Conrad Remote");
|
||||
|
||||
// =======================================
|
||||
// Remote
|
||||
DeviceClass deviceClassConradRemote(pluginId(), conradVendorId, conradRemoteId);
|
||||
deviceClassConradRemote.setName("Conrad Remote");
|
||||
// // Params
|
||||
// QList<ParamType> deviceParamsRemote;
|
||||
|
||||
// Params
|
||||
QList<ParamType> deviceParamsRemote;
|
||||
// QVariantList deviceParamRemote;
|
||||
// QVariantMap nameParam;
|
||||
// nameParam.insert("name", "name");
|
||||
// nameParam.insert("type", "string");
|
||||
// deviceParamRemote.append(nameParam);
|
||||
|
||||
QVariantList deviceParamRemote;
|
||||
QVariantMap nameParam;
|
||||
nameParam.insert("name", "name");
|
||||
nameParam.insert("type", "string");
|
||||
deviceParamRemote.append(nameParam);
|
||||
// // Events
|
||||
// QList<EventType> buttonEvents;
|
||||
|
||||
QList<ParamType> actionParamsRemote;
|
||||
ParamType actionParamRemote("power", QVariant::Bool);
|
||||
actionParamsRemote.append(actionParamRemote);
|
||||
// QList<ParamType> paramsRemote;
|
||||
// ParamType paramButton("button", QVariant::Int);
|
||||
// paramsRemote.append(paramButton);
|
||||
|
||||
// ParamType paramGroup("group", QVariant::Int);
|
||||
// paramsRemote.append(paramGroup);
|
||||
|
||||
// Actions
|
||||
QList<ActionType> remoteActions;
|
||||
// ParamType paramPower("power", QVariant::Bool);
|
||||
// paramsRemote.append(paramPower);
|
||||
|
||||
ActionType powerAction(conradRemoteActionTypeId);
|
||||
powerAction.setName("power");
|
||||
powerAction.setParameters(actionParamsRemote);
|
||||
remoteActions.append(powerAction);
|
||||
// EventType buttonEvent(conradRemoteButtonEventTypeId);
|
||||
// buttonEvent.setName("Button Pressed");
|
||||
// buttonEvent.setParameters(paramsRemote);
|
||||
// buttonEvents.append(buttonEvent);
|
||||
|
||||
deviceClassConradRemote.setActions(remoteActions);
|
||||
// deviceClassConradRemote.setParamTypes(deviceParamsRemote);
|
||||
// deviceClassConradRemote.setEventTypes(buttonEvents);
|
||||
// ret.append(deviceClassConradRemote);
|
||||
|
||||
// Events
|
||||
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;
|
||||
}
|
||||
// return ret;
|
||||
//}
|
||||
|
||||
DeviceManager::HardwareResources DevicePluginConrad::requiredHardware() const
|
||||
{
|
||||
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)
|
||||
{
|
||||
QList<int> rawData;
|
||||
|
||||
@ -31,14 +31,9 @@ class DevicePluginConrad : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginConrad();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
QString pluginName() const override;
|
||||
PluginId pluginId() const override;
|
||||
|
||||
void radioData(const QList<int> &rawData) override;
|
||||
void radioData(QList<int> rawData) override;
|
||||
|
||||
public slots:
|
||||
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> ret;
|
||||
ret.append(Vendor(elroVendorId, "Elro"));
|
||||
return ret;
|
||||
}
|
||||
//QList<Vendor> DevicePluginElro::supportedVendors() const
|
||||
//{
|
||||
// QList<Vendor> ret;
|
||||
// ret.append(Vendor(elroVendorId, "Elro"));
|
||||
// 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
|
||||
{
|
||||
// TODO: load list from config with static uuid
|
||||
QList<DeviceClass> ret;
|
||||
|
||||
// =======================================
|
||||
// Remote
|
||||
DeviceClass deviceClassElroRemote(pluginId(), elroVendorId, elroRemoteId);
|
||||
deviceClassElroRemote.setName("Elro Remote");
|
||||
// // =======================================
|
||||
// // Remote
|
||||
// qDebug() << "have supported vendors" << supportedVendors().count();
|
||||
// DeviceClass deviceClassElroRemote(pluginId(), supportedVendors().first().id(), elroRemoteId);
|
||||
// deviceClassElroRemote.setName("Elro Remote");
|
||||
|
||||
QList<ParamType> deviceParamsRemote;
|
||||
ParamType channelParam = ParamType("channel 1", QVariant::Bool);
|
||||
deviceParamsRemote.append(channelParam);
|
||||
channelParam = ParamType("channel 2", QVariant::Bool);
|
||||
deviceParamsRemote.append(channelParam);
|
||||
channelParam = ParamType("channel 3", QVariant::Bool);
|
||||
deviceParamsRemote.append(channelParam);
|
||||
channelParam = ParamType("channel 4", QVariant::Bool);
|
||||
deviceParamsRemote.append(channelParam);
|
||||
channelParam = ParamType("channel 5", QVariant::Bool);
|
||||
deviceParamsRemote.append(channelParam);
|
||||
// QList<ParamType> deviceParamsRemote;
|
||||
// ParamType channelParam = ParamType("channel1", QVariant::Bool);
|
||||
// deviceParamsRemote.append(channelParam);
|
||||
// channelParam = ParamType("channel2", QVariant::Bool);
|
||||
// deviceParamsRemote.append(channelParam);
|
||||
// channelParam = ParamType("channel3", QVariant::Bool);
|
||||
// deviceParamsRemote.append(channelParam);
|
||||
// channelParam = ParamType("channel4", QVariant::Bool);
|
||||
// deviceParamsRemote.append(channelParam);
|
||||
// channelParam = ParamType("channel5", QVariant::Bool);
|
||||
// deviceParamsRemote.append(channelParam);
|
||||
|
||||
deviceClassElroRemote.setParamTypes(deviceParamsRemote);
|
||||
// deviceClassElroRemote.setParamTypes(deviceParamsRemote);
|
||||
|
||||
QList<EventType> buttonEvents;
|
||||
// QList<EventType> buttonEvents;
|
||||
|
||||
QList<ParamType> paramsRemote;
|
||||
ParamType param("power", QVariant::Bool);
|
||||
paramsRemote.append(param);
|
||||
// QList<ParamType> paramsRemote;
|
||||
// ParamType param("power", QVariant::Bool);
|
||||
// paramsRemote.append(param);
|
||||
|
||||
EventType buttonAEvent(EventTypeId("9dd3f862-35f3-4b69-954e-fa3c8bd68e39"));
|
||||
buttonAEvent.setName("A");
|
||||
buttonAEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonAEvent);
|
||||
// EventType buttonAEvent(EventTypeId("9dd3f862-35f3-4b69-954e-fa3c8bd68e39"));
|
||||
// buttonAEvent.setName("A");
|
||||
// buttonAEvent.setParameters(paramsRemote);
|
||||
// buttonEvents.append(buttonAEvent);
|
||||
|
||||
EventType buttonBEvent(EventTypeId("733226eb-91ba-4e37-9d78-12c87eb5e763"));
|
||||
buttonBEvent.setName("B");
|
||||
buttonBEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonBEvent);
|
||||
// EventType buttonBEvent(EventTypeId("733226eb-91ba-4e37-9d78-12c87eb5e763"));
|
||||
// buttonBEvent.setName("B");
|
||||
// buttonBEvent.setParameters(paramsRemote);
|
||||
// buttonEvents.append(buttonBEvent);
|
||||
|
||||
EventType buttonCEvent(EventTypeId("47aaeaec-485a-4775-a543-33f339fd28c8"));
|
||||
buttonCEvent.setName("C");
|
||||
buttonCEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonCEvent);
|
||||
// EventType buttonCEvent(EventTypeId("47aaeaec-485a-4775-a543-33f339fd28c8"));
|
||||
// buttonCEvent.setName("C");
|
||||
// buttonCEvent.setParameters(paramsRemote);
|
||||
// buttonEvents.append(buttonCEvent);
|
||||
|
||||
EventType buttonDEvent(EventTypeId("db3d484c-add9-44ab-80a4-a0664e0c87c8"));
|
||||
buttonDEvent.setName("D");
|
||||
buttonDEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonDEvent);
|
||||
// EventType buttonDEvent(EventTypeId("db3d484c-add9-44ab-80a4-a0664e0c87c8"));
|
||||
// buttonDEvent.setName("D");
|
||||
// buttonDEvent.setParameters(paramsRemote);
|
||||
// buttonEvents.append(buttonDEvent);
|
||||
|
||||
EventType buttonEEvent(EventTypeId("eb914aac-fb73-4ee2-9f1b-c34b2f6cc24a"));
|
||||
buttonEEvent.setName("E");
|
||||
buttonEEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonEEvent);
|
||||
// EventType buttonEEvent(EventTypeId("eb914aac-fb73-4ee2-9f1b-c34b2f6cc24a"));
|
||||
// buttonEEvent.setName("E");
|
||||
// buttonEEvent.setParameters(paramsRemote);
|
||||
// buttonEvents.append(buttonEEvent);
|
||||
|
||||
deviceClassElroRemote.setEventTypes(buttonEvents);
|
||||
ret.append(deviceClassElroRemote);
|
||||
// deviceClassElroRemote.setEventTypes(buttonEvents);
|
||||
// ret.append(deviceClassElroRemote);
|
||||
|
||||
// =======================================
|
||||
// Motion Detector
|
||||
// // =======================================
|
||||
// // Motion Detector
|
||||
|
||||
DeviceClass deviceClassElroMotionDetector(pluginId(), elroVendorId, elroMotionDetectorId);
|
||||
deviceClassElroMotionDetector.setName("Elro Motion Detector");
|
||||
deviceClassElroMotionDetector.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
||||
// DeviceClass deviceClassElroMotionDetector(pluginId(), supportedVendors().first().id(), elroMotionDetectorId);
|
||||
// deviceClassElroMotionDetector.setName("Elro Motion Detector");
|
||||
// deviceClassElroMotionDetector.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
||||
|
||||
QList<EventType> motionDetectorEvents;
|
||||
QList<ParamType> deviceParamsMotionDetector;
|
||||
// QList<EventType> motionDetectorEvents;
|
||||
// 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;
|
||||
ParamType paramSwitch = ParamType("channel 1", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
paramSwitch = ParamType("channel 2", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
paramSwitch = ParamType("channel 3", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
paramSwitch = ParamType("channel 4", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
paramSwitch = ParamType("channel 5", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
paramSwitch = ParamType("A", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
paramSwitch = ParamType("B", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
paramSwitch = ParamType("C", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
paramSwitch = ParamType("D", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
paramSwitch = ParamType("E", QVariant::Bool);
|
||||
deviceParamsSwitch.append(paramSwitch);
|
||||
// QList<ParamType> deviceParamsSwitch;
|
||||
// ParamType paramSwitch = ParamType("channel1", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
// paramSwitch = ParamType("channel2", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
// paramSwitch = ParamType("channel3", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
// paramSwitch = ParamType("channel4", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
// paramSwitch = ParamType("channel5", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
// paramSwitch = ParamType("A", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
// paramSwitch = ParamType("B", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
// paramSwitch = ParamType("C", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
// paramSwitch = ParamType("D", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
// paramSwitch = ParamType("E", QVariant::Bool);
|
||||
// deviceParamsSwitch.append(paramSwitch);
|
||||
|
||||
deviceClassElroSwitch.setParamTypes(deviceParamsSwitch);
|
||||
// deviceClassElroSwitch.setParamTypes(deviceParamsSwitch);
|
||||
|
||||
|
||||
QList<ParamType> actionParamsSwitch;
|
||||
ParamType actionParamSwitch("power", QVariant::Bool);
|
||||
actionParamsSwitch.append(actionParamSwitch);
|
||||
// QList<ParamType> actionParamsSwitch;
|
||||
// ParamType actionParamSwitch("power", QVariant::Bool);
|
||||
// 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"));
|
||||
powerAction.setName("power");
|
||||
powerAction.setParameters(actionParamsSwitch);
|
||||
switchActions.append(powerAction);
|
||||
|
||||
deviceClassElroSwitch.setActions(switchActions);
|
||||
ret.append(deviceClassElroSwitch);
|
||||
return ret;
|
||||
}
|
||||
// deviceClassElroSwitch.setActions(switchActions);
|
||||
// ret.append(deviceClassElroSwitch);
|
||||
// return ret;
|
||||
//}
|
||||
|
||||
DeviceManager::HardwareResources DevicePluginElro::requiredHardware() const
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
|
||||
@ -31,14 +31,9 @@ class DevicePluginElro : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginElro();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
QString pluginName() const override;
|
||||
PluginId pluginId() const override;
|
||||
|
||||
void radioData(const QList<int> &rawData) override;
|
||||
void radioData(QList<int> rawData) override;
|
||||
|
||||
public slots:
|
||||
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 <QStringList>
|
||||
|
||||
VendorId intertechnoVendorId = VendorId("6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba");
|
||||
DeviceClassId intertechnoRemote = DeviceClassId("ab73ad2f-6594-45a3-9063-8f72d365c5e5");
|
||||
DeviceClassId intertechnoSwitch = DeviceClassId("324219e8-7c53-41b5-b314-c2900cd15252");
|
||||
|
||||
@ -171,179 +170,161 @@ DevicePluginIntertechno::DevicePluginIntertechno()
|
||||
{
|
||||
}
|
||||
|
||||
QList<Vendor> DevicePluginIntertechno::supportedVendors() const
|
||||
{
|
||||
QList<Vendor> ret;
|
||||
Vendor intertechno(intertechnoVendorId, "Intertechno");
|
||||
ret.append(intertechno);
|
||||
return ret;
|
||||
}
|
||||
//QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
||||
//{
|
||||
// QList<DeviceClass> ret;
|
||||
|
||||
QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
||||
{
|
||||
QList<DeviceClass> ret;
|
||||
|
||||
// =======================================
|
||||
// Remote
|
||||
DeviceClass deviceClassIntertechnoRemote(pluginId(), intertechnoVendorId, intertechnoRemote);
|
||||
deviceClassIntertechnoRemote.setName("Intertechno Remote");
|
||||
// // =======================================
|
||||
// // Remote
|
||||
// DeviceClass deviceClassIntertechnoRemote(pluginId(), supportedVendors().first().id(), intertechnoRemote);
|
||||
// deviceClassIntertechnoRemote.setName("Intertechno Remote");
|
||||
|
||||
QList<ParamType> remoteParams;
|
||||
// family code = A-P
|
||||
ParamType familyParam("familyCode", QVariant::String);
|
||||
remoteParams.append(familyParam);
|
||||
// QList<ParamType> remoteParams;
|
||||
// // family code = A-P
|
||||
// ParamType familyParam("familyCode", QVariant::String);
|
||||
// remoteParams.append(familyParam);
|
||||
|
||||
deviceClassIntertechnoRemote.setParamTypes(remoteParams);
|
||||
// deviceClassIntertechnoRemote.setParamTypes(remoteParams);
|
||||
|
||||
QList<EventType> buttonEvents;
|
||||
// QList<EventType> buttonEvents;
|
||||
|
||||
QList<ParamType> paramsRemote;
|
||||
// on = true
|
||||
// off = false
|
||||
ParamType paramRemote("power", QVariant::Bool);
|
||||
paramsRemote.append(paramRemote);
|
||||
// QList<ParamType> paramsRemote;
|
||||
// // on = true
|
||||
// // off = false
|
||||
// ParamType paramRemote("power", QVariant::Bool);
|
||||
// paramsRemote.append(paramRemote);
|
||||
|
||||
/* 1-16
|
||||
* ________________
|
||||
* | I | II|III| IV |
|
||||
* |---|---|---|----|
|
||||
* 1 | 1 | 5 | 9 | 13 |
|
||||
* 2 | 2 | 6 | 10| 14 |
|
||||
* 3 | 3 | 7 | 11| 15 |
|
||||
* 4 | 4 | 8 | 12| 16 |
|
||||
* |___|___|___|____|
|
||||
*/
|
||||
// /* 1-16
|
||||
// * ________________
|
||||
// * | I | II|III| IV |
|
||||
// * |---|---|---|----|
|
||||
// * 1 | 1 | 5 | 9 | 13 |
|
||||
// * 2 | 2 | 6 | 10| 14 |
|
||||
// * 3 | 3 | 7 | 11| 15 |
|
||||
// * 4 | 4 | 8 | 12| 16 |
|
||||
// * |___|___|___|____|
|
||||
// */
|
||||
|
||||
EventType button1Event(EventTypeId("785c1b30-a3f2-4696-af7c-d532acf3d6f7"));
|
||||
button1Event.setName("1");
|
||||
button1Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button1Event);
|
||||
// EventType button1Event(EventTypeId("785c1b30-a3f2-4696-af7c-d532acf3d6f7"));
|
||||
// button1Event.setName("1");
|
||||
// button1Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button1Event);
|
||||
|
||||
EventType button2Event(EventTypeId("1d42c850-7b43-452f-b205-e1aac14eb3ee"));
|
||||
button2Event.setName("2");
|
||||
button2Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button2Event);
|
||||
// EventType button2Event(EventTypeId("1d42c850-7b43-452f-b205-e1aac14eb3ee"));
|
||||
// button2Event.setName("2");
|
||||
// button2Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button2Event);
|
||||
|
||||
EventType button3Event(EventTypeId("77a4780e-2355-4a77-870d-2f675bf986ce"));
|
||||
button3Event.setName("3");
|
||||
button3Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button3Event);
|
||||
// EventType button3Event(EventTypeId("77a4780e-2355-4a77-870d-2f675bf986ce"));
|
||||
// button3Event.setName("3");
|
||||
// button3Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button3Event);
|
||||
|
||||
EventType button4Event(EventTypeId("bd6a8b4b-f946-4f3b-992f-e7cff10187b8"));
|
||||
button4Event.setName("4");
|
||||
button4Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button4Event);
|
||||
// EventType button4Event(EventTypeId("bd6a8b4b-f946-4f3b-992f-e7cff10187b8"));
|
||||
// button4Event.setName("4");
|
||||
// button4Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button4Event);
|
||||
|
||||
EventType button5Event(EventTypeId("0f20782e-0acc-45f1-8c42-5dc5f5b29f1b"));
|
||||
button5Event.setName("5");
|
||||
button5Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button5Event);
|
||||
// EventType button5Event(EventTypeId("0f20782e-0acc-45f1-8c42-5dc5f5b29f1b"));
|
||||
// button5Event.setName("5");
|
||||
// button5Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button5Event);
|
||||
|
||||
EventType button6Event(EventTypeId("f7cb439a-0528-4905-9583-06b6bfeb3ba1"));
|
||||
button6Event.setName("6");
|
||||
button6Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button6Event);
|
||||
// EventType button6Event(EventTypeId("f7cb439a-0528-4905-9583-06b6bfeb3ba1"));
|
||||
// button6Event.setName("6");
|
||||
// button6Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button6Event);
|
||||
|
||||
EventType button7Event(EventTypeId("a0b0d8d8-2b43-4897-98e0-05b6b408a950"));
|
||||
button7Event.setName("7");
|
||||
button7Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button7Event);
|
||||
// EventType button7Event(EventTypeId("a0b0d8d8-2b43-4897-98e0-05b6b408a950"));
|
||||
// button7Event.setName("7");
|
||||
// button7Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button7Event);
|
||||
|
||||
EventType button8Event(EventTypeId("ae5833a2-bc43-4462-ae47-e45dac1fb0ce"));
|
||||
button8Event.setName("8");
|
||||
button8Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button8Event);
|
||||
// EventType button8Event(EventTypeId("ae5833a2-bc43-4462-ae47-e45dac1fb0ce"));
|
||||
// button8Event.setName("8");
|
||||
// button8Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button8Event);
|
||||
|
||||
EventType button9Event(EventTypeId("52c13828-d047-4256-b488-0bf84abbc87c"));
|
||||
button9Event.setName("9");
|
||||
button9Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button9Event);
|
||||
// EventType button9Event(EventTypeId("52c13828-d047-4256-b488-0bf84abbc87c"));
|
||||
// button9Event.setName("9");
|
||||
// button9Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button9Event);
|
||||
|
||||
EventType button10Event(EventTypeId("22c5afbc-835e-47cc-8211-4429eb9d9fee"));
|
||||
button10Event.setName("10");
|
||||
button10Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button10Event);
|
||||
// EventType button10Event(EventTypeId("22c5afbc-835e-47cc-8211-4429eb9d9fee"));
|
||||
// button10Event.setName("10");
|
||||
// button10Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button10Event);
|
||||
|
||||
EventType button11Event(EventTypeId("6bec5cbc-8bfb-4c6c-8ac8-f8e7723fd5aa"));
|
||||
button11Event.setName("11");
|
||||
button11Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button11Event);
|
||||
// EventType button11Event(EventTypeId("6bec5cbc-8bfb-4c6c-8ac8-f8e7723fd5aa"));
|
||||
// button11Event.setName("11");
|
||||
// button11Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button11Event);
|
||||
|
||||
EventType button12Event(EventTypeId("8b71edd2-8135-4c8b-bf44-380efadf1942"));
|
||||
button12Event.setName("12");
|
||||
button12Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button12Event);
|
||||
// EventType button12Event(EventTypeId("8b71edd2-8135-4c8b-bf44-380efadf1942"));
|
||||
// button12Event.setName("12");
|
||||
// button12Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button12Event);
|
||||
|
||||
EventType button13Event(EventTypeId("192f36a4-1e58-41aa-9618-83d46e329a4b"));
|
||||
button13Event.setName("13");
|
||||
button13Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button13Event);
|
||||
// EventType button13Event(EventTypeId("192f36a4-1e58-41aa-9618-83d46e329a4b"));
|
||||
// button13Event.setName("13");
|
||||
// button13Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button13Event);
|
||||
|
||||
EventType button14Event(EventTypeId("6c76de60-5e19-4a29-b027-e71e66caa2d6"));
|
||||
button14Event.setName("14");
|
||||
button14Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button14Event);
|
||||
// EventType button14Event(EventTypeId("6c76de60-5e19-4a29-b027-e71e66caa2d6"));
|
||||
// button14Event.setName("14");
|
||||
// button14Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button14Event);
|
||||
|
||||
EventType button15Event(EventTypeId("c2f56c10-1f81-4477-88fa-fc0f4a6383df"));
|
||||
button15Event.setName("15");
|
||||
button15Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button15Event);
|
||||
// EventType button15Event(EventTypeId("c2f56c10-1f81-4477-88fa-fc0f4a6383df"));
|
||||
// button15Event.setName("15");
|
||||
// button15Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button15Event);
|
||||
|
||||
EventType button16Event(EventTypeId("5d2eb3f8-4cd4-4c71-9c0c-e0b685e168e4"));
|
||||
button16Event.setName("16");
|
||||
button16Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button16Event);
|
||||
// EventType button16Event(EventTypeId("5d2eb3f8-4cd4-4c71-9c0c-e0b685e168e4"));
|
||||
// button16Event.setName("16");
|
||||
// button16Event.setParameters(paramsRemote);
|
||||
// buttonEvents.append(button16Event);
|
||||
|
||||
deviceClassIntertechnoRemote.setEventTypes(buttonEvents);
|
||||
ret.append(deviceClassIntertechnoRemote);
|
||||
// deviceClassIntertechnoRemote.setEventTypes(buttonEvents);
|
||||
// ret.append(deviceClassIntertechnoRemote);
|
||||
|
||||
|
||||
// =======================================
|
||||
// Switch
|
||||
DeviceClass deviceClassIntertechnoSwitch(pluginId(), intertechnoVendorId, intertechnoSwitch);
|
||||
deviceClassIntertechnoSwitch.setName("Intertechno Switch");
|
||||
// // =======================================
|
||||
// // Switch
|
||||
// DeviceClass deviceClassIntertechnoSwitch(pluginId(), supportedVendors().last().id(), intertechnoSwitch);
|
||||
// deviceClassIntertechnoSwitch.setName("Intertechno Switch");
|
||||
|
||||
QList<ParamType> switchDeviceParams;
|
||||
// button code = 1-16
|
||||
ParamType buttonParam("buttonCode", QVariant::Int);
|
||||
// QList<ParamType> switchDeviceParams;
|
||||
// // button code = 1-16
|
||||
// ParamType buttonParam("buttonCode", QVariant::Int);
|
||||
|
||||
switchDeviceParams.append(familyParam);
|
||||
switchDeviceParams.append(buttonParam);
|
||||
// switchDeviceParams.append(familyParam);
|
||||
// switchDeviceParams.append(buttonParam);
|
||||
|
||||
deviceClassIntertechnoSwitch.setParamTypes(switchDeviceParams);
|
||||
// deviceClassIntertechnoSwitch.setParamTypes(switchDeviceParams);
|
||||
|
||||
QList<ActionType> switchActions;
|
||||
// QList<ActionType> switchActions;
|
||||
|
||||
QList<ParamType> paramsSwitch;
|
||||
ParamType paramSwitch("power", QVariant::Bool);
|
||||
paramsSwitch.append(paramSwitch);
|
||||
// QList<ParamType> paramsSwitch;
|
||||
// ParamType paramSwitch("power", QVariant::Bool);
|
||||
// paramsSwitch.append(paramSwitch);
|
||||
|
||||
ActionType switchActionPower(ActionTypeId("df19fb51-c3cd-4b95-8d88-ebbb535f4789"));
|
||||
switchActionPower.setName("power");
|
||||
switchActionPower.setParameters(paramsSwitch);
|
||||
switchActions.append(switchActionPower);
|
||||
// ActionType switchActionPower(ActionTypeId("df19fb51-c3cd-4b95-8d88-ebbb535f4789"));
|
||||
// switchActionPower.setName("power");
|
||||
// switchActionPower.setParameters(paramsSwitch);
|
||||
// switchActions.append(switchActionPower);
|
||||
|
||||
deviceClassIntertechnoSwitch.setActions(switchActions);
|
||||
ret.append(deviceClassIntertechnoSwitch);
|
||||
// deviceClassIntertechnoSwitch.setActions(switchActions);
|
||||
// ret.append(deviceClassIntertechnoSwitch);
|
||||
|
||||
return ret;
|
||||
}
|
||||
// return ret;
|
||||
//}
|
||||
|
||||
DeviceManager::HardwareResources DevicePluginIntertechno::requiredHardware() const
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
|
||||
@ -31,14 +31,9 @@ class DevicePluginIntertechno : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginIntertechno();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
QString pluginName() const override;
|
||||
PluginId pluginId() const override;
|
||||
|
||||
void radioData(const QList<int> &rawData) override;
|
||||
void radioData(QList<int> rawData) override;
|
||||
|
||||
public slots:
|
||||
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 <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");
|
||||
EventTypeId LircKeypressEventTypeId = EventTypeId("8711471a-fa0e-410b-b174-dfc3d2aeffb1");
|
||||
|
||||
@ -40,77 +37,59 @@ DevicePluginLircd::DevicePluginLircd()
|
||||
connect(m_lircClient, &LircClient::buttonPressed, this, &DevicePluginLircd::buttonPressed);
|
||||
}
|
||||
|
||||
QList<Vendor> DevicePluginLircd::supportedVendors() const
|
||||
{
|
||||
QList<Vendor> ret;
|
||||
Vendor guh(lircdVendorId, "Lircd");
|
||||
ret.append(guh);
|
||||
return ret;
|
||||
}
|
||||
//QList<DeviceClass> DevicePluginLircd::supportedDevices() const
|
||||
//{
|
||||
// QList<DeviceClass> ret;
|
||||
|
||||
QList<DeviceClass> DevicePluginLircd::supportedDevices() const
|
||||
{
|
||||
QList<DeviceClass> ret;
|
||||
// DeviceClass deviceClassLircd(pluginId(), supportedVendors().first().id(), lircdDeviceClassId);
|
||||
// deviceClassLircd.setName("IR Receiver");
|
||||
|
||||
DeviceClass deviceClassLircd(pluginId(), lircdVendorId, lircdDeviceClassId);
|
||||
deviceClassLircd.setName("IR Receiver");
|
||||
|
||||
QList<ParamType> params;
|
||||
ParamType remoteNameParam("remoteName", QVariant::String);
|
||||
params.append(remoteNameParam);
|
||||
deviceClassLircd.setParamTypes(params);
|
||||
// QList<ParamType> 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!
|
||||
// Ideally that file can be generated from /usr/share/lirc/remotes/*
|
||||
// Note that the IDs need to be kept static!
|
||||
QList<ParamType> repeatParam;
|
||||
ParamType repeatParamMap("repeat", QVariant::Int);
|
||||
repeatParam.append(repeatParamMap);
|
||||
// // TODO: find a way to load this stuff from a json file, really!
|
||||
// // Ideally that file can be generated from /usr/share/lirc/remotes/*
|
||||
// // Note that the IDs need to be kept static!
|
||||
// QList<ParamType> repeatParam;
|
||||
// ParamType repeatParamMap("repeat", QVariant::Int);
|
||||
// repeatParam.append(repeatParamMap);
|
||||
|
||||
QList<EventType> events;
|
||||
EventType powerButton(EventTypeId("d62d779f-e5c6-4767-98e6-efe9c062b662"));
|
||||
powerButton.setName("Power");
|
||||
powerButton.setParameters(repeatParam);
|
||||
events.append(powerButton);
|
||||
EventType yellowButton(EventTypeId("3313f62e-ea20-47f5-85af-28897d6ac440"));
|
||||
yellowButton.setName("Yellow");
|
||||
yellowButton.setParameters(repeatParam);
|
||||
events.append(yellowButton);
|
||||
EventType blueButton(EventTypeId("9a395d93-e482-4fa2-b4bc-e60bb4bf8652"));
|
||||
blueButton.setName("Blue");
|
||||
blueButton.setParameters(repeatParam);
|
||||
events.append(blueButton);
|
||||
EventType greenButton(EventTypeId("e8aaf18e-dc11-40da-980d-4eec42c58267"));
|
||||
greenButton.setName("Green");
|
||||
greenButton.setParameters(repeatParam);
|
||||
events.append(greenButton);
|
||||
EventType redButton(EventTypeId("b8518755-55a0-4cd4-8856-1680848edcb7"));
|
||||
redButton.setName("Red");
|
||||
redButton.setParameters(repeatParam);
|
||||
events.append(redButton);
|
||||
// QList<EventType> events;
|
||||
// EventType powerButton(EventTypeId("d62d779f-e5c6-4767-98e6-efe9c062b662"));
|
||||
// powerButton.setName("Power");
|
||||
// powerButton.setParameters(repeatParam);
|
||||
// events.append(powerButton);
|
||||
// EventType yellowButton(EventTypeId("3313f62e-ea20-47f5-85af-28897d6ac440"));
|
||||
// yellowButton.setName("Yellow");
|
||||
// yellowButton.setParameters(repeatParam);
|
||||
// events.append(yellowButton);
|
||||
// EventType blueButton(EventTypeId("9a395d93-e482-4fa2-b4bc-e60bb4bf8652"));
|
||||
// blueButton.setName("Blue");
|
||||
// blueButton.setParameters(repeatParam);
|
||||
// events.append(blueButton);
|
||||
// EventType greenButton(EventTypeId("e8aaf18e-dc11-40da-980d-4eec42c58267"));
|
||||
// greenButton.setName("Green");
|
||||
// greenButton.setParameters(repeatParam);
|
||||
// events.append(greenButton);
|
||||
// EventType redButton(EventTypeId("b8518755-55a0-4cd4-8856-1680848edcb7"));
|
||||
// redButton.setName("Red");
|
||||
// redButton.setParameters(repeatParam);
|
||||
// events.append(redButton);
|
||||
|
||||
deviceClassLircd.setEventTypes(events);
|
||||
// deviceClassLircd.setEventTypes(events);
|
||||
|
||||
ret.append(deviceClassLircd);
|
||||
// ret.append(deviceClassLircd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
// return ret;
|
||||
//}
|
||||
|
||||
DeviceManager::HardwareResources DevicePluginLircd::requiredHardware() const
|
||||
{
|
||||
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)
|
||||
{
|
||||
Device *remote = nullptr;
|
||||
|
||||
@ -35,13 +35,8 @@ class DevicePluginLircd: public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginLircd();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
QString pluginName() const override;
|
||||
PluginId pluginId() const override;
|
||||
|
||||
// QVariantMap configuration() const 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 <QDateTime>
|
||||
|
||||
extern VendorId guhVendorId;
|
||||
|
||||
DeviceClassId googleMailDeviceClassId = DeviceClassId("3869884a-1592-4b8f-84a7-994be18ff555");
|
||||
DeviceClassId customMailDeviceClassId = DeviceClassId("f4844c97-7ca6-4349-904e-ff9749a9fe74");
|
||||
|
||||
@ -247,91 +245,83 @@ DevicePluginMailNotification::~DevicePluginMailNotification()
|
||||
m_smtpClient->deleteLater();
|
||||
}
|
||||
|
||||
QList<Vendor> DevicePluginMailNotification::supportedVendors() const
|
||||
{
|
||||
QList<Vendor> ret;
|
||||
Vendor mail(guhVendorId, "guh");
|
||||
ret.append(mail);
|
||||
return ret;
|
||||
}
|
||||
//QList<DeviceClass> DevicePluginMailNotification::supportedDevices() const
|
||||
//{
|
||||
// QList<DeviceClass> ret;
|
||||
|
||||
QList<DeviceClass> DevicePluginMailNotification::supportedDevices() const
|
||||
{
|
||||
QList<DeviceClass> ret;
|
||||
// // General Action
|
||||
// QList<ActionType> mailActions;
|
||||
|
||||
// General Action
|
||||
QList<ActionType> mailActions;
|
||||
// QList<ParamType> actionParamsMail;
|
||||
// ParamType actionParamSubject("subject", QVariant::String);
|
||||
// actionParamsMail.append(actionParamSubject);
|
||||
|
||||
QList<ParamType> actionParamsMail;
|
||||
ParamType actionParamSubject("subject", QVariant::String);
|
||||
actionParamsMail.append(actionParamSubject);
|
||||
// ParamType actionParamBody("body", QVariant::String);
|
||||
// actionParamsMail.append(actionParamBody);
|
||||
|
||||
ParamType actionParamBody("body", QVariant::String);
|
||||
actionParamsMail.append(actionParamBody);
|
||||
|
||||
ActionType sendMailAction(sendMailActionTypeId);
|
||||
sendMailAction.setName("send mail");
|
||||
sendMailAction.setParameters(actionParamsMail);
|
||||
mailActions.append(sendMailAction);
|
||||
// ActionType sendMailAction(sendMailActionTypeId);
|
||||
// sendMailAction.setName("send mail");
|
||||
// sendMailAction.setParameters(actionParamsMail);
|
||||
// mailActions.append(sendMailAction);
|
||||
|
||||
|
||||
|
||||
// Google Mail
|
||||
// ---------------------------------------------------------------
|
||||
DeviceClass deviceClassGoogleMail(pluginId(), guhVendorId, googleMailDeviceClassId);
|
||||
deviceClassGoogleMail.setName("Google Mail Notification");
|
||||
deviceClassGoogleMail.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
// // Google Mail
|
||||
// // ---------------------------------------------------------------
|
||||
// DeviceClass deviceClassGoogleMail(pluginId(), supportedVendors().first().id(), googleMailDeviceClassId);
|
||||
// deviceClassGoogleMail.setName("Google Mail Notification");
|
||||
// deviceClassGoogleMail.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
|
||||
// Params
|
||||
QList<ParamType> googleMailParams;
|
||||
// // Params
|
||||
// QList<ParamType> googleMailParams;
|
||||
|
||||
ParamType userGoogleParam("user", QVariant::String);
|
||||
googleMailParams.append(userGoogleParam);
|
||||
// ParamType userGoogleParam("user", QVariant::String);
|
||||
// googleMailParams.append(userGoogleParam);
|
||||
|
||||
ParamType passwordGoogleParam("password", QVariant::String);
|
||||
googleMailParams.append(passwordGoogleParam);
|
||||
// ParamType passwordGoogleParam("password", QVariant::String);
|
||||
// googleMailParams.append(passwordGoogleParam);
|
||||
|
||||
ParamType recipientGoogleParam("recipient", QVariant::String);
|
||||
googleMailParams.append(recipientGoogleParam);
|
||||
// ParamType recipientGoogleParam("recipient", QVariant::String);
|
||||
// googleMailParams.append(recipientGoogleParam);
|
||||
|
||||
deviceClassGoogleMail.setActions(mailActions);
|
||||
deviceClassGoogleMail.setParamTypes(googleMailParams);
|
||||
// deviceClassGoogleMail.setActions(mailActions);
|
||||
// deviceClassGoogleMail.setParamTypes(googleMailParams);
|
||||
|
||||
// Custom Mail
|
||||
// ---------------------------------------------------------------
|
||||
DeviceClass deviceClassCustomMail(pluginId(), guhVendorId, customMailDeviceClassId);
|
||||
deviceClassCustomMail.setName("Custom Mail Notification");
|
||||
deviceClassCustomMail.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
// // Custom Mail
|
||||
// // ---------------------------------------------------------------
|
||||
// DeviceClass deviceClassCustomMail(pluginId(), supportedVendors().first().id(), customMailDeviceClassId);
|
||||
// deviceClassCustomMail.setName("Custom Mail Notification");
|
||||
// deviceClassCustomMail.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
|
||||
// Params
|
||||
QList<ParamType> customMailParams;
|
||||
// // Params
|
||||
// QList<ParamType> customMailParams;
|
||||
|
||||
ParamType userCustomParam("user", QVariant::String);
|
||||
customMailParams.append(userCustomParam);
|
||||
// ParamType userCustomParam("user", QVariant::String);
|
||||
// customMailParams.append(userCustomParam);
|
||||
|
||||
ParamType passwordCustomParam("password", QVariant::String);
|
||||
customMailParams.append(passwordCustomParam);
|
||||
// ParamType passwordCustomParam("password", QVariant::String);
|
||||
// customMailParams.append(passwordCustomParam);
|
||||
|
||||
ParamType recipientCustomParam("recipient", QVariant::String);
|
||||
customMailParams.append(recipientCustomParam);
|
||||
// ParamType recipientCustomParam("recipient", QVariant::String);
|
||||
// customMailParams.append(recipientCustomParam);
|
||||
|
||||
ParamType hostCustomParam("host", QVariant::String);
|
||||
customMailParams.append(hostCustomParam);
|
||||
// ParamType hostCustomParam("host", QVariant::String);
|
||||
// customMailParams.append(hostCustomParam);
|
||||
|
||||
ParamType portCustomParam("port", QVariant::Int);
|
||||
customMailParams.append(portCustomParam);
|
||||
// ParamType portCustomParam("port", QVariant::Int);
|
||||
// customMailParams.append(portCustomParam);
|
||||
|
||||
ParamType authCustomParam("auth", QVariant::String);
|
||||
authCustomParam.setAllowedValues(QVariantList() << "PLAIN" << "LOGIN");
|
||||
customMailParams.append(authCustomParam);
|
||||
// ParamType authCustomParam("auth", QVariant::String);
|
||||
// authCustomParam.setAllowedValues(QVariantList() << "PLAIN" << "LOGIN");
|
||||
// customMailParams.append(authCustomParam);
|
||||
|
||||
deviceClassCustomMail.setActions(mailActions);
|
||||
deviceClassCustomMail.setParamTypes(customMailParams);
|
||||
// deviceClassCustomMail.setActions(mailActions);
|
||||
// deviceClassCustomMail.setParamTypes(customMailParams);
|
||||
|
||||
ret.append(deviceClassGoogleMail);
|
||||
ret.append(deviceClassCustomMail);
|
||||
return ret;
|
||||
}
|
||||
// ret.append(deviceClassGoogleMail);
|
||||
// ret.append(deviceClassCustomMail);
|
||||
// return ret;
|
||||
//}
|
||||
|
||||
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginMailNotification::setupDevice(Device *device)
|
||||
{
|
||||
@ -384,14 +374,3 @@ QPair<DeviceManager::DeviceError, QString> DevicePluginMailNotification::execute
|
||||
|
||||
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();
|
||||
~DevicePluginMailNotification();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
|
||||
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
||||
|
||||
QString pluginName() const override;
|
||||
PluginId pluginId() const override;
|
||||
|
||||
private:
|
||||
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 <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 mockDeviceAutoClassId = DeviceClassId("ab4257b3-7548-47ee-9bd4-7dc3004fd197");
|
||||
DeviceClassId mockDeviceDiscoveryClassId = DeviceClassId("1bbaf751-36b7-4d3d-b05a-58dab2a3be8c");
|
||||
@ -51,161 +49,153 @@ DevicePluginMock::~DevicePluginMock()
|
||||
{
|
||||
}
|
||||
|
||||
QList<Vendor> DevicePluginMock::supportedVendors() const
|
||||
{
|
||||
QList<Vendor> ret;
|
||||
Vendor guh(guhVendorId, "guh");
|
||||
ret.append(guh);
|
||||
return ret;
|
||||
}
|
||||
//QList<DeviceClass> DevicePluginMock::supportedDevices() const
|
||||
//{
|
||||
// QList<DeviceClass> ret;
|
||||
|
||||
QList<DeviceClass> DevicePluginMock::supportedDevices() const
|
||||
{
|
||||
QList<DeviceClass> ret;
|
||||
// DeviceClass deviceClassMock(pluginId(), supportedVendors().first().id(), mockDeviceClassId);
|
||||
// deviceClassMock.setName("Mock Device");
|
||||
|
||||
DeviceClass deviceClassMock(pluginId(), guhVendorId, mockDeviceClassId);
|
||||
deviceClassMock.setName("Mock Device");
|
||||
// QList<ParamType> mockParams;
|
||||
// ParamType portParam("httpport", QVariant::Int);
|
||||
// mockParams.append(portParam);
|
||||
|
||||
QList<ParamType> mockParams;
|
||||
ParamType portParam("httpport", QVariant::Int);
|
||||
mockParams.append(portParam);
|
||||
// deviceClassMock.setParamTypes(mockParams);
|
||||
|
||||
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);
|
||||
intState.setName("Dummy int state");
|
||||
intState.setType(QVariant::Int);
|
||||
intState.setDefaultValue(10);
|
||||
mockStates.append(intState);
|
||||
// StateType boolState(mockBoolStateId);
|
||||
// boolState.setName("Dummy bool state");
|
||||
// boolState.setType(QVariant::Int);
|
||||
// boolState.setDefaultValue(false);
|
||||
// mockStates.append(boolState);
|
||||
|
||||
StateType boolState(mockBoolStateId);
|
||||
boolState.setName("Dummy bool state");
|
||||
boolState.setType(QVariant::Int);
|
||||
boolState.setDefaultValue(false);
|
||||
mockStates.append(boolState);
|
||||
// deviceClassMock.setStateTypes(mockStates);
|
||||
|
||||
deviceClassMock.setStateTypes(mockStates);
|
||||
|
||||
QList<EventType> mockEvents;
|
||||
// QList<EventType> mockEvents;
|
||||
|
||||
EventType event1(mockEvent1Id);
|
||||
event1.setName("Mock Event 1");
|
||||
mockEvents.append(event1);
|
||||
// EventType event1(mockEvent1Id);
|
||||
// event1.setName("Mock Event 1");
|
||||
// mockEvents.append(event1);
|
||||
|
||||
EventType event2(mockEvent2Id);
|
||||
event2.setName("Mock Event 2");
|
||||
QList<ParamType> event2ParamTypes;
|
||||
ParamType event2Param1Type("mockParamInt", QVariant::Int, 42);
|
||||
event2ParamTypes.append(event2Param1Type);
|
||||
event2.setParameters(event2ParamTypes);
|
||||
mockEvents.append(event2);
|
||||
// EventType event2(mockEvent2Id);
|
||||
// event2.setName("Mock Event 2");
|
||||
// QList<ParamType> event2ParamTypes;
|
||||
// ParamType event2Param1Type("mockParamInt", QVariant::Int, 42);
|
||||
// event2ParamTypes.append(event2Param1Type);
|
||||
// event2.setParameters(event2ParamTypes);
|
||||
// mockEvents.append(event2);
|
||||
|
||||
deviceClassMock.setEventTypes(mockEvents);
|
||||
// deviceClassMock.setEventTypes(mockEvents);
|
||||
|
||||
QList<ActionType> mockActions;
|
||||
// QList<ActionType> mockActions;
|
||||
|
||||
mockParams.clear();
|
||||
ActionType action1(mockActionIdWithParams);
|
||||
action1.setName("Mock Action 1 (with params)");
|
||||
ParamType mockActionParam1("mockActionParam1", QVariant::Int);
|
||||
mockParams.append(mockActionParam1);
|
||||
ParamType mockActionParam2("mockActionParam2", QVariant::Bool);
|
||||
mockParams.append(mockActionParam2);
|
||||
action1.setParameters(mockParams);
|
||||
mockActions.append(action1);
|
||||
// mockParams.clear();
|
||||
// ActionType action1(mockActionIdWithParams);
|
||||
// action1.setName("Mock Action 1 (with params)");
|
||||
// ParamType mockActionParam1("mockActionParam1", QVariant::Int);
|
||||
// mockParams.append(mockActionParam1);
|
||||
// ParamType mockActionParam2("mockActionParam2", QVariant::Bool);
|
||||
// mockParams.append(mockActionParam2);
|
||||
// action1.setParameters(mockParams);
|
||||
// mockActions.append(action1);
|
||||
|
||||
ActionType action2(mockActionIdNoParams);
|
||||
action2.setName("Mock Action 3 (without params)");
|
||||
mockActions.append(action2);
|
||||
// ActionType action2(mockActionIdNoParams);
|
||||
// action2.setName("Mock Action 3 (without params)");
|
||||
// mockActions.append(action2);
|
||||
|
||||
ActionType action3(mockActionIdAsync);
|
||||
action3.setName("Mock Action 3 (async)");
|
||||
mockActions.append(action3);
|
||||
// ActionType action3(mockActionIdAsync);
|
||||
// action3.setName("Mock Action 3 (async)");
|
||||
// mockActions.append(action3);
|
||||
|
||||
ActionType action4(mockActionIdFailing);
|
||||
action4.setName("Mock Action 4 (broken)");
|
||||
mockActions.append(action4);
|
||||
// ActionType action4(mockActionIdFailing);
|
||||
// action4.setName("Mock Action 4 (broken)");
|
||||
// mockActions.append(action4);
|
||||
|
||||
ActionType action5(mockActionIdAsyncFailing);
|
||||
action5.setName("Mock Action 5 (async, broken)");
|
||||
mockActions.append(action4);
|
||||
// ActionType action5(mockActionIdAsyncFailing);
|
||||
// action5.setName("Mock Action 5 (async, broken)");
|
||||
// mockActions.append(action4);
|
||||
|
||||
deviceClassMock.setActions(mockActions);
|
||||
// deviceClassMock.setActions(mockActions);
|
||||
|
||||
ret.append(deviceClassMock);
|
||||
// ret.append(deviceClassMock);
|
||||
|
||||
// Auto created mock device
|
||||
DeviceClass deviceClassMockAuto(pluginId(), guhVendorId, mockDeviceAutoClassId);
|
||||
deviceClassMockAuto.setName("Mock Device (Auto created)");
|
||||
deviceClassMockAuto.setCreateMethod(DeviceClass::CreateMethodAuto);
|
||||
// // Auto created mock device
|
||||
// DeviceClass deviceClassMockAuto(pluginId(), supportedVendors().first().id(), mockDeviceAutoClassId);
|
||||
// deviceClassMockAuto.setName("Mock Device (Auto created)");
|
||||
// deviceClassMockAuto.setCreateMethod(DeviceClass::CreateMethodAuto);
|
||||
|
||||
mockParams.clear();
|
||||
deviceClassMockAuto.setParamTypes(mockParams);
|
||||
deviceClassMockAuto.setStateTypes(mockStates);
|
||||
deviceClassMockAuto.setEventTypes(mockEvents);
|
||||
deviceClassMockAuto.setActions(mockActions);
|
||||
// mockParams.clear();
|
||||
// deviceClassMockAuto.setParamTypes(mockParams);
|
||||
// deviceClassMockAuto.setStateTypes(mockStates);
|
||||
// deviceClassMockAuto.setEventTypes(mockEvents);
|
||||
// deviceClassMockAuto.setActions(mockActions);
|
||||
|
||||
ret.append(deviceClassMockAuto);
|
||||
// ret.append(deviceClassMockAuto);
|
||||
|
||||
// Discovery created device
|
||||
DeviceClass deviceClassMockDiscovery(pluginId(), guhVendorId, mockDeviceDiscoveryClassId);
|
||||
deviceClassMockDiscovery.setName("Mock Device (Discovery created)");
|
||||
deviceClassMockDiscovery.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
||||
QList<ParamType> paramTypes;
|
||||
ParamType paramType = ParamType("resultCount", QVariant::Int, 2);
|
||||
paramType.setAllowedValues(QList<QVariant>() << 1 << 2);
|
||||
paramTypes.append(paramType);
|
||||
deviceClassMockDiscovery.setDiscoveryParamTypes(paramTypes);
|
||||
// // Discovery created device
|
||||
// DeviceClass deviceClassMockDiscovery(pluginId(), supportedVendors().first().id(), mockDeviceDiscoveryClassId);
|
||||
// deviceClassMockDiscovery.setName("Mock Device (Discovery created)");
|
||||
// deviceClassMockDiscovery.setCreateMethod(DeviceClass::CreateMethodDiscovery);
|
||||
// QList<ParamType> paramTypes;
|
||||
// ParamType paramType = ParamType("resultCount", QVariant::Int, 2);
|
||||
// paramType.setAllowedValues(QList<QVariant>() << 1 << 2);
|
||||
// paramTypes.append(paramType);
|
||||
// deviceClassMockDiscovery.setDiscoveryParamTypes(paramTypes);
|
||||
|
||||
mockParams.clear();
|
||||
mockParams.append(portParam);
|
||||
deviceClassMockDiscovery.setParamTypes(mockParams);
|
||||
deviceClassMockDiscovery.setStateTypes(mockStates);
|
||||
deviceClassMockDiscovery.setEventTypes(mockEvents);
|
||||
deviceClassMockDiscovery.setActions(mockActions);
|
||||
// mockParams.clear();
|
||||
// mockParams.append(portParam);
|
||||
// deviceClassMockDiscovery.setParamTypes(mockParams);
|
||||
// deviceClassMockDiscovery.setStateTypes(mockStates);
|
||||
// deviceClassMockDiscovery.setEventTypes(mockEvents);
|
||||
// deviceClassMockDiscovery.setActions(mockActions);
|
||||
|
||||
ret.append(deviceClassMockDiscovery);
|
||||
// ret.append(deviceClassMockDiscovery);
|
||||
|
||||
// Async setup device
|
||||
DeviceClass deviceClassMockAsync(pluginId(), guhVendorId, mockDeviceAsyncSetupClassId);
|
||||
deviceClassMockAsync.setName("Mock Device (Async)");
|
||||
deviceClassMockAsync.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
// // Async setup device
|
||||
// DeviceClass deviceClassMockAsync(pluginId(), supportedVendors().first().id(), mockDeviceAsyncSetupClassId);
|
||||
// deviceClassMockAsync.setName("Mock Device (Async)");
|
||||
// deviceClassMockAsync.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
|
||||
deviceClassMockAsync.setParamTypes(mockParams);
|
||||
deviceClassMockAsync.setStateTypes(mockStates);
|
||||
deviceClassMockAsync.setEventTypes(mockEvents);
|
||||
deviceClassMockAsync.setActions(mockActions);
|
||||
// deviceClassMockAsync.setParamTypes(mockParams);
|
||||
// deviceClassMockAsync.setStateTypes(mockStates);
|
||||
// deviceClassMockAsync.setEventTypes(mockEvents);
|
||||
// deviceClassMockAsync.setActions(mockActions);
|
||||
|
||||
ret.append(deviceClassMockAsync);
|
||||
// ret.append(deviceClassMockAsync);
|
||||
|
||||
// Async setup device
|
||||
DeviceClass deviceClassMockBroken(pluginId(), guhVendorId, mockDeviceBrokenClassId);
|
||||
deviceClassMockBroken.setName("Mock Device (Broken setup)");
|
||||
deviceClassMockBroken.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
// // Async setup device
|
||||
// DeviceClass deviceClassMockBroken(pluginId(), supportedVendors().first().id(), mockDeviceBrokenClassId);
|
||||
// deviceClassMockBroken.setName("Mock Device (Broken setup)");
|
||||
// deviceClassMockBroken.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
|
||||
deviceClassMockBroken.setParamTypes(mockParams);
|
||||
deviceClassMockBroken.setStateTypes(mockStates);
|
||||
deviceClassMockBroken.setEventTypes(mockEvents);
|
||||
deviceClassMockBroken.setActions(mockActions);
|
||||
// deviceClassMockBroken.setParamTypes(mockParams);
|
||||
// deviceClassMockBroken.setStateTypes(mockStates);
|
||||
// deviceClassMockBroken.setEventTypes(mockEvents);
|
||||
// deviceClassMockBroken.setActions(mockActions);
|
||||
|
||||
ret.append(deviceClassMockBroken);
|
||||
// ret.append(deviceClassMockBroken);
|
||||
|
||||
// Broken Async setup device
|
||||
DeviceClass deviceClassMockBrokenAsyncSetup(pluginId(), guhVendorId, mockDeviceBrokenAsyncSetupClassId);
|
||||
deviceClassMockBrokenAsyncSetup.setName("Mock Device (Async Broken setup)");
|
||||
deviceClassMockBrokenAsyncSetup.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
// // Broken Async setup device
|
||||
// DeviceClass deviceClassMockBrokenAsyncSetup(pluginId(), supportedVendors().first().id(), mockDeviceBrokenAsyncSetupClassId);
|
||||
// deviceClassMockBrokenAsyncSetup.setName("Mock Device (Async Broken setup)");
|
||||
// deviceClassMockBrokenAsyncSetup.setCreateMethod(DeviceClass::CreateMethodUser);
|
||||
|
||||
deviceClassMockBrokenAsyncSetup.setParamTypes(mockParams);
|
||||
deviceClassMockBrokenAsyncSetup.setStateTypes(mockStates);
|
||||
deviceClassMockBrokenAsyncSetup.setEventTypes(mockEvents);
|
||||
deviceClassMockBrokenAsyncSetup.setActions(mockActions);
|
||||
// deviceClassMockBrokenAsyncSetup.setParamTypes(mockParams);
|
||||
// deviceClassMockBrokenAsyncSetup.setStateTypes(mockStates);
|
||||
// deviceClassMockBrokenAsyncSetup.setEventTypes(mockEvents);
|
||||
// deviceClassMockBrokenAsyncSetup.setActions(mockActions);
|
||||
|
||||
ret.append(deviceClassMockBrokenAsyncSetup);
|
||||
// ret.append(deviceClassMockBrokenAsyncSetup);
|
||||
|
||||
return ret;
|
||||
}
|
||||
// return ret;
|
||||
//}
|
||||
|
||||
DeviceManager::HardwareResources DevicePluginMock::requiredHardware() const
|
||||
{
|
||||
@ -221,16 +211,6 @@ QPair<DeviceManager::DeviceError, QString> DevicePluginMock::discoverDevices(con
|
||||
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)
|
||||
{
|
||||
qDebug() << "Mockdevice created returning true" << device->paramValue("httpport").toInt();
|
||||
|
||||
@ -36,14 +36,9 @@ public:
|
||||
explicit DevicePluginMock();
|
||||
~DevicePluginMock();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const 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;
|
||||
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 <QDateTime>
|
||||
|
||||
VendorId openweathermapVendorId = VendorId("bf1e96f0-9650-4e7c-a56c-916d54d18e7a");
|
||||
VendorId openweathermapVendorId = VendorId("");
|
||||
DeviceClassId openweathermapDeviceClassId = DeviceClassId("985195aa-17ad-4530-88a4-cdd753d747d7");
|
||||
|
||||
ActionTypeId updateWeatherActionTypeId = ActionTypeId("cfbc6504-d86f-4856-8dfa-97b6fbb385e4");
|
||||
@ -304,125 +304,6 @@ DevicePluginOpenweathermap::DevicePluginOpenweathermap()
|
||||
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)
|
||||
{
|
||||
if(deviceClassId == openweathermapDeviceClassId){
|
||||
@ -472,16 +353,6 @@ QPair<DeviceManager::DeviceError, QString> DevicePluginOpenweathermap::executeAc
|
||||
return report();
|
||||
}
|
||||
|
||||
QString DevicePluginOpenweathermap::pluginName() const
|
||||
{
|
||||
return "Openweathermap";
|
||||
}
|
||||
|
||||
PluginId DevicePluginOpenweathermap::pluginId() const
|
||||
{
|
||||
return PluginId("bc6af567-2338-41d5-aac1-462dec6e4783");
|
||||
}
|
||||
|
||||
void DevicePluginOpenweathermap::guhTimer()
|
||||
{
|
||||
foreach (Device *device, deviceManager()->findConfiguredDevices(openweathermapDeviceClassId)) {
|
||||
|
||||
@ -35,17 +35,11 @@ public:
|
||||
|
||||
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::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
||||
|
||||
QString pluginName() const override;
|
||||
PluginId pluginId() const override;
|
||||
|
||||
void guhTimer() override;
|
||||
|
||||
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 <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 hueDeviceClassAutoId = DeviceClassId("9cce5981-50a1-4873-a374-c53c095feb3b");
|
||||
|
||||
@ -54,109 +53,75 @@ DevicePluginPhilipsHue::DevicePluginPhilipsHue():
|
||||
connect(m_bridge, &HueBridgeConnection::getFinished, this, &DevicePluginPhilipsHue::getFinished);
|
||||
}
|
||||
|
||||
QList<Vendor> DevicePluginPhilipsHue::supportedVendors() const
|
||||
{
|
||||
QList<Vendor> 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);
|
||||
//QList<DeviceClass> DevicePluginPhilipsHue::supportedDevices() const
|
||||
//{
|
||||
// QList<DeviceClass> ret;
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
@ -169,16 +134,6 @@ void DevicePluginPhilipsHue::startMonitoringAutoDevices()
|
||||
// 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> params;
|
||||
|
||||
@ -36,15 +36,10 @@ class DevicePluginPhilipsHue: public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginPhilipsHue();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
void startMonitoringAutoDevices() override;
|
||||
|
||||
QString pluginName() const override;
|
||||
PluginId pluginId() const override;
|
||||
|
||||
QList<ParamType> configurationDescription() const 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 <QUdpSocket>
|
||||
|
||||
extern VendorId guhVendorId;
|
||||
DeviceClassId wolDeviceClassId = DeviceClassId("3c8f2447-dcd0-4882-8c09-99e579e4d24c");
|
||||
ActionTypeId wolActionTypeId = ActionTypeId("fb9b9d87-218f-4f0d-9e16-39f8a105029a");
|
||||
|
||||
@ -131,55 +130,37 @@ DevicePluginWakeOnLan::DevicePluginWakeOnLan()
|
||||
{
|
||||
}
|
||||
|
||||
QList<Vendor> DevicePluginWakeOnLan::supportedVendors() const
|
||||
{
|
||||
QList<Vendor> ret;
|
||||
Vendor guh(guhVendorId, "guh");
|
||||
ret.append(guh);
|
||||
return ret;
|
||||
}
|
||||
//QList<DeviceClass> DevicePluginWakeOnLan::supportedDevices() const
|
||||
//{
|
||||
// QList<DeviceClass> ret;
|
||||
|
||||
QList<DeviceClass> DevicePluginWakeOnLan::supportedDevices() const
|
||||
{
|
||||
QList<DeviceClass> ret;
|
||||
|
||||
DeviceClass deviceClassWakeOnLan(pluginId(), guhVendorId, wolDeviceClassId);
|
||||
deviceClassWakeOnLan.setName("Wake On Lan");
|
||||
// DeviceClass deviceClassWakeOnLan(pluginId(), supportedVendors().first().id(), wolDeviceClassId);
|
||||
// deviceClassWakeOnLan.setName("Wake On Lan");
|
||||
|
||||
QList<ParamType> wolParams;
|
||||
ParamType nameParam("name", QVariant::String);
|
||||
wolParams.append(nameParam);
|
||||
ParamType wolParam("mac", QVariant::String);
|
||||
wolParams.append(wolParam);
|
||||
// QList<ParamType> wolParams;
|
||||
// ParamType nameParam("name", QVariant::String);
|
||||
// wolParams.append(nameParam);
|
||||
// ParamType wolParam("mac", QVariant::String);
|
||||
// wolParams.append(wolParam);
|
||||
|
||||
|
||||
QList<ActionType> wolActions;
|
||||
ActionType wolAction(wolActionTypeId);
|
||||
wolAction.setName("wakeup");
|
||||
wolActions.append(wolAction);
|
||||
// QList<ActionType> wolActions;
|
||||
// ActionType wolAction(wolActionTypeId);
|
||||
// wolAction.setName("wakeup");
|
||||
// wolActions.append(wolAction);
|
||||
|
||||
deviceClassWakeOnLan.setParamTypes(wolParams);
|
||||
deviceClassWakeOnLan.setActions(wolActions);
|
||||
// deviceClassWakeOnLan.setParamTypes(wolParams);
|
||||
// deviceClassWakeOnLan.setActions(wolActions);
|
||||
|
||||
ret.append(deviceClassWakeOnLan);
|
||||
return ret;
|
||||
}
|
||||
// ret.append(deviceClassWakeOnLan);
|
||||
// return ret;
|
||||
//}
|
||||
|
||||
DeviceManager::HardwareResources DevicePluginWakeOnLan::requiredHardware() const
|
||||
{
|
||||
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)
|
||||
{
|
||||
qDebug() << "execute action " << action.actionTypeId().toString();
|
||||
|
||||
@ -33,12 +33,8 @@ class DevicePluginWakeOnLan : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginWakeOnLan();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() 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;
|
||||
|
||||
|
||||
|
||||
@ -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 <QStringList>
|
||||
|
||||
extern VendorId guhVendorId;
|
||||
PluginId pluginUuid = PluginId("8e0f791e-b273-4267-8605-b7c2f55a68ab");
|
||||
DeviceClassId detectorId = DeviceClassId("bd216356-f1ec-4324-9785-6982d2174e17");
|
||||
StateTypeId inRangeStateTypeId = StateTypeId("cb43e1b5-4f61-4538-bfa2-c33055c542cf");
|
||||
|
||||
@ -33,57 +31,39 @@ DevicePluginWifiDetector::DevicePluginWifiDetector()
|
||||
{
|
||||
}
|
||||
|
||||
QList<Vendor> DevicePluginWifiDetector::supportedVendors() const
|
||||
{
|
||||
QList<Vendor> ret;
|
||||
Vendor guh(guhVendorId, "guh");
|
||||
ret.append(guh);
|
||||
return ret;
|
||||
}
|
||||
//QList<DeviceClass> DevicePluginWifiDetector::supportedDevices() const
|
||||
//{
|
||||
// QList<DeviceClass> ret;
|
||||
|
||||
QList<DeviceClass> DevicePluginWifiDetector::supportedDevices() const
|
||||
{
|
||||
QList<DeviceClass> ret;
|
||||
|
||||
DeviceClass deviceClassWifiDetector(pluginId(), guhVendorId, detectorId);
|
||||
deviceClassWifiDetector.setName("WiFi Device");
|
||||
// DeviceClass deviceClassWifiDetector(pluginId(), supportedVendors().first().id(), detectorId);
|
||||
// deviceClassWifiDetector.setName("WiFi Device");
|
||||
|
||||
QList<ParamType> detectorParams;
|
||||
ParamType macParam("mac", QVariant::String);
|
||||
detectorParams.append(macParam);
|
||||
// QList<ParamType> detectorParams;
|
||||
// ParamType macParam("mac", QVariant::String);
|
||||
// detectorParams.append(macParam);
|
||||
|
||||
deviceClassWifiDetector.setParamTypes(detectorParams);
|
||||
// deviceClassWifiDetector.setParamTypes(detectorParams);
|
||||
|
||||
QList<StateType> detectorStates;
|
||||
// QList<StateType> detectorStates;
|
||||
|
||||
StateType inRangeState(inRangeStateTypeId);
|
||||
inRangeState.setName("inRange");
|
||||
inRangeState.setType(QVariant::Bool);
|
||||
inRangeState.setDefaultValue(false);
|
||||
detectorStates.append(inRangeState);
|
||||
// StateType inRangeState(inRangeStateTypeId);
|
||||
// inRangeState.setName("inRange");
|
||||
// inRangeState.setType(QVariant::Bool);
|
||||
// inRangeState.setDefaultValue(false);
|
||||
// detectorStates.append(inRangeState);
|
||||
|
||||
deviceClassWifiDetector.setStateTypes(detectorStates);
|
||||
// deviceClassWifiDetector.setStateTypes(detectorStates);
|
||||
|
||||
ret.append(deviceClassWifiDetector);
|
||||
// ret.append(deviceClassWifiDetector);
|
||||
|
||||
return ret;
|
||||
}
|
||||
// return ret;
|
||||
//}
|
||||
|
||||
DeviceManager::HardwareResources DevicePluginWifiDetector::requiredHardware() const
|
||||
{
|
||||
return DeviceManager::HardwareResourceTimer;
|
||||
}
|
||||
|
||||
QString DevicePluginWifiDetector::pluginName() const
|
||||
{
|
||||
return "WiFi Detector";
|
||||
}
|
||||
|
||||
PluginId DevicePluginWifiDetector::pluginId() const
|
||||
{
|
||||
return pluginUuid;
|
||||
}
|
||||
|
||||
void DevicePluginWifiDetector::guhTimer()
|
||||
{
|
||||
QProcess *p = new QProcess(this);
|
||||
|
||||
@ -33,13 +33,8 @@ class DevicePluginWifiDetector : public DevicePlugin
|
||||
public:
|
||||
explicit DevicePluginWifiDetector();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
QString pluginName() const override;
|
||||
PluginId pluginId() const override;
|
||||
|
||||
void guhTimer() override;
|
||||
|
||||
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 <QtTest>
|
||||
|
||||
extern PluginId mockPluginId;
|
||||
extern VendorId guhVendorId;
|
||||
extern DeviceClassId mockDeviceClassId;
|
||||
extern DeviceClassId mockDeviceAutoClassId;
|
||||
extern DeviceClassId mockDeviceDiscoveryClassId;
|
||||
@ -63,6 +61,9 @@ protected:
|
||||
void restartServer();
|
||||
|
||||
protected:
|
||||
PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");
|
||||
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
||||
|
||||
MockTcpServer *m_mockTcpServer;
|
||||
QUuid m_clientId;
|
||||
int m_commandId;
|
||||
|
||||
Reference in New Issue
Block a user