improove plugin loading and add deviceIcon to plugins

This commit is contained in:
Simon Stürz 2016-02-27 00:18:46 +01:00 committed by Michael Zanetti
parent 134879793f
commit 74150aa7a6
29 changed files with 218 additions and 165 deletions

View File

@ -2,7 +2,7 @@
GUH_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"') GUH_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"')
# define protocol versions # define protocol versions
JSON_PROTOCOL_VERSION=36 JSON_PROTOCOL_VERSION=37
REST_API_VERSION=1 REST_API_VERSION=1
DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" \ DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" \

View File

@ -26,7 +26,7 @@
\ingroup devices \ingroup devices
\inmodule libguh \inmodule libguh
The DeviceManager holds all information about supported and configured Devices in the system. The DeviceManager hold s all information about supported and configured Devices in the system.
It is also responsible for loading Plugins and managing common hardware resources between It is also responsible for loading Plugins and managing common hardware resources between
\l{DevicePlugin}{device plugins}. \l{DevicePlugin}{device plugins}.

View File

@ -120,6 +120,7 @@
\value DeviceIconDesk \value DeviceIconDesk
\value DeviceIconHifi \value DeviceIconHifi
\value DeviceIconPower \value DeviceIconPower
\value DeviceIconEnergy
\value DeviceIconRadio \value DeviceIconRadio
\value DeviceIconSmartPhone \value DeviceIconSmartPhone
\value DeviceIconSocket \value DeviceIconSocket
@ -138,6 +139,11 @@
\value DeviceIconSwitch \value DeviceIconSwitch
\value DeviceIconMotionDetectors \value DeviceIconMotionDetectors
\value DeviceIconWeather \value DeviceIconWeather
\value DeviceIconTime
\value DeviceIconLightBulb
\value DeviceIconGateway
\value DeviceIconMail
\value DeviceIconNetwork
\value DeviceIconCloud \value DeviceIconCloud
*/ */
@ -152,6 +158,7 @@ DeviceClass::DeviceClass(const PluginId &pluginId, const VendorId &vendorId, con
m_id(id), m_id(id),
m_vendorId(vendorId), m_vendorId(vendorId),
m_pluginId(pluginId), m_pluginId(pluginId),
m_deviceIcon(DeviceIconPower),
m_createMethods(CreateMethodUser), m_createMethods(CreateMethodUser),
m_setupMethod(SetupMethodJustAdd) m_setupMethod(SetupMethodJustAdd)
{ {

View File

@ -78,6 +78,7 @@ public:
}; };
enum DeviceIcon { enum DeviceIcon {
DeviceIconNone,
DeviceIconBed, DeviceIconBed,
DeviceIconBlinds, DeviceIconBlinds,
DeviceIconCeilingLamp, DeviceIconCeilingLamp,
@ -86,6 +87,7 @@ public:
DeviceIconDesk, DeviceIconDesk,
DeviceIconHifi, DeviceIconHifi,
DeviceIconPower, DeviceIconPower,
DeviceIconEnergy,
DeviceIconRadio, DeviceIconRadio,
DeviceIconSmartPhone, DeviceIconSmartPhone,
DeviceIconSocket, DeviceIconSocket,
@ -104,6 +106,11 @@ public:
DeviceIconSwitch, DeviceIconSwitch,
DeviceIconMotionDetectors, DeviceIconMotionDetectors,
DeviceIconWeather, DeviceIconWeather,
DeviceIconTime,
DeviceIconLightBulb,
DeviceIconGateway,
DeviceIconMail,
DeviceIconNetwork,
DeviceIconCloud DeviceIconCloud
}; };

View File

@ -183,7 +183,9 @@ QList<Vendor> DevicePlugin::supportedVendors() const
return vendors; return vendors;
} }
/*! Return a list of \l{DeviceClass}{DeviceClasses} describing all the devices supported by this plugin. */ /*! Return a list of \l{DeviceClass}{DeviceClasses} describing all the devices supported by this plugin.
If a DeviceClass has an invalid parameter it will be ignored.
*/
QList<DeviceClass> DevicePlugin::supportedDevices() const QList<DeviceClass> DevicePlugin::supportedDevices() const
{ {
QList<DeviceClass> deviceClasses; QList<DeviceClass> deviceClasses;
@ -200,12 +202,16 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
createMethods |= DeviceClass::CreateMethodDiscovery; createMethods |= DeviceClass::CreateMethodDiscovery;
} else if (createMethodValue.toString() == "auto") { } else if (createMethodValue.toString() == "auto") {
createMethods |= DeviceClass::CreateMethodAuto; createMethods |= DeviceClass::CreateMethodAuto;
} else if (createMethodValue.toString() == "user") {
createMethods |= DeviceClass::CreateMethodUser;
} else { } else {
qCWarning(dcDeviceManager) << "Unknown createMehtod" << createMethodValue.toString() <<
"in deviceClass " << deviceClass.name() << ". Falling back to CreateMethodUser.";
createMethods |= DeviceClass::CreateMethodUser; createMethods |= DeviceClass::CreateMethodUser;
} }
} }
deviceClass.setCreateMethods(createMethods); deviceClass.setCreateMethods(createMethods);
deviceClass.setDeviceIcon(loadAndVerifyDeviceIcon(jo.value("deviceIcon").toString()));
deviceClass.setDiscoveryParamTypes(parseParamTypes(jo.value("discoveryParamTypes").toArray())); deviceClass.setDiscoveryParamTypes(parseParamTypes(jo.value("discoveryParamTypes").toArray()));
QString setupMethod = jo.value("setupMethod").toString(); QString setupMethod = jo.value("setupMethod").toString();
@ -215,7 +221,9 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
deviceClass.setSetupMethod(DeviceClass::SetupMethodDisplayPin); deviceClass.setSetupMethod(DeviceClass::SetupMethodDisplayPin);
} else if (setupMethod == "enterPin") { } else if (setupMethod == "enterPin") {
deviceClass.setSetupMethod(DeviceClass::SetupMethodEnterPin); deviceClass.setSetupMethod(DeviceClass::SetupMethodEnterPin);
} else { } else if (setupMethod == "justAdd") {
qCWarning(dcDeviceManager) << "Unknown setupMehtod" << setupMethod <<
"in deviceClass " << deviceClass.name() << ". Falling back to SetupMethodJustAdd.";
deviceClass.setSetupMethod(DeviceClass::SetupMethodJustAdd); deviceClass.setSetupMethod(DeviceClass::SetupMethodJustAdd);
} }
deviceClass.setPairingInfo(jo.value("pairingInfo").toString()); deviceClass.setPairingInfo(jo.value("pairingInfo").toString());
@ -223,7 +231,7 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
QList<DeviceClass::BasicTag> basicTags; QList<DeviceClass::BasicTag> basicTags;
foreach (const QJsonValue &basicTagJson, jo.value("basicTags").toArray()) { foreach (const QJsonValue &basicTagJson, jo.value("basicTags").toArray()) {
basicTags.append(basicTagStringToBasicTag(basicTagJson.toString())); basicTags.append(loadAndVerifyBasicTag(basicTagJson.toString()));
} }
deviceClass.setBasicTags(basicTags); deviceClass.setBasicTags(basicTags);
@ -242,7 +250,7 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
StateType stateType(st.value("id").toString()); StateType stateType(st.value("id").toString());
stateType.setName(st.value("name").toString()); stateType.setName(st.value("name").toString());
stateType.setType(t); stateType.setType(t);
stateType.setUnit(unitStringToUnit(st.value("unit").toString())); stateType.setUnit(loadAndVerifyUnit(st.value("unit").toString()));
stateType.setDefaultValue(st.value("defaultValue").toVariant()); stateType.setDefaultValue(st.value("defaultValue").toVariant());
if (st.contains("minValue")) if (st.contains("minValue"))
stateType.setMinValue(st.value("minValue").toVariant()); stateType.setMinValue(st.value("minValue").toVariant());
@ -256,6 +264,13 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
possibleValues.append(possibleValueJson.toVariant()); possibleValues.append(possibleValueJson.toVariant());
} }
stateType.setPossibleValues(possibleValues); stateType.setPossibleValues(possibleValues);
// inform the plugin developer about the error in the plugin json file
Q_ASSERT_X(stateType.possibleValues().contains(stateType.defaultValue()),
QString("\"%1\" plugin").arg(pluginName()).toLatin1().data(),
QString("The given default value \"%1\" is not in the possible values of the stateType \"%2\".")
.arg(stateType.defaultValue().toString()).arg(stateType.name()).toLatin1().data());
} }
stateTypes.append(stateType); stateTypes.append(stateType);
@ -307,9 +322,9 @@ QList<DeviceClass> DevicePlugin::supportedDevices() const
} }
deviceClass.setEventTypes(eventTypes); deviceClass.setEventTypes(eventTypes);
if (!broken) { if (!broken)
deviceClasses.append(deviceClass); deviceClasses.append(deviceClass);
}
} }
} }
return deviceClasses; return deviceClasses;
@ -451,12 +466,12 @@ QList<ParamType> DevicePlugin::parseParamTypes(const QJsonArray &array) const
// set the input type if there is any // set the input type if there is any
if (pt.contains("inputType")) { if (pt.contains("inputType")) {
paramType.setInputType(inputTypeStringToInputType(pt.value("inputType").toString())); paramType.setInputType(loadAndVerifyInputType(pt.value("inputType").toString()));
} }
// set the unit if there is any // set the unit if there is any
if (pt.contains("unit")) { if (pt.contains("unit")) {
paramType.setUnit(unitStringToUnit(pt.value("unit").toString())); paramType.setUnit(loadAndVerifyUnit(pt.value("unit").toString()));
} }
// set readOnly if given (default false) // set readOnly if given (default false)
@ -693,161 +708,96 @@ QStringList DevicePlugin::verifyFields(const QStringList &fields, const QJsonObj
return ret; return ret;
} }
Types::Unit DevicePlugin::unitStringToUnit(const QString &unitString) const Types::Unit DevicePlugin::loadAndVerifyUnit(const QString &unitString) const
{ {
if (unitString == QString()) { if (unitString.isEmpty())
return Types::UnitNone; return Types::UnitNone;
} else if (unitString == "Seconds") {
return Types::UnitSeconds; QMetaObject metaObject = Types::staticMetaObject;
} else if (unitString == "Minutes") { int enumIndex = metaObject.indexOfEnumerator(QString("Unit").toLatin1().data());
return Types::UnitMinutes; QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
} else if (unitString == "Hours") {
return Types::UnitHours; int enumValue = -1;
} else if (unitString == "UnixTime") { for (int i = 0; i < metaEnum.keyCount(); i++) {
return Types::UnitUnixTime; if (QString(metaEnum.valueToKey(metaEnum.value(i))) == QString("Unit" + unitString)) {
} else if (unitString == "MeterPerSecond") { enumValue = metaEnum.value(i);
return Types::UnitMeterPerSecond; break;
} else if (unitString == "KiloMeterPerHour") { }
return Types::UnitKiloMeterPerHour;
} else if (unitString == "Degree") {
return Types::UnitDegree;
} else if (unitString == "Radiant") {
return Types::UnitRadiant;
} else if (unitString == "DegreeCelsius") {
return Types::UnitDegreeCelsius;
} else if (unitString == "DegreeKelvin") {
return Types::UnitDegreeKelvin;
} else if (unitString == "Mired") {
return Types::UnitMired;
} else if (unitString == "MilliBar") {
return Types::UnitMilliBar;
} else if (unitString == "Bar") {
return Types::UnitBar;
} else if (unitString == "Pascal") {
return Types::UnitPascal;
} else if (unitString == "HectoPascal") {
return Types::UnitHectoPascal;
} else if (unitString == "Atmosphere") {
return Types::UnitAtmosphere;
} else if (unitString == "Lumen") {
return Types::UnitLumen;
} else if (unitString == "Lux") {
return Types::UnitLux;
} else if (unitString == "Candela") {
return Types::UnitCandela;
} else if (unitString == "MilliMeter") {
return Types::UnitMilliMeter;
} else if (unitString == "CentiMeter") {
return Types::UnitCentiMeter;
} else if (unitString == "Meter") {
return Types::UnitMeter;
} else if (unitString == "KiloMeter") {
return Types::UnitKiloMeter;
} else if (unitString == "Gram") {
return Types::UnitGram;
} else if (unitString == "KiloGram") {
return Types::UnitKiloGram;
} else if (unitString == "Dezibel") {
return Types::UnitDezibel;
} else if (unitString == "KiloByte") {
return Types::UnitKiloByte;
} else if (unitString == "MegaByte") {
return Types::UnitMegaByte;
} else if (unitString == "GigaByte") {
return Types::UnitGigaByte;
} else if (unitString == "TeraByte") {
return Types::UnitTeraByte;
} else if (unitString == "MilliWatt") {
return Types::UnitMilliWatt;
} else if (unitString == "Watt") {
return Types::UnitWatt;
} else if (unitString == "KiloWatt") {
return Types::UnitKiloWatt;
} else if (unitString == "KiloWattHour") {
return Types::UnitKiloWattHour;
} else if (unitString == "EuroPerMegaWattHour") {
return Types::UnitEuroPerMegaWattHour;
} else if (unitString == "EuroCentPerKiloWattHour") {
return Types::UnitEuroCentPerKiloWattHour;
} else if (unitString == "Percentage") {
return Types::UnitPercentage;
} else if (unitString == "PartsPerMillion") {
return Types::UnitPartsPerMillion;
} else if (unitString == "Euro") {
return Types::UnitEuro;
} else if (unitString == "Dollar") {
return Types::UnitDollar;
} else {
qCWarning(dcDeviceManager) << "Could not parse unit:" << unitString << "in plugin" << this->pluginName();
} }
return Types::UnitNone;
// inform the plugin developer about the error in the plugin json file
Q_ASSERT_X(enumValue != -1,
QString("\"%1\" plugin").arg(pluginName()).toLatin1().data(),
QString("Invalid unit type \"%1\" in json file.").arg(unitString).toLatin1().data());
return (Types::Unit)enumValue;
} }
Types::InputType DevicePlugin::inputTypeStringToInputType(const QString &inputType) const Types::InputType DevicePlugin::loadAndVerifyInputType(const QString &inputType) const
{ {
if (inputType == "TextLine") { QMetaObject metaObject = Types::staticMetaObject;
return Types::InputTypeTextLine; int enumIndex = metaObject.indexOfEnumerator(QString("InputType").toLatin1().data());
} else if (inputType == "TextArea") { QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
return Types::InputTypeTextArea;
} else if (inputType == "Password") { int enumValue = -1;
return Types::InputTypePassword; for (int i = 0; i < metaEnum.keyCount(); i++) {
} else if (inputType == "Search") { if (QString(metaEnum.valueToKey(metaEnum.value(i))) == QString("InputType" + inputType)) {
return Types::InputTypeSearch; enumValue = metaEnum.value(i);
} else if (inputType == "Mail") { break;
return Types::InputTypeMail; }
} else if (inputType == "IPv4Address") {
return Types::InputTypeIPv4Address;
} else if (inputType == "IPv6Address") {
return Types::InputTypeIPv6Address;
} else if (inputType == "Url") {
return Types::InputTypeUrl;
} else if (inputType == "MacAddress") {
return Types::InputTypeMacAddress;
} }
return Types::InputTypeNone;
// inform the plugin developer about the error in the plugin json file
Q_ASSERT_X(enumValue != -1,
QString("\"%1\" plugin").arg(pluginName()).toLatin1().data(),
QString("Invalid inputType \"%1\" in json file.").arg(inputType).toLatin1().data());
return (Types::InputType)enumValue;
} }
DeviceClass::BasicTag DevicePlugin::basicTagStringToBasicTag(const QString &basicTag) const DeviceClass::BasicTag DevicePlugin::loadAndVerifyBasicTag(const QString &basicTag) const
{ {
if (basicTag == "Device") { QMetaObject metaObject = DeviceClass::staticMetaObject;
return DeviceClass::BasicTagDevice; int enumIndex = metaObject.indexOfEnumerator(QString("BasicTag").toLatin1().data());
} else if (basicTag == "Service") { QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
return DeviceClass::BasicTagService;
} else if (basicTag == "Actuator") { int enumValue = -1;
return DeviceClass::BasicTagActuator; for (int i = 0; i < metaEnum.keyCount(); i++) {
} else if (basicTag == "Sensor") { if (QString(metaEnum.valueToKey(metaEnum.value(i))) == QString("BasicTag" + basicTag)) {
return DeviceClass::BasicTagSensor; enumValue = metaEnum.value(i);
} else if (basicTag == "Lighting") { break;
return DeviceClass::BasicTagLighting; }
} else if (basicTag == "Energy") {
return DeviceClass::BasicTagEnergy;
} else if (basicTag == "Multimedia") {
return DeviceClass::BasicTagMultimedia;
} else if (basicTag == "Weather") {
return DeviceClass::BasicTagWeather;
} else if (basicTag == "Gateway") {
return DeviceClass::BasicTagGateway;
} else if (basicTag == "Heating") {
return DeviceClass::BasicTagHeating;
} else if (basicTag == "Cooling") {
return DeviceClass::BasicTagCooling;
} else if (basicTag == "Notification") {
return DeviceClass::BasicTagNotification;
} else if (basicTag == "Security") {
return DeviceClass::BasicTagSecurity;
} else if (basicTag == "Time") {
return DeviceClass::BasicTagTime;
} else if (basicTag == "Shading") {
return DeviceClass::BasicTagShading;
} else if (basicTag == "Appliance") {
return DeviceClass::BasicTagAppliance;
} else if (basicTag == "Camera") {
return DeviceClass::BasicTagCamera;
} else if (basicTag == "Lock") {
return DeviceClass::BasicTagLock;
} else {
qCWarning(dcDeviceManager) << "Could not parse basicTag:" << basicTag << "in plugin" << this->pluginName();
} }
return DeviceClass::BasicTagDevice; // inform the plugin developer about the error in the plugin json file
Q_ASSERT_X(enumValue != -1,
QString("\"%1\" plugin").arg(pluginName()).toLatin1().data(),
QString("Invalid basicTag type \"%1\" in json file.").arg(basicTag).toLatin1().data());
return (DeviceClass::BasicTag)enumValue;
}
DeviceClass::DeviceIcon DevicePlugin::loadAndVerifyDeviceIcon(const QString &deviceIcon) const
{
if (deviceIcon.isEmpty())
return DeviceClass::DeviceIconNone;
QMetaObject metaObject = DeviceClass::staticMetaObject;
int enumIndex = metaObject.indexOfEnumerator(QString("DeviceIcon").toLatin1().data());
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
int enumValue = -1;
for (int i = 0; i < metaEnum.keyCount(); i++) {
if (QString(metaEnum.valueToKey(metaEnum.value(i))) == QString("DeviceIcon" + deviceIcon)) {
enumValue = metaEnum.value(i);
break;
}
}
// inform the plugin developer about the error in the plugin json file
Q_ASSERT_X(enumValue != -1,
QString("\"%1\" plugin").arg(pluginName()).toLatin1().data(),
QString("Invalid icon type \"%1\" in json file.").arg(deviceIcon).toLatin1().data());
return (DeviceClass::DeviceIcon)enumValue;
} }

View File

@ -38,7 +38,9 @@
#endif #endif
#include <QObject> #include <QObject>
#include <QMetaEnum>
#include <QJsonObject> #include <QJsonObject>
#include <QMetaObject>
class DeviceManager; class DeviceManager;
class Device; class Device;
@ -90,7 +92,6 @@ public:
QVariant configValue(const QString &paramName) const; QVariant configValue(const QString &paramName) const;
DeviceManager::DeviceError setConfigValue(const QString &paramName, const QVariant &value); DeviceManager::DeviceError setConfigValue(const QString &paramName, const QVariant &value);
signals: signals:
void emitEvent(const Event &event); void emitEvent(const Event &event);
void devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> &deviceDescriptors); void devicesDiscovered(const DeviceClassId &deviceClassId, const QList<DeviceDescriptor> &deviceDescriptors);
@ -125,9 +126,11 @@ private:
QStringList verifyFields(const QStringList &fields, const QJsonObject &value) const; QStringList verifyFields(const QStringList &fields, const QJsonObject &value) const;
Types::Unit unitStringToUnit(const QString &unitString) const; // load and verify enum values
Types::InputType inputTypeStringToInputType(const QString &inputType) const; Types::Unit loadAndVerifyUnit(const QString &unitString) const;
DeviceClass::BasicTag basicTagStringToBasicTag(const QString &basicTag) const; Types::InputType loadAndVerifyInputType(const QString &inputType) const;
DeviceClass::BasicTag loadAndVerifyBasicTag(const QString &basicTag) const;
DeviceClass::DeviceIcon loadAndVerifyDeviceIcon(const QString &deviceIcon) const;
DeviceManager *m_deviceManager; DeviceManager *m_deviceManager;

View File

@ -20,6 +20,7 @@
"deviceClassId": "29cd8265-d8bb-4cf9-9080-bfc2cf9787bc", "deviceClassId": "29cd8265-d8bb-4cf9-9080-bfc2cf9787bc",
"name": "aWATTar", "name": "aWATTar",
"createMethods": ["user"], "createMethods": ["user"],
"deviceIcon": "Energy",
"basicTags": [ "basicTags": [
"Service", "Service",
"Actuator", "Actuator",

View File

@ -11,12 +11,13 @@
{ {
"deviceClassId": "2bb14180-aa5d-4999-992d-e6d464cff486", "deviceClassId": "2bb14180-aa5d-4999-992d-e6d464cff486",
"name": "Shutter (RSM900R)", "name": "Shutter (RSM900R)",
"idName": "conradShutter",
"deviceIcon": "Blinds",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator", "Actuator",
"Shading" "Shading"
], ],
"idName": "conradShutter",
"createMethods": ["user"], "createMethods": ["user"],
"paramTypes": [ "paramTypes": [
{ {

View File

@ -12,6 +12,7 @@
"deviceClassId": "fbf665fb-9aca-423f-a5f2-924e50ebe6ca", "deviceClassId": "fbf665fb-9aca-423f-a5f2-924e50ebe6ca",
"idName": "today", "idName": "today",
"name": "Today", "name": "Today",
"deviceIcon": "Time",
"basicTags": [ "basicTags": [
"Service", "Service",
"Time" "Time"
@ -174,6 +175,7 @@
"deviceClassId": "3f3c7ecc-9915-4e4e-95a1-e11f4f9d174d", "deviceClassId": "3f3c7ecc-9915-4e4e-95a1-e11f4f9d174d",
"idName": "alarm", "idName": "alarm",
"name": "Alarm", "name": "Alarm",
"deviceIcon": "Time",
"basicTags": [ "basicTags": [
"Service", "Service",
"Actuator", "Actuator",
@ -271,6 +273,7 @@
"deviceClassId": "805c8948-e663-4ba6-aa67-df7446ed7098", "deviceClassId": "805c8948-e663-4ba6-aa67-df7446ed7098",
"idName": "countdown", "idName": "countdown",
"name": "Countdown", "name": "Countdown",
"deviceIcon": "Time",
"basicTags": [ "basicTags": [
"Service", "Service",
"Actuator", "Actuator",

View File

@ -11,6 +11,7 @@
"deviceClassId": "164f9602-90ee-4693-bda3-9cafae37603e", "deviceClassId": "164f9602-90ee-4693-bda3-9cafae37603e",
"idName": "avea", "idName": "avea",
"name": "Avea", "name": "Avea",
"deviceIcon": "LightBulb",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator", "Actuator",

View File

@ -11,6 +11,7 @@
{ {
"deviceClassId": "308ae6e6-38b3-4b3a-a513-3199da2764f8", "deviceClassId": "308ae6e6-38b3-4b3a-a513-3199da2764f8",
"name": "Elro Socket", "name": "Elro Socket",
"deviceIcon": "Socket",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator" "Actuator"

View File

@ -12,6 +12,7 @@
"deviceClassId": "1e892268-8bd7-442c-a001-bd4e2e6b2949", "deviceClassId": "1e892268-8bd7-442c-a001-bd4e2e6b2949",
"idName": "cube", "idName": "cube",
"name": "Max! Cube LAN Gateway", "name": "Max! Cube LAN Gateway",
"deviceIcon": "Gateway",
"basicTags": [ "basicTags": [
"Device", "Device",
"Gateway", "Gateway",
@ -60,6 +61,7 @@
"deviceClassId": "ffbfec5d-06e8-4082-b62b-92cc5c3e8c4e", "deviceClassId": "ffbfec5d-06e8-4082-b62b-92cc5c3e8c4e",
"idName": "wallThermostate", "idName": "wallThermostate",
"name": "Max! Wall Thermostat", "name": "Max! Wall Thermostat",
"deviceIcon": "Thermometer",
"basicTags": [ "basicTags": [
"Device", "Device",
"Heating", "Heating",
@ -241,6 +243,7 @@
"deviceClassId": "f80d9481-4827-45ee-a013-b97b22412d92", "deviceClassId": "f80d9481-4827-45ee-a013-b97b22412d92",
"idName": "radiatorThermostate", "idName": "radiatorThermostate",
"name": "Max! Radiator Thermostat", "name": "Max! Radiator Thermostat",
"deviceIcon": "Thermometer",
"basicTags": [ "basicTags": [
"Device", "Device",
"Heating", "Heating",

View File

@ -12,6 +12,7 @@
"deviceClassId": "c0f511f9-70f5-499b-bd70-2c0e9ddd68c4", "deviceClassId": "c0f511f9-70f5-499b-bd70-2c0e9ddd68c4",
"idName": "toggleButton", "idName": "toggleButton",
"name": "Toggle Button", "name": "Toggle Button",
"deviceIcon": "Switch",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator" "Actuator"
@ -39,6 +40,7 @@
"deviceClassId": "820b2f2d-0d92-48c8-8fd4-f94ce8fc4103", "deviceClassId": "820b2f2d-0d92-48c8-8fd4-f94ce8fc4103",
"idName": "button", "idName": "button",
"name": "Button", "name": "Button",
"deviceIcon": "Switch",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator" "Actuator"
@ -70,6 +72,7 @@
"deviceClassId": "430d188c-476d-4825-a9bd-86dfa3094b56", "deviceClassId": "430d188c-476d-4825-a9bd-86dfa3094b56",
"idName": "onOffButton", "idName": "onOffButton",
"name": "ON/OFF Button", "name": "ON/OFF Button",
"deviceIcon": "Switch",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator" "Actuator"

View File

@ -12,6 +12,7 @@
"deviceClassId": "324219e8-7c53-41b5-b314-c2900cd15252", "deviceClassId": "324219e8-7c53-41b5-b314-c2900cd15252",
"name": "Intertechno switch", "name": "Intertechno switch",
"createMethods": ["user"], "createMethods": ["user"],
"deviceIcon": "Switch",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator" "Actuator"

View File

@ -12,6 +12,7 @@
"deviceClassId": "d09953e3-c5bd-415b-973b-0d0bf2be3f69", "deviceClassId": "d09953e3-c5bd-415b-973b-0d0bf2be3f69",
"idName": "kodi", "idName": "kodi",
"name": "Kodi", "name": "Kodi",
"deviceIcon": "Tv",
"basicTags": [ "basicTags": [
"Service", "Service",
"Multimedia", "Multimedia",

View File

@ -12,6 +12,7 @@
"deviceClassId": "6b1f8f37-7eb4-46c4-9f15-a6eb4904999c", "deviceClassId": "6b1f8f37-7eb4-46c4-9f15-a6eb4904999c",
"idName": "rfController", "idName": "rfController",
"name": "RF Controller (LN-CON-RF20B)", "name": "RF Controller (LN-CON-RF20B)",
"deviceIcon": "LightBulb",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator", "Actuator",

View File

@ -12,6 +12,7 @@
"deviceClassId": "1d41b5a8-74ff-4a12-b365-c7bbe610848f", "deviceClassId": "1d41b5a8-74ff-4a12-b365-c7bbe610848f",
"idName": "lgSmartTv", "idName": "lgSmartTv",
"name": "LG Smart Tv", "name": "LG Smart Tv",
"deviceIcon": "Tv",
"basicTags": [ "basicTags": [
"Device", "Device",
"Multimedia", "Multimedia",

View File

@ -12,6 +12,7 @@
"deviceClassId": "f4844c97-7ca6-4349-904e-ff9749a9fe74", "deviceClassId": "f4844c97-7ca6-4349-904e-ff9749a9fe74",
"idName": "customMail", "idName": "customMail",
"name": "Custom mail", "name": "Custom mail",
"deviceIcon": "Mail",
"basicTags": [ "basicTags": [
"Service", "Service",
"Notification" "Notification"
@ -90,6 +91,7 @@
"deviceClassId": "3869884a-1592-4b8f-84a7-994be18ff555", "deviceClassId": "3869884a-1592-4b8f-84a7-994be18ff555",
"idName": "googleMail", "idName": "googleMail",
"name": "Google mail", "name": "Google mail",
"deviceIcon": "Mail",
"basicTags": [ "basicTags": [
"Service", "Service",
"Notification" "Notification"
@ -143,6 +145,7 @@
"deviceClassId": "59409e8f-0c83-414f-abd5-bbbf2758acba", "deviceClassId": "59409e8f-0c83-414f-abd5-bbbf2758acba",
"idName": "yahooMail", "idName": "yahooMail",
"name": "Yahoo mail", "name": "Yahoo mail",
"deviceIcon": "Mail",
"basicTags": [ "basicTags": [
"Service", "Service",
"Notification" "Notification"

View File

@ -26,6 +26,7 @@
"deviceClassId": "753f0d32-0468-4d08-82ed-1964aab03298", "deviceClassId": "753f0d32-0468-4d08-82ed-1964aab03298",
"idName": "mock", "idName": "mock",
"name": "Mock Device", "name": "Mock Device",
"deviceIcon": "Tune",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator", "Actuator",
@ -140,6 +141,7 @@
"Gateway" "Gateway"
], ],
"createMethods": ["auto"], "createMethods": ["auto"],
"deviceIcon": "Tune",
"paramTypes": [ "paramTypes": [
{ {
"name": "name", "name": "name",
@ -238,6 +240,7 @@
], ],
"createMethods": ["discovery"], "createMethods": ["discovery"],
"setupMethod": "pushButton", "setupMethod": "pushButton",
"deviceIcon": "Tune",
"pairingInfo": "Wait 3 second before you continue, the push button will be pressed automatically.", "pairingInfo": "Wait 3 second before you continue, the push button will be pressed automatically.",
"discoveryParamTypes": [ "discoveryParamTypes": [
{ {
@ -281,7 +284,7 @@
"idName": "allowedValues", "idName": "allowedValues",
"name": "allowed values", "name": "allowed values",
"type": "QString", "type": "QString",
"defaultValue": "String value 1", "defaultValue": "String value 2",
"possibleValues": [ "possibleValues": [
"String value 1", "String value 1",
"String value 2", "String value 2",
@ -321,6 +324,7 @@
"deviceClassId": "296f1fd4-e893-46b2-8a42-50d1bceb8730", "deviceClassId": "296f1fd4-e893-46b2-8a42-50d1bceb8730",
"idName": "mockDisplayPin", "idName": "mockDisplayPin",
"name": "Mock Device (Display Pin)", "name": "Mock Device (Display Pin)",
"deviceIcon": "Tune",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator", "Actuator",
@ -418,6 +422,7 @@
"deviceClassId": "a71fbde9-9a38-4bf8-beab-c8aade2608ba", "deviceClassId": "a71fbde9-9a38-4bf8-beab-c8aade2608ba",
"idName": "mockParent", "idName": "mockParent",
"name": "Mock Device (Parent)", "name": "Mock Device (Parent)",
"deviceIcon": "Tune",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator", "Actuator",
@ -480,6 +485,7 @@
"deviceClassId": "515ffdf1-55e5-498d-9abc-4e2fe768f3a9", "deviceClassId": "515ffdf1-55e5-498d-9abc-4e2fe768f3a9",
"idName": "mockInputType", "idName": "mockInputType",
"name": "Mock Device (InputTypes)", "name": "Mock Device (InputTypes)",
"deviceIcon": "Tune",
"basicTags": [ "basicTags": [
"Device" "Device"
], ],

View File

@ -12,6 +12,7 @@
"deviceClassId": "728d5a67-27a3-400e-b83c-2765f5196f69", "deviceClassId": "728d5a67-27a3-400e-b83c-2765f5196f69",
"idName": "connection", "idName": "connection",
"name": "Netatmo Connection", "name": "Netatmo Connection",
"deviceIcon": "Network",
"basicTags": [ "basicTags": [
"Service", "Service",
"Gateway", "Gateway",
@ -49,6 +50,7 @@
"deviceClassId": "1c809049-04f2-4710-99f5-6ed379a2934f", "deviceClassId": "1c809049-04f2-4710-99f5-6ed379a2934f",
"idName": "indoor", "idName": "indoor",
"name": "Indoor Station", "name": "Indoor Station",
"deviceIcon": "Thermometer",
"basicTags": [ "basicTags": [
"Device", "Device",
"Weather", "Weather",
@ -154,6 +156,7 @@
"deviceClassId": "6cc01d62-7317-4ec4-8ac4-a4cab762c179", "deviceClassId": "6cc01d62-7317-4ec4-8ac4-a4cab762c179",
"idName": "outdoor", "idName": "outdoor",
"name": "Outdoor Station", "name": "Outdoor Station",
"deviceIcon": "Thermometer",
"basicTags": [ "basicTags": [
"Device", "Device",
"Weather", "Weather",

View File

@ -12,6 +12,7 @@
"deviceClassId": "985195aa-17ad-4530-88a4-cdd753d747d7", "deviceClassId": "985195aa-17ad-4530-88a4-cdd753d747d7",
"idName": "openweathermap", "idName": "openweathermap",
"name": "Weather", "name": "Weather",
"deviceIcon": "Weather",
"basicTags": [ "basicTags": [
"Service", "Service",
"Weather", "Weather",

View File

@ -12,6 +12,7 @@
"deviceClassId": "642aa4c7-19aa-45ed-ba06-aa1ae6c9edf7", "deviceClassId": "642aa4c7-19aa-45ed-ba06-aa1ae6c9edf7",
"idName": "hueBridge", "idName": "hueBridge",
"name": "Hue gateway", "name": "Hue gateway",
"deviceIcon": "Gateway",
"basicTags": [ "basicTags": [
"Device", "Device",
"Gateway", "Gateway",
@ -118,6 +119,7 @@
"deviceClassId": "0edba26c-96ab-44fb-a6a2-c0574d19630e", "deviceClassId": "0edba26c-96ab-44fb-a6a2-c0574d19630e",
"idName": "hueLight", "idName": "hueLight",
"name": "Hue Light", "name": "Hue Light",
"deviceIcon": "LightBulb",
"basicTags": [ "basicTags": [
"Device", "Device",
"Lighting", "Lighting",
@ -251,6 +253,7 @@
"deviceClassId": "4fa568ef-7a3a-422b-b0c0-206d37cb4eed", "deviceClassId": "4fa568ef-7a3a-422b-b0c0-206d37cb4eed",
"idName": "hueWhiteLight", "idName": "hueWhiteLight",
"name": "Hue White Light", "name": "Hue White Light",
"deviceIcon": "LightBulb",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator", "Actuator",
@ -352,6 +355,7 @@
"deviceClassId": "bb482d39-67ef-46dc-88e9-7b181d642b28", "deviceClassId": "bb482d39-67ef-46dc-88e9-7b181d642b28",
"idName": "hueRemote", "idName": "hueRemote",
"name": "Hue Remote", "name": "Hue Remote",
"deviceIcon": "Switch",
"basicTags": [ "basicTags": [
"Device", "Device",
"Sensor" "Sensor"

View File

@ -11,6 +11,7 @@
{ {
"deviceClassId": "6ecd5a8d-595a-4520-85e3-dcc9679edf66", "deviceClassId": "6ecd5a8d-595a-4520-85e3-dcc9679edf66",
"name": "UDP Commander", "name": "UDP Commander",
"deviceIcon": "Network",
"basicTags": [ "basicTags": [
"Service", "Service",
"Sensor" "Sensor"

View File

@ -11,6 +11,7 @@
{ {
"deviceClassId": "8468a15d-ecc0-43b6-98ca-e1e4ac9e2df3", "deviceClassId": "8468a15d-ecc0-43b6-98ca-e1e4ac9e2df3",
"name": "Unitec switch (48111)", "name": "Unitec switch (48111)",
"deviceIcon": "Switch",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator" "Actuator"

View File

@ -11,6 +11,7 @@
{ {
"deviceClassId": "3c8f2447-dcd0-4882-8c09-99e579e4d24c", "deviceClassId": "3c8f2447-dcd0-4882-8c09-99e579e4d24c",
"name": "Wake On Lan", "name": "Wake On Lan",
"deviceIcon": "Network",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator" "Actuator"

View File

@ -12,6 +12,7 @@
"deviceClassId": "69d97d3b-a8e6-42f3-afc0-ca8a53eb7cce", "deviceClassId": "69d97d3b-a8e6-42f3-afc0-ca8a53eb7cce",
"idName": "wemoSwitch", "idName": "wemoSwitch",
"name": "WeMo Switch", "name": "WeMo Switch",
"deviceIcon": "Socket",
"basicTags": [ "basicTags": [
"Device", "Device",
"Actuator" "Actuator"

View File

@ -12,6 +12,7 @@
"deviceClassId": "bd216356-f1ec-4324-9785-6982d2174e17", "deviceClassId": "bd216356-f1ec-4324-9785-6982d2174e17",
"name": "WiFi Device", "name": "WiFi Device",
"idName": "wifi", "idName": "wifi",
"deviceIcon": "Network",
"basicTags": [ "basicTags": [
"Device", "Device",
"Sensor" "Sensor"

View File

@ -81,13 +81,13 @@ void JsonTypes::init()
{ {
// BasicTypes // BasicTypes
s_basicType = enumToStrings(JsonTypes::staticMetaObject, "BasicType"); s_basicType = enumToStrings(JsonTypes::staticMetaObject, "BasicType");
s_basicTag = enumToStrings(DeviceClass::staticMetaObject, "BasicTag");
s_stateOperator = enumToStrings(Types::staticMetaObject, "StateOperator"); s_stateOperator = enumToStrings(Types::staticMetaObject, "StateOperator");
s_valueOperator = enumToStrings(Types::staticMetaObject, "ValueOperator"); s_valueOperator = enumToStrings(Types::staticMetaObject, "ValueOperator");
s_inputType = enumToStrings(Types::staticMetaObject, "InputType"); s_inputType = enumToStrings(Types::staticMetaObject, "InputType");
s_unit = enumToStrings(Types::staticMetaObject, "Unit"); s_unit = enumToStrings(Types::staticMetaObject, "Unit");
s_createMethod = enumToStrings(DeviceClass::staticMetaObject, "CreateMethod"); s_createMethod = enumToStrings(DeviceClass::staticMetaObject, "CreateMethod");
s_setupMethod = enumToStrings(DeviceClass::staticMetaObject, "SetupMethod"); s_setupMethod = enumToStrings(DeviceClass::staticMetaObject, "SetupMethod");
s_basicTag = enumToStrings(DeviceClass::staticMetaObject, "BasicTag");
s_deviceIcon = enumToStrings(DeviceClass::staticMetaObject, "DeviceIcon"); s_deviceIcon = enumToStrings(DeviceClass::staticMetaObject, "DeviceIcon");
s_removePolicy = enumToStrings(RuleEngine::staticMetaObject, "RemovePolicy"); s_removePolicy = enumToStrings(RuleEngine::staticMetaObject, "RemovePolicy");
s_deviceError = enumToStrings(DeviceManager::staticMetaObject, "DeviceError"); s_deviceError = enumToStrings(DeviceManager::staticMetaObject, "DeviceError");
@ -193,6 +193,7 @@ void JsonTypes::init()
s_deviceClass.insert("vendorId", basicTypeToString(Uuid)); s_deviceClass.insert("vendorId", basicTypeToString(Uuid));
s_deviceClass.insert("pluginId", basicTypeToString(Uuid)); s_deviceClass.insert("pluginId", basicTypeToString(Uuid));
s_deviceClass.insert("name", basicTypeToString(String)); s_deviceClass.insert("name", basicTypeToString(String));
s_deviceClass.insert("deviceIcon", deviceIconRef());
s_deviceClass.insert("basicTags", QVariantList() << basicTagRef()); s_deviceClass.insert("basicTags", QVariantList() << basicTagRef());
s_deviceClass.insert("stateTypes", QVariantList() << stateTypeRef()); s_deviceClass.insert("stateTypes", QVariantList() << stateTypeRef());
s_deviceClass.insert("eventTypes", QVariantList() << eventTypeRef()); s_deviceClass.insert("eventTypes", QVariantList() << eventTypeRef());
@ -529,6 +530,7 @@ QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass)
variant.insert("id", deviceClass.id()); variant.insert("id", deviceClass.id());
variant.insert("vendorId", deviceClass.vendorId()); variant.insert("vendorId", deviceClass.vendorId());
variant.insert("pluginId", deviceClass.pluginId()); variant.insert("pluginId", deviceClass.pluginId());
variant.insert("deviceIcon", s_deviceIcon.at(deviceClass.deviceIcon()));
QVariantList basicTags; QVariantList basicTags;
foreach (const DeviceClass::BasicTag &basicTag, deviceClass.basicTags()) { foreach (const DeviceClass::BasicTag &basicTag, deviceClass.basicTags()) {

View File

@ -1,4 +1,4 @@
36 37
{ {
"methods": { "methods": {
"Actions.ExecuteAction": { "Actions.ExecuteAction": {
@ -595,6 +595,7 @@
"createMethods": [ "createMethods": [
"$ref:CreateMethod" "$ref:CreateMethod"
], ],
"deviceIcon": "$ref:DeviceIcon",
"discoveryParamTypes": [ "discoveryParamTypes": [
"$ref:ParamType" "$ref:ParamType"
], ],
@ -644,6 +645,42 @@
"DeviceErrorPairingTransactionIdNotFound", "DeviceErrorPairingTransactionIdNotFound",
"DeviceErrorParameterNotWritable" "DeviceErrorParameterNotWritable"
], ],
"DeviceIcon": [
"DeviceIconNone",
"DeviceIconBed",
"DeviceIconBlinds",
"DeviceIconCeilingLamp",
"DeviceIconCouch",
"DeviceIconDeskLamp",
"DeviceIconDesk",
"DeviceIconHifi",
"DeviceIconPower",
"DeviceIconEnergy",
"DeviceIconRadio",
"DeviceIconSmartPhone",
"DeviceIconSocket",
"DeviceIconStandardLamp",
"DeviceIconSun",
"DeviceIconTablet",
"DeviceIconThermometer",
"DeviceIconTune",
"DeviceIconTv",
"DeviceIconBattery",
"DeviceIconDishwasher",
"DeviceIconWashingMachine",
"DeviceIconLaundryDryer",
"DeviceIconIrHeater",
"DeviceIconRadiator",
"DeviceIconSwitch",
"DeviceIconMotionDetectors",
"DeviceIconWeather",
"DeviceIconTime",
"DeviceIconLightBulb",
"DeviceIconGateway",
"DeviceIconMail",
"DeviceIconNetwork",
"DeviceIconCloud"
],
"Event": { "Event": {
"deviceId": "Uuid", "deviceId": "Uuid",
"eventTypeId": "Uuid", "eventTypeId": "Uuid",
@ -879,7 +916,15 @@
"UnitPercentage", "UnitPercentage",
"UnitPartsPerMillion", "UnitPartsPerMillion",
"UnitEuro", "UnitEuro",
"UnitDollar" "UnitDollar",
"UnitHerz",
"UnitAmpere",
"UnitMilliAmpere",
"UnitVolt",
"UnitMilliVolt",
"UnitVoltAmpere",
"UnitVoltAmpereReactive",
"UnitAmpereHour"
], ],
"ValueOperator": [ "ValueOperator": [
"ValueOperatorEquals", "ValueOperatorEquals",