diff --git a/guh.pri b/guh.pri index 43d00b63..dfac576b 100644 --- a/guh.pri +++ b/guh.pri @@ -2,7 +2,7 @@ GUH_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"') # define protocol versions -JSON_PROTOCOL_VERSION=36 +JSON_PROTOCOL_VERSION=37 REST_API_VERSION=1 DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" \ diff --git a/libguh/devicemanager.cpp b/libguh/devicemanager.cpp index f3730c81..6c1c8789 100644 --- a/libguh/devicemanager.cpp +++ b/libguh/devicemanager.cpp @@ -26,7 +26,7 @@ \ingroup devices \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 \l{DevicePlugin}{device plugins}. diff --git a/libguh/plugin/deviceclass.cpp b/libguh/plugin/deviceclass.cpp index 21efb014..0daa745c 100644 --- a/libguh/plugin/deviceclass.cpp +++ b/libguh/plugin/deviceclass.cpp @@ -120,6 +120,7 @@ \value DeviceIconDesk \value DeviceIconHifi \value DeviceIconPower + \value DeviceIconEnergy \value DeviceIconRadio \value DeviceIconSmartPhone \value DeviceIconSocket @@ -138,6 +139,11 @@ \value DeviceIconSwitch \value DeviceIconMotionDetectors \value DeviceIconWeather + \value DeviceIconTime + \value DeviceIconLightBulb + \value DeviceIconGateway + \value DeviceIconMail + \value DeviceIconNetwork \value DeviceIconCloud */ @@ -152,6 +158,7 @@ DeviceClass::DeviceClass(const PluginId &pluginId, const VendorId &vendorId, con m_id(id), m_vendorId(vendorId), m_pluginId(pluginId), + m_deviceIcon(DeviceIconPower), m_createMethods(CreateMethodUser), m_setupMethod(SetupMethodJustAdd) { diff --git a/libguh/plugin/deviceclass.h b/libguh/plugin/deviceclass.h index 040bef8b..9c5847d9 100644 --- a/libguh/plugin/deviceclass.h +++ b/libguh/plugin/deviceclass.h @@ -78,6 +78,7 @@ public: }; enum DeviceIcon { + DeviceIconNone, DeviceIconBed, DeviceIconBlinds, DeviceIconCeilingLamp, @@ -86,6 +87,7 @@ public: DeviceIconDesk, DeviceIconHifi, DeviceIconPower, + DeviceIconEnergy, DeviceIconRadio, DeviceIconSmartPhone, DeviceIconSocket, @@ -104,6 +106,11 @@ public: DeviceIconSwitch, DeviceIconMotionDetectors, DeviceIconWeather, + DeviceIconTime, + DeviceIconLightBulb, + DeviceIconGateway, + DeviceIconMail, + DeviceIconNetwork, DeviceIconCloud }; diff --git a/libguh/plugin/deviceplugin.cpp b/libguh/plugin/deviceplugin.cpp index a773a4bb..94efe2f1 100644 --- a/libguh/plugin/deviceplugin.cpp +++ b/libguh/plugin/deviceplugin.cpp @@ -183,7 +183,9 @@ QList DevicePlugin::supportedVendors() const 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 DevicePlugin::supportedDevices() const { QList deviceClasses; @@ -200,12 +202,16 @@ QList DevicePlugin::supportedDevices() const createMethods |= DeviceClass::CreateMethodDiscovery; } else if (createMethodValue.toString() == "auto") { createMethods |= DeviceClass::CreateMethodAuto; + } else if (createMethodValue.toString() == "user") { + createMethods |= DeviceClass::CreateMethodUser; } else { + qCWarning(dcDeviceManager) << "Unknown createMehtod" << createMethodValue.toString() << + "in deviceClass " << deviceClass.name() << ". Falling back to CreateMethodUser."; createMethods |= DeviceClass::CreateMethodUser; } } deviceClass.setCreateMethods(createMethods); - + deviceClass.setDeviceIcon(loadAndVerifyDeviceIcon(jo.value("deviceIcon").toString())); deviceClass.setDiscoveryParamTypes(parseParamTypes(jo.value("discoveryParamTypes").toArray())); QString setupMethod = jo.value("setupMethod").toString(); @@ -215,7 +221,9 @@ QList DevicePlugin::supportedDevices() const deviceClass.setSetupMethod(DeviceClass::SetupMethodDisplayPin); } else if (setupMethod == "enterPin") { 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.setPairingInfo(jo.value("pairingInfo").toString()); @@ -223,7 +231,7 @@ QList DevicePlugin::supportedDevices() const QList basicTags; foreach (const QJsonValue &basicTagJson, jo.value("basicTags").toArray()) { - basicTags.append(basicTagStringToBasicTag(basicTagJson.toString())); + basicTags.append(loadAndVerifyBasicTag(basicTagJson.toString())); } deviceClass.setBasicTags(basicTags); @@ -242,7 +250,7 @@ QList DevicePlugin::supportedDevices() const StateType stateType(st.value("id").toString()); stateType.setName(st.value("name").toString()); stateType.setType(t); - stateType.setUnit(unitStringToUnit(st.value("unit").toString())); + stateType.setUnit(loadAndVerifyUnit(st.value("unit").toString())); stateType.setDefaultValue(st.value("defaultValue").toVariant()); if (st.contains("minValue")) stateType.setMinValue(st.value("minValue").toVariant()); @@ -256,6 +264,13 @@ QList DevicePlugin::supportedDevices() const possibleValues.append(possibleValueJson.toVariant()); } 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); @@ -307,9 +322,9 @@ QList DevicePlugin::supportedDevices() const } deviceClass.setEventTypes(eventTypes); - if (!broken) { + if (!broken) deviceClasses.append(deviceClass); - } + } } return deviceClasses; @@ -451,12 +466,12 @@ QList DevicePlugin::parseParamTypes(const QJsonArray &array) const // set the input type if there is any 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 if (pt.contains("unit")) { - paramType.setUnit(unitStringToUnit(pt.value("unit").toString())); + paramType.setUnit(loadAndVerifyUnit(pt.value("unit").toString())); } // set readOnly if given (default false) @@ -693,161 +708,96 @@ QStringList DevicePlugin::verifyFields(const QStringList &fields, const QJsonObj 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; - } else if (unitString == "Seconds") { - return Types::UnitSeconds; - } else if (unitString == "Minutes") { - return Types::UnitMinutes; - } else if (unitString == "Hours") { - return Types::UnitHours; - } else if (unitString == "UnixTime") { - return Types::UnitUnixTime; - } else if (unitString == "MeterPerSecond") { - return Types::UnitMeterPerSecond; - } 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(); + + QMetaObject metaObject = Types::staticMetaObject; + int enumIndex = metaObject.indexOfEnumerator(QString("Unit").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("Unit" + unitString)) { + enumValue = metaEnum.value(i); + break; + } } - 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") { - return Types::InputTypeTextLine; - } else if (inputType == "TextArea") { - return Types::InputTypeTextArea; - } else if (inputType == "Password") { - return Types::InputTypePassword; - } else if (inputType == "Search") { - return Types::InputTypeSearch; - } else if (inputType == "Mail") { - 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; + QMetaObject metaObject = Types::staticMetaObject; + int enumIndex = metaObject.indexOfEnumerator(QString("InputType").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("InputType" + inputType)) { + enumValue = metaEnum.value(i); + break; + } } - 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") { - return DeviceClass::BasicTagDevice; - } else if (basicTag == "Service") { - return DeviceClass::BasicTagService; - } else if (basicTag == "Actuator") { - return DeviceClass::BasicTagActuator; - } else if (basicTag == "Sensor") { - return DeviceClass::BasicTagSensor; - } else if (basicTag == "Lighting") { - 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(); + QMetaObject metaObject = DeviceClass::staticMetaObject; + int enumIndex = metaObject.indexOfEnumerator(QString("BasicTag").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("BasicTag" + basicTag)) { + enumValue = metaEnum.value(i); + break; + } } - 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; } diff --git a/libguh/plugin/deviceplugin.h b/libguh/plugin/deviceplugin.h index c5e972ef..a591c2b5 100644 --- a/libguh/plugin/deviceplugin.h +++ b/libguh/plugin/deviceplugin.h @@ -38,7 +38,9 @@ #endif #include +#include #include +#include class DeviceManager; class Device; @@ -90,7 +92,6 @@ public: QVariant configValue(const QString ¶mName) const; DeviceManager::DeviceError setConfigValue(const QString ¶mName, const QVariant &value); - signals: void emitEvent(const Event &event); void devicesDiscovered(const DeviceClassId &deviceClassId, const QList &deviceDescriptors); @@ -125,9 +126,11 @@ private: QStringList verifyFields(const QStringList &fields, const QJsonObject &value) const; - Types::Unit unitStringToUnit(const QString &unitString) const; - Types::InputType inputTypeStringToInputType(const QString &inputType) const; - DeviceClass::BasicTag basicTagStringToBasicTag(const QString &basicTag) const; + // load and verify enum values + Types::Unit loadAndVerifyUnit(const QString &unitString) 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; diff --git a/plugins/deviceplugins/awattar/devicepluginawattar.json b/plugins/deviceplugins/awattar/devicepluginawattar.json index 28775a3a..e97ec0ac 100644 --- a/plugins/deviceplugins/awattar/devicepluginawattar.json +++ b/plugins/deviceplugins/awattar/devicepluginawattar.json @@ -20,6 +20,7 @@ "deviceClassId": "29cd8265-d8bb-4cf9-9080-bfc2cf9787bc", "name": "aWATTar", "createMethods": ["user"], + "deviceIcon": "Energy", "basicTags": [ "Service", "Actuator", diff --git a/plugins/deviceplugins/conrad/devicepluginconrad.json b/plugins/deviceplugins/conrad/devicepluginconrad.json index 2bf7ec9f..ad37b5b4 100644 --- a/plugins/deviceplugins/conrad/devicepluginconrad.json +++ b/plugins/deviceplugins/conrad/devicepluginconrad.json @@ -11,12 +11,13 @@ { "deviceClassId": "2bb14180-aa5d-4999-992d-e6d464cff486", "name": "Shutter (RSM900R)", + "idName": "conradShutter", + "deviceIcon": "Blinds", "basicTags": [ "Device", "Actuator", "Shading" ], - "idName": "conradShutter", "createMethods": ["user"], "paramTypes": [ { diff --git a/plugins/deviceplugins/datetime/deviceplugindatetime.json b/plugins/deviceplugins/datetime/deviceplugindatetime.json index c9fe202e..65d50b12 100644 --- a/plugins/deviceplugins/datetime/deviceplugindatetime.json +++ b/plugins/deviceplugins/datetime/deviceplugindatetime.json @@ -12,6 +12,7 @@ "deviceClassId": "fbf665fb-9aca-423f-a5f2-924e50ebe6ca", "idName": "today", "name": "Today", + "deviceIcon": "Time", "basicTags": [ "Service", "Time" @@ -174,6 +175,7 @@ "deviceClassId": "3f3c7ecc-9915-4e4e-95a1-e11f4f9d174d", "idName": "alarm", "name": "Alarm", + "deviceIcon": "Time", "basicTags": [ "Service", "Actuator", @@ -271,6 +273,7 @@ "deviceClassId": "805c8948-e663-4ba6-aa67-df7446ed7098", "idName": "countdown", "name": "Countdown", + "deviceIcon": "Time", "basicTags": [ "Service", "Actuator", diff --git a/plugins/deviceplugins/elgato/devicepluginelgato.json b/plugins/deviceplugins/elgato/devicepluginelgato.json index 9c384449..4ad2d1bb 100644 --- a/plugins/deviceplugins/elgato/devicepluginelgato.json +++ b/plugins/deviceplugins/elgato/devicepluginelgato.json @@ -11,6 +11,7 @@ "deviceClassId": "164f9602-90ee-4693-bda3-9cafae37603e", "idName": "avea", "name": "Avea", + "deviceIcon": "LightBulb", "basicTags": [ "Device", "Actuator", diff --git a/plugins/deviceplugins/elro/devicepluginelro.json b/plugins/deviceplugins/elro/devicepluginelro.json index 56881de1..386199ab 100644 --- a/plugins/deviceplugins/elro/devicepluginelro.json +++ b/plugins/deviceplugins/elro/devicepluginelro.json @@ -11,6 +11,7 @@ { "deviceClassId": "308ae6e6-38b3-4b3a-a513-3199da2764f8", "name": "Elro Socket", + "deviceIcon": "Socket", "basicTags": [ "Device", "Actuator" diff --git a/plugins/deviceplugins/eq-3/deviceplugineq-3.json b/plugins/deviceplugins/eq-3/deviceplugineq-3.json index 7426a2e2..2e91e3bf 100644 --- a/plugins/deviceplugins/eq-3/deviceplugineq-3.json +++ b/plugins/deviceplugins/eq-3/deviceplugineq-3.json @@ -12,6 +12,7 @@ "deviceClassId": "1e892268-8bd7-442c-a001-bd4e2e6b2949", "idName": "cube", "name": "Max! Cube LAN Gateway", + "deviceIcon": "Gateway", "basicTags": [ "Device", "Gateway", @@ -60,6 +61,7 @@ "deviceClassId": "ffbfec5d-06e8-4082-b62b-92cc5c3e8c4e", "idName": "wallThermostate", "name": "Max! Wall Thermostat", + "deviceIcon": "Thermometer", "basicTags": [ "Device", "Heating", @@ -241,6 +243,7 @@ "deviceClassId": "f80d9481-4827-45ee-a013-b97b22412d92", "idName": "radiatorThermostate", "name": "Max! Radiator Thermostat", + "deviceIcon": "Thermometer", "basicTags": [ "Device", "Heating", diff --git a/plugins/deviceplugins/genericelements/deviceplugingenericelements.json b/plugins/deviceplugins/genericelements/deviceplugingenericelements.json index b69b6e28..e1c64280 100644 --- a/plugins/deviceplugins/genericelements/deviceplugingenericelements.json +++ b/plugins/deviceplugins/genericelements/deviceplugingenericelements.json @@ -12,6 +12,7 @@ "deviceClassId": "c0f511f9-70f5-499b-bd70-2c0e9ddd68c4", "idName": "toggleButton", "name": "Toggle Button", + "deviceIcon": "Switch", "basicTags": [ "Device", "Actuator" @@ -39,6 +40,7 @@ "deviceClassId": "820b2f2d-0d92-48c8-8fd4-f94ce8fc4103", "idName": "button", "name": "Button", + "deviceIcon": "Switch", "basicTags": [ "Device", "Actuator" @@ -70,6 +72,7 @@ "deviceClassId": "430d188c-476d-4825-a9bd-86dfa3094b56", "idName": "onOffButton", "name": "ON/OFF Button", + "deviceIcon": "Switch", "basicTags": [ "Device", "Actuator" diff --git a/plugins/deviceplugins/intertechno/devicepluginintertechno.json b/plugins/deviceplugins/intertechno/devicepluginintertechno.json index 32cf2983..92be2ae6 100644 --- a/plugins/deviceplugins/intertechno/devicepluginintertechno.json +++ b/plugins/deviceplugins/intertechno/devicepluginintertechno.json @@ -12,6 +12,7 @@ "deviceClassId": "324219e8-7c53-41b5-b314-c2900cd15252", "name": "Intertechno switch", "createMethods": ["user"], + "deviceIcon": "Switch", "basicTags": [ "Device", "Actuator" diff --git a/plugins/deviceplugins/kodi/devicepluginkodi.json b/plugins/deviceplugins/kodi/devicepluginkodi.json index 78596479..4f82b84d 100644 --- a/plugins/deviceplugins/kodi/devicepluginkodi.json +++ b/plugins/deviceplugins/kodi/devicepluginkodi.json @@ -12,6 +12,7 @@ "deviceClassId": "d09953e3-c5bd-415b-973b-0d0bf2be3f69", "idName": "kodi", "name": "Kodi", + "deviceIcon": "Tv", "basicTags": [ "Service", "Multimedia", diff --git a/plugins/deviceplugins/leynew/devicepluginleynew.json b/plugins/deviceplugins/leynew/devicepluginleynew.json index 81c07613..15daa69d 100644 --- a/plugins/deviceplugins/leynew/devicepluginleynew.json +++ b/plugins/deviceplugins/leynew/devicepluginleynew.json @@ -12,6 +12,7 @@ "deviceClassId": "6b1f8f37-7eb4-46c4-9f15-a6eb4904999c", "idName": "rfController", "name": "RF Controller (LN-CON-RF20B)", + "deviceIcon": "LightBulb", "basicTags": [ "Device", "Actuator", diff --git a/plugins/deviceplugins/lgsmarttv/devicepluginlgsmarttv.json b/plugins/deviceplugins/lgsmarttv/devicepluginlgsmarttv.json index 8d1391a6..7b5887af 100644 --- a/plugins/deviceplugins/lgsmarttv/devicepluginlgsmarttv.json +++ b/plugins/deviceplugins/lgsmarttv/devicepluginlgsmarttv.json @@ -12,6 +12,7 @@ "deviceClassId": "1d41b5a8-74ff-4a12-b365-c7bbe610848f", "idName": "lgSmartTv", "name": "LG Smart Tv", + "deviceIcon": "Tv", "basicTags": [ "Device", "Multimedia", diff --git a/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json b/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json index 9266cee3..f0c76485 100644 --- a/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json +++ b/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json @@ -12,6 +12,7 @@ "deviceClassId": "f4844c97-7ca6-4349-904e-ff9749a9fe74", "idName": "customMail", "name": "Custom mail", + "deviceIcon": "Mail", "basicTags": [ "Service", "Notification" @@ -90,6 +91,7 @@ "deviceClassId": "3869884a-1592-4b8f-84a7-994be18ff555", "idName": "googleMail", "name": "Google mail", + "deviceIcon": "Mail", "basicTags": [ "Service", "Notification" @@ -143,6 +145,7 @@ "deviceClassId": "59409e8f-0c83-414f-abd5-bbbf2758acba", "idName": "yahooMail", "name": "Yahoo mail", + "deviceIcon": "Mail", "basicTags": [ "Service", "Notification" diff --git a/plugins/deviceplugins/mock/devicepluginmock.json b/plugins/deviceplugins/mock/devicepluginmock.json index 1bddc484..f888d51a 100644 --- a/plugins/deviceplugins/mock/devicepluginmock.json +++ b/plugins/deviceplugins/mock/devicepluginmock.json @@ -26,6 +26,7 @@ "deviceClassId": "753f0d32-0468-4d08-82ed-1964aab03298", "idName": "mock", "name": "Mock Device", + "deviceIcon": "Tune", "basicTags": [ "Device", "Actuator", @@ -140,6 +141,7 @@ "Gateway" ], "createMethods": ["auto"], + "deviceIcon": "Tune", "paramTypes": [ { "name": "name", @@ -238,6 +240,7 @@ ], "createMethods": ["discovery"], "setupMethod": "pushButton", + "deviceIcon": "Tune", "pairingInfo": "Wait 3 second before you continue, the push button will be pressed automatically.", "discoveryParamTypes": [ { @@ -281,7 +284,7 @@ "idName": "allowedValues", "name": "allowed values", "type": "QString", - "defaultValue": "String value 1", + "defaultValue": "String value 2", "possibleValues": [ "String value 1", "String value 2", @@ -321,6 +324,7 @@ "deviceClassId": "296f1fd4-e893-46b2-8a42-50d1bceb8730", "idName": "mockDisplayPin", "name": "Mock Device (Display Pin)", + "deviceIcon": "Tune", "basicTags": [ "Device", "Actuator", @@ -418,6 +422,7 @@ "deviceClassId": "a71fbde9-9a38-4bf8-beab-c8aade2608ba", "idName": "mockParent", "name": "Mock Device (Parent)", + "deviceIcon": "Tune", "basicTags": [ "Device", "Actuator", @@ -480,6 +485,7 @@ "deviceClassId": "515ffdf1-55e5-498d-9abc-4e2fe768f3a9", "idName": "mockInputType", "name": "Mock Device (InputTypes)", + "deviceIcon": "Tune", "basicTags": [ "Device" ], diff --git a/plugins/deviceplugins/netatmo/devicepluginnetatmo.json b/plugins/deviceplugins/netatmo/devicepluginnetatmo.json index 2167afca..eb6a4203 100644 --- a/plugins/deviceplugins/netatmo/devicepluginnetatmo.json +++ b/plugins/deviceplugins/netatmo/devicepluginnetatmo.json @@ -12,6 +12,7 @@ "deviceClassId": "728d5a67-27a3-400e-b83c-2765f5196f69", "idName": "connection", "name": "Netatmo Connection", + "deviceIcon": "Network", "basicTags": [ "Service", "Gateway", @@ -49,6 +50,7 @@ "deviceClassId": "1c809049-04f2-4710-99f5-6ed379a2934f", "idName": "indoor", "name": "Indoor Station", + "deviceIcon": "Thermometer", "basicTags": [ "Device", "Weather", @@ -154,6 +156,7 @@ "deviceClassId": "6cc01d62-7317-4ec4-8ac4-a4cab762c179", "idName": "outdoor", "name": "Outdoor Station", + "deviceIcon": "Thermometer", "basicTags": [ "Device", "Weather", diff --git a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json index e768c3c1..cf46f83f 100644 --- a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json +++ b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json @@ -12,6 +12,7 @@ "deviceClassId": "985195aa-17ad-4530-88a4-cdd753d747d7", "idName": "openweathermap", "name": "Weather", + "deviceIcon": "Weather", "basicTags": [ "Service", "Weather", diff --git a/plugins/deviceplugins/philipshue/devicepluginphilipshue.json b/plugins/deviceplugins/philipshue/devicepluginphilipshue.json index e5db327a..bdb4676b 100644 --- a/plugins/deviceplugins/philipshue/devicepluginphilipshue.json +++ b/plugins/deviceplugins/philipshue/devicepluginphilipshue.json @@ -12,6 +12,7 @@ "deviceClassId": "642aa4c7-19aa-45ed-ba06-aa1ae6c9edf7", "idName": "hueBridge", "name": "Hue gateway", + "deviceIcon": "Gateway", "basicTags": [ "Device", "Gateway", @@ -118,6 +119,7 @@ "deviceClassId": "0edba26c-96ab-44fb-a6a2-c0574d19630e", "idName": "hueLight", "name": "Hue Light", + "deviceIcon": "LightBulb", "basicTags": [ "Device", "Lighting", @@ -251,6 +253,7 @@ "deviceClassId": "4fa568ef-7a3a-422b-b0c0-206d37cb4eed", "idName": "hueWhiteLight", "name": "Hue White Light", + "deviceIcon": "LightBulb", "basicTags": [ "Device", "Actuator", @@ -352,6 +355,7 @@ "deviceClassId": "bb482d39-67ef-46dc-88e9-7b181d642b28", "idName": "hueRemote", "name": "Hue Remote", + "deviceIcon": "Switch", "basicTags": [ "Device", "Sensor" diff --git a/plugins/deviceplugins/udpcommander/devicepluginudpcommander.json b/plugins/deviceplugins/udpcommander/devicepluginudpcommander.json index f8ecc7a7..611b3afc 100644 --- a/plugins/deviceplugins/udpcommander/devicepluginudpcommander.json +++ b/plugins/deviceplugins/udpcommander/devicepluginudpcommander.json @@ -11,6 +11,7 @@ { "deviceClassId": "6ecd5a8d-595a-4520-85e3-dcc9679edf66", "name": "UDP Commander", + "deviceIcon": "Network", "basicTags": [ "Service", "Sensor" diff --git a/plugins/deviceplugins/unitec/devicepluginunitec.json b/plugins/deviceplugins/unitec/devicepluginunitec.json index 384bbce2..652159ea 100644 --- a/plugins/deviceplugins/unitec/devicepluginunitec.json +++ b/plugins/deviceplugins/unitec/devicepluginunitec.json @@ -11,6 +11,7 @@ { "deviceClassId": "8468a15d-ecc0-43b6-98ca-e1e4ac9e2df3", "name": "Unitec switch (48111)", + "deviceIcon": "Switch", "basicTags": [ "Device", "Actuator" diff --git a/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json b/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json index ddd86c86..8d859044 100644 --- a/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json +++ b/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json @@ -11,6 +11,7 @@ { "deviceClassId": "3c8f2447-dcd0-4882-8c09-99e579e4d24c", "name": "Wake On Lan", + "deviceIcon": "Network", "basicTags": [ "Device", "Actuator" diff --git a/plugins/deviceplugins/wemo/devicepluginwemo.json b/plugins/deviceplugins/wemo/devicepluginwemo.json index 7837fb13..1eb65b58 100644 --- a/plugins/deviceplugins/wemo/devicepluginwemo.json +++ b/plugins/deviceplugins/wemo/devicepluginwemo.json @@ -12,6 +12,7 @@ "deviceClassId": "69d97d3b-a8e6-42f3-afc0-ca8a53eb7cce", "idName": "wemoSwitch", "name": "WeMo Switch", + "deviceIcon": "Socket", "basicTags": [ "Device", "Actuator" diff --git a/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json b/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json index 17a2a279..cc6b4c2e 100644 --- a/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json +++ b/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json @@ -12,6 +12,7 @@ "deviceClassId": "bd216356-f1ec-4324-9785-6982d2174e17", "name": "WiFi Device", "idName": "wifi", + "deviceIcon": "Network", "basicTags": [ "Device", "Sensor" diff --git a/server/jsonrpc/jsontypes.cpp b/server/jsonrpc/jsontypes.cpp index ce0637e2..95ff0040 100644 --- a/server/jsonrpc/jsontypes.cpp +++ b/server/jsonrpc/jsontypes.cpp @@ -81,13 +81,13 @@ void JsonTypes::init() { // BasicTypes s_basicType = enumToStrings(JsonTypes::staticMetaObject, "BasicType"); - s_basicTag = enumToStrings(DeviceClass::staticMetaObject, "BasicTag"); s_stateOperator = enumToStrings(Types::staticMetaObject, "StateOperator"); s_valueOperator = enumToStrings(Types::staticMetaObject, "ValueOperator"); s_inputType = enumToStrings(Types::staticMetaObject, "InputType"); s_unit = enumToStrings(Types::staticMetaObject, "Unit"); s_createMethod = enumToStrings(DeviceClass::staticMetaObject, "CreateMethod"); s_setupMethod = enumToStrings(DeviceClass::staticMetaObject, "SetupMethod"); + s_basicTag = enumToStrings(DeviceClass::staticMetaObject, "BasicTag"); s_deviceIcon = enumToStrings(DeviceClass::staticMetaObject, "DeviceIcon"); s_removePolicy = enumToStrings(RuleEngine::staticMetaObject, "RemovePolicy"); s_deviceError = enumToStrings(DeviceManager::staticMetaObject, "DeviceError"); @@ -193,6 +193,7 @@ void JsonTypes::init() s_deviceClass.insert("vendorId", basicTypeToString(Uuid)); s_deviceClass.insert("pluginId", basicTypeToString(Uuid)); s_deviceClass.insert("name", basicTypeToString(String)); + s_deviceClass.insert("deviceIcon", deviceIconRef()); s_deviceClass.insert("basicTags", QVariantList() << basicTagRef()); s_deviceClass.insert("stateTypes", QVariantList() << stateTypeRef()); s_deviceClass.insert("eventTypes", QVariantList() << eventTypeRef()); @@ -529,6 +530,7 @@ QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass) variant.insert("id", deviceClass.id()); variant.insert("vendorId", deviceClass.vendorId()); variant.insert("pluginId", deviceClass.pluginId()); + variant.insert("deviceIcon", s_deviceIcon.at(deviceClass.deviceIcon())); QVariantList basicTags; foreach (const DeviceClass::BasicTag &basicTag, deviceClass.basicTags()) { diff --git a/tests/auto/api.json b/tests/auto/api.json index 8158a38c..abaf5909 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -1,4 +1,4 @@ -36 +37 { "methods": { "Actions.ExecuteAction": { @@ -595,6 +595,7 @@ "createMethods": [ "$ref:CreateMethod" ], + "deviceIcon": "$ref:DeviceIcon", "discoveryParamTypes": [ "$ref:ParamType" ], @@ -644,6 +645,42 @@ "DeviceErrorPairingTransactionIdNotFound", "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": { "deviceId": "Uuid", "eventTypeId": "Uuid", @@ -879,7 +916,15 @@ "UnitPercentage", "UnitPartsPerMillion", "UnitEuro", - "UnitDollar" + "UnitDollar", + "UnitHerz", + "UnitAmpere", + "UnitMilliAmpere", + "UnitVolt", + "UnitMilliVolt", + "UnitVoltAmpere", + "UnitVoltAmpereReactive", + "UnitAmpereHour" ], "ValueOperator": [ "ValueOperatorEquals",