From bfd008854a4ae18745113816d01746c26b34a567 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 29 Mar 2020 01:08:26 +0100 Subject: [PATCH] Fix interfaces handling --- libnymea-app/devicemanager.cpp | 1 - libnymea-app/types/interfaces.cpp | 344 +++++++++++------- libnymea-app/types/interfaces.h | 1 + .../ui/mainviews/DevicesPageDelegate.qml | 18 +- 4 files changed, 225 insertions(+), 139 deletions(-) diff --git a/libnymea-app/devicemanager.cpp b/libnymea-app/devicemanager.cpp index 5dff3ed2..089906a6 100644 --- a/libnymea-app/devicemanager.cpp +++ b/libnymea-app/devicemanager.cpp @@ -135,7 +135,6 @@ void DeviceManager::addDevice(const QUuid &deviceClassId, const QString &name, c void DeviceManager::notificationReceived(const QVariantMap &data) { QString notification = data.value("notification").toString(); - qDebug() << "*** Notification received:" << notification; if (notification == "Devices.StateChanged") { // qDebug() << "Device state changed" << data.value("params"); Device *dev = m_devices->getDevice(data.value("params").toMap().value("deviceId").toUuid()); diff --git a/libnymea-app/types/interfaces.cpp b/libnymea-app/types/interfaces.cpp index b469ec20..7ada9468 100644 --- a/libnymea-app/types/interfaces.cpp +++ b/libnymea-app/types/interfaces.cpp @@ -46,172 +46,246 @@ Interfaces::Interfaces(QObject *parent) : QAbstractListModel(parent) { ParamTypes *pts = nullptr; - addInterface("battery", tr("Battery powered devices")); - addStateType("battery", "batteryCritical", QVariant::Bool, false, - tr("Battery level is critical"), - tr("Battery level entered critical state")); + addInterface("accesscontrol", tr("Access control systems")); + addEventType("accesscontrol", "accessGranted", tr("Access granted"), new ParamTypes()); + addEventType("accesscontrol", "accessDenied", tr("Access denied"), new ParamTypes()); + addInterface("connectable", tr("Connectable things")); + addStateType("connectable", "connected", QVariant::Bool, false, tr("Connected"), tr("Connected changed")); - addInterface("notifications", tr("Notification services")); - pts = createParamTypes("title", tr("Title"), QVariant::String); - addParamType(pts, "body", tr("Message body"), QVariant::String); - addActionType("notifications", "notify", tr("Send notification"), pts); + addInterface("gateway", tr("Gateways"), {"connectable"}); - addInterface("power", tr("Powered things")); - addStateType("power", "power", QVariant::Bool, true, - tr("Thing is turned on"), - tr("A thing is turned on or off"), - tr("Turn things on or off")); + addInterface("account", tr("Accounts"), {"gateway"}); + addStateType("account", "loggedIn", QVariant::Bool, false, tr("User is logged in"), tr("User login changed")); - addInterface("light", tr("Lights")); - addStateType("light", "power", QVariant::Bool, true, - tr("Light is turned on"), - tr("A light is turned on or off"), - tr("Turn lights on or off")); + addInterface("alert", tr("Alert")); + addActionType("alert", "alert", tr("Alert"), new ParamTypes()); - addInterface("dimmablelight", tr("Dimmable lights"), {"light"}); - addStateType("dimmablelight", "brightness", QVariant::Int, true, - tr("Light's brightness is"), - tr("A light's brightness has changed"), - tr("Set lights brightness"), 0, 100); - - addInterface("colortemperaturelight", tr("Color temperature light"), {"light", "dimmablelight"}); - addStateType("colortemperaturelight", "colorTemperature", QVariant::Int, true, - tr("Lights color temperature is"), - tr("A lights color temperature has changed"), - tr("Set lights color temperature"), 0, 100); - - addInterface("colorlight", tr("Color lights"), {"light", "dimmablelight", "colortemperaturelight"}); - addStateType("colorlight", "color", QVariant::Color, true, - tr("Light's color is"), - tr("A light's color has changed"), - tr("Set lights color")); - - addInterface("temperaturesensor", tr("Temperature sensors")); - addStateType("temperaturesensor", "temperature", QVariant::Double, false, - tr("Temperature"), - tr("Temperature has changed")); - - addInterface("simpleclosable", tr("Closable things")); + addInterface("simpleclosable", tr("Simple closables")); + addActionType("simpleclosable", "open", tr("Open"), new ParamTypes()); addActionType("simpleclosable", "close", tr("Close"), new ParamTypes()); - addInterface("presencesensor", tr("Presence sensors")); - addStateType("presencesensor", "isPresent", QVariant::Bool, false, - tr("Is present"), - tr("Presence changed")); + addInterface("closable", tr("Closables"), {"simpleclosable"}); + addActionType("closable", "stop", tr("Stop"), new ParamTypes()); - addInterface("blind", tr("Blinds")); - addActionType("blind", "close", tr("Close"), new ParamTypes()); - addActionType("blind", "open", tr("Open"), new ParamTypes()); + addInterface("awning", tr("Awnings"), {"closable"}); - addInterface("awning", tr("Awnings")); - addActionType("awning", "close", tr("Close"), new ParamTypes()); - addActionType("awning", "open", tr("Open"), new ParamTypes()); + addInterface("barcodescanner", tr("Barcode scanners")); + pts = createParamTypes("content", tr("Content"), QVariant::String); + addEventType("barcodescanner", "codeScanned", tr("Code scanned"), pts); - addInterface("shutter", tr("Shutters")); - addActionType("shutter", "close", tr("Close"), new ParamTypes()); - addActionType("shutter", "open", tr("Open"), new ParamTypes()); + addInterface("battery", tr("Battery powered devices")); + addStateType("battery", "batteryCritical", QVariant::Bool, false, tr("Battery level is critical"), tr("Battery level entered critical state")); - addInterface("garagegate", tr("Garage gates")); - addActionType("garagegate", "close", tr("Close"), new ParamTypes()); - addActionType("garagegate", "open", tr("Open"), new ParamTypes()); + addInterface("batterylevel", tr("Battery powered devices"), {"battery"}); + addStateType("batterylevel", "batteryLevel", QVariant::Int, false, tr("Battery level"), tr("Battery level changed"), QString(), 0, 100); - addInterface("co2sensor", tr("Air sensors")); - addStateType("co2sensor", "co2", QVariant::Double, false, - tr("Air quality"), - tr("Air quality changed")); + addInterface("blind", tr("Blinds"), {"closable"}); - addInterface("humiditysensor", tr("Humidity sensors")); - addStateType("humiditysensor", "humidity", QVariant::Double, false, - tr("Humidity"), - tr("Humidity changed")); + addInterface("button", tr("Switches")); + addEventType("button", "pressed", tr("Button pressed"), new ParamTypes()); - addInterface("daylightsensor", tr("Daylight sensors")); - addStateType("daylightsensor", "daylight", QVariant::Bool, false, - tr("Daylight"), - tr("Daylight changed")); + addInterface("sensor", tr("Sensor")); - addInterface("lightsensor", tr("Light intensity sensors")); - addStateType("lightsensor", "lightIntensity", QVariant::Bool, false, - tr("Light intensity"), - tr("Light intensity changed")); + addInterface("closablesensor", tr("Closable sensors"), {"sensor"}); + addStateType("closablesensor", "closed", QVariant::Bool, false, tr("Closed"), tr("Opened or closed")); + + addInterface("co2sensor", tr("CO2 sensor"), {"sensor"}); + addStateType("co2sensor", "co2", QVariant::Double, false, tr("CO2 level"), tr("CO2 level changed")); + + addInterface("power", tr("Powered things")); + addStateType("power", "power", QVariant::Bool, true, tr("Thing is turned on"), tr("A thing is turned on or off"), tr("Turn things on or off")); + + addInterface("light", tr("Lights")); + addStateType("light", "power", QVariant::Bool, true, tr("Light is turned on"), tr("A light is turned on or off"), tr("Turn lights on or off")); + + addInterface("dimmablelight", tr("Dimmable lights"), {"light"}); + addStateType("dimmablelight", "brightness", QVariant::Int, true, tr("Light's brightness is"), tr("A light's brightness has changed"), tr("Set lights brightness"), 0, 100); + + addInterface("colortemperaturelight", tr("Color temperature light"), {"light", "dimmablelight"}); + addStateType("colortemperaturelight", "colorTemperature", QVariant::Int, true, tr("Lights color temperature is"), tr("A lights color temperature has changed"), tr("Set lights color temperature"), 0, 100); + + addInterface("colorlight", tr("Color lights"), {"light", "dimmablelight", "colortemperaturelight"}); + addStateType("colorlight", "color", QVariant::Color, true, tr("Light's color is"), tr("A light's color has changed"), tr("Set lights color")); + + addInterface("conductivitysensor", tr("Conductivity sensors"), {"sensor"}); + addStateType("conductivitysensor", "conductivity", QVariant::Double, false, tr("Conductivity"), tr("Conductivity changed")); + + addInterface("daylightsensor", tr("Daylight sensors"), {"sensor"}); + addStateType("daylightsensor", "daylight", QVariant::Bool, false, tr("Daylight"), tr("Daylight changed")); + + addInterface("doorbell", tr("Doorbells")); + addEventType("doorbell", "doorbellPressed", tr("Doorbell pressed"), new ParamTypes()); addInterface("evcharger", tr("EV charger")); - addStateType("evcharger", "power", QVariant::Bool, true, - tr("Charging"), - tr("Charging changed"), - tr("Enable charging")); + addStateType("evcharger", "power", QVariant::Bool, true, tr("Charging"), tr("Charging changed"), tr("Enable charging")); - addInterface("volumecontroller", tr("Speakers")); - addActionType("volumecontroller", "increaseVolume", tr("Increase volume"), new ParamTypes()); - addActionType("volumecontroller", "decreaseVolume", tr("Decrease volume"), new ParamTypes()); + addInterface("extendedclosable", tr("Closable things"), {"closable"}); + addStateType("extendedclosable", "moving", QVariant::Bool, false, tr("Moving"), tr("Moving changed")); - addInterface("gateway", tr("Gateways")); - addStateType("gateway", "connected", QVariant::Bool, false, - tr("Connected"), - tr("Connected changed")); + addInterface("extendedawning", tr("Awnings"), {"awning", "extendedclosable"}); + + addInterface("extendedblind", tr("Blinds"), {"blind", "extendedclosable"}); + + addInterface("extendedevcharger", tr("EV chargers"), {"evcharger"}); + addStateType("extendedevcharger", "maxChargingCurrent", QVariant::UInt, true, tr("Maximum charging current"), tr("Maximum charging current changed"), tr("Set maximum charging current")); addInterface("heating", tr("Heatings")); - addStateType("heating", "power", QVariant::Bool, true, - tr("Heating enabled"), - tr("Heating enabled changed"), - tr("Enable heating")); + addStateType("heating", "power", QVariant::Bool, true, tr("Heating enabled"), tr("Heating enabled changed"), tr("Enable heating")); - addInterface("mediaplayer", tr("Media players")); - addStateType("mediaplayer", "playbackStatus", QVariant::String, true, - tr("Playback status"), - tr("Playback status changed"), - tr("Set playback status")); + addInterface("extendedheating", tr("Heatings"), {"heating"}); + addStateType("extendedheating", "percentage", QVariant::Int, true, tr("Percentage"), tr("Percentage changed"), tr("Set percentage"), 0, 100); - addInterface("mediacontroller", tr("Media controllers")); + addInterface("media", tr("Media")); + + addInterface("mediacontroller", tr("Media controllers"), {"media"}); addActionType("mediacontroller", "play", tr("Start playback"), new ParamTypes()); addActionType("mediacontroller", "stop", tr("Stop playback"), new ParamTypes()); addActionType("mediacontroller", "pause", tr("Pause playback"), new ParamTypes()); addActionType("mediacontroller", "skipBack", tr("Skip back"), new ParamTypes()); addActionType("mediacontroller", "skipNext", tr("Skip next"), new ParamTypes()); - addInterface("powersocket", tr("Power sockets")); - addStateType("powersocket", "power", QVariant::Bool, true, - tr("Powered"), - tr("Turned on/off"), - tr("Turn on/off")); + addInterface("extendedmediacontroller", tr("Media controllers"), {"mediacontroller"}); + addActionType("extendedmediacontroller", "fastForward", tr("Fast forward"), new ParamTypes()); + addActionType("extendedmediacontroller", "fastRewind", tr("Fast rewind"), new ParamTypes()); - addInterface("weather", tr("Weather")); - addStateType("weather", "weatherCondition", QVariant::String, false, - tr("Weather description"), - tr("Weather description changed")); - addStateType("weather", "weatherDescription", QVariant::String, false, - tr("Weather condition"), - tr("Weather condition changed")); - addStateType("weather", "temperature", QVariant::Double, false, - tr("Temperature"), - tr("Temperature changed")); - addStateType("weather", "humidity", QVariant::Double, false, - tr("Humidity"), - tr("Humidity changed")); - addStateType("weather", "humidity", QVariant::Double, false, - tr("Pressure"), - tr("Pressure changed")); - addStateType("weather", "windSpeed", QVariant::Double, false, - tr("Wind seed"), - tr("Wind speed changed")); - addStateType("weather", "windDirection", QVariant::Int, false, - tr("Wind direction"), - tr("Wind direction changed")); + addInterface("navigationpad", tr("Navigation pad")); + pts = createParamTypes("to", tr("To"), QVariant::String, QVariant(), {"up", "down", "left", "right", "enter", "back", "menu", "info", "home"}); + addActionType("navigationpad", "navigate", tr("Navigate"), pts); - addInterface("media", tr("Media")); + addInterface("extendednavigationpad", tr("Navigation pad")); + pts = createParamTypes("to", tr("To"), QVariant::String, QVariant(), {"up", "down", "left", "right", "enter", "back", "menu", "info", "home"}); + addActionType("extendednavigationpad", "navigate", tr("Navigate"), pts); - addInterface("sensor", tr("Sensor")); + addInterface("shutter", tr("Shutters"), {"simpleclosable"}); + + addInterface("extendedshutter", tr("Shutters"), {"shutter", "extendedclosable"}); addInterface("smartmeter", tr("Smart meter")); - addInterface("button", tr("Button")); - addEventType("button", "pressed", tr("Button pressed"), new ParamTypes()); + addInterface("smartmeterconsumer", tr("Smart meters"), {"smartmeter"}); + addStateType("smartmeterconsumer", "totalEnergyConsumed", QVariant::Double, false, tr("Total energy consumed"), tr("Total energy consumed changed")); + + addInterface("extendedsmartmeterconsumer", tr("Smart meters"), {"smartmeterconsumer"}); + addStateType("extendedsmartmeterconsumer", "currentPower", QVariant::Double, false, tr("Current power"), tr("Current power changed")); + + addInterface("smartmeterproducer", tr("Smart meters"), {"smartmeter"}); + addStateType("smartmeterproducer", "totalEnergyProduced", QVariant::Double, false, tr("Total energy producedd"), tr("Total energy produced changed")); + + addInterface("extendedsmartmeterproducer", tr("Smart meters"), {"smartmeterproducer"}); + addStateType("extendedsmartmeterproducer", "currentPower", QVariant::Double, false, tr("Current power"), tr("Current power changed")); + + addInterface("extendedvolumecontroller", tr("Volume control"), {"media"}); + addStateType("extendedvolumecontroller", "mute", QVariant::Bool, true, tr("Mute"), tr("Muted"), tr("Mute")); + addStateType("extendedvolumecontroller", "volume", QVariant::Bool, true, tr("Volume"), tr("Volume changed"), tr("Set volume"), 0, 100); + + addInterface("useraccesscontrol", tr("User access control systems"), {"accesscontrol"}); + addStateType("useraccesscontrol", "users", QVariant::StringList, false, tr("Users"), tr("Users changed")); + pts = createParamTypes("user", tr("User"), QVariant::String); + addEventType("useraccesscontrol", "accessGranted", tr("Access granted"), pts); + pts = createParamTypes("user", tr("User"), QVariant::String); + addActionType("useraccesscontrol", "addUser", tr("Add user"), pts); + pts = createParamTypes("user", tr("User"), QVariant::String); + addActionType("useraccesscontrol", "removeUser", tr("Remove user"), pts); + + addInterface("fingerprintreader", tr("Fingerprint readers"), {"useraccesscontrol"}); + addStateType("useraccesscontrol", "users", QVariant::StringList, false, tr("Users"), tr("Users changed")); + pts = createParamTypes("user", tr("User"), QVariant::String); + addParamType(pts, "finger", tr("Finger"), QVariant::String); + addEventType("useraccesscontrol", "accessGranted", tr("Access granted"), pts); + pts = createParamTypes("user", tr("User"), QVariant::String); + addParamType(pts, "finger", tr("Finger"), QVariant::String); + addActionType("useraccesscontrol", "addUser", tr("Add user"), pts); + pts = createParamTypes("user", tr("User"), QVariant::String); + addActionType("useraccesscontrol", "removeUser", tr("Remove user"), pts); + + addInterface("garagegate", tr("Garage doors"), {"closable"}); + addStateType("garagegate", "state", QVariant::String, false, tr("State"), tr("State changed")); + addStateType("garagegate", "intermediatePosition", QVariant::Bool, false, tr("Intermediate position"), tr("Intermediate position changed")); + + addInterface("humiditysensor", tr("Humidity sensors"), {"sensor"}); + addStateType("humiditysensor", "humidity", QVariant::Double, false, tr("Humidity"), tr("Humidity changed")); + + addInterface("inputtrigger", tr("Incoming events")); + addEventType("inputtrigger", "triggered", tr("Triggered"), new ParamTypes()); + + addInterface("lightsensor", tr("Light sensors"), {"sensor"}); + addStateType("lightsensor", "lightIntensity", QVariant::Double, false, tr("Light intensity"), tr("Light intensity changed")); + + addInterface("longpressbutton", tr("Buttons"), {"button"}); + addEventType("longpressbutton", "longPressed", tr("Long pressed"), new ParamTypes()); + + addInterface("mediametadataprovider", tr("Media sources"), {"media"}); + addStateType("mediametadataprovider", "title", QVariant::String, false, tr("Title"), tr("Title changed")); + addStateType("mediametadataprovider", "artist", QVariant::String, false, tr("Artist"), tr("Artist changed")); + addStateType("mediametadataprovider", "collection", QVariant::String, false, tr("Collection"), tr("Collection changed")); + addStateType("mediametadataprovider", "artwork", QVariant::String, false, tr("Artwork"), tr("Artwork changed")); + + addInterface("mediaplayer", tr("Media players"), {"media"}); + addStateType("mediaplayer", "playbackStatus", QVariant::String, true, tr("Playback status"), tr("Playback status changed"), tr("Set playback status")); + + addInterface("moisturesensor", tr("Moisture sensors"), {"sensor"}); + addStateType("moisturesensor", "moisture", QVariant::Double, false, tr("Moisture"), tr("Moisture changed")); + + addInterface("multibutton", tr("Switches"), {"button"}); + pts = createParamTypes("buttonName", tr("Button name"), QVariant::String); + addEventType("multibutton", "pressed", tr("Pressed"), pts); + + addInterface("noisesensor", tr("Noise sensors"), {"sensor"}); + addStateType("noisesensor", "noise", QVariant::Double, false, tr("Noise level"), tr("Noise level changed")); + + addInterface("notifications", tr("Notification services")); + pts = createParamTypes("title", tr("Title"), QVariant::String); + addParamType(pts, "body", tr("Message body"), QVariant::String); + addActionType("notifications", "notify", tr("Send notification"), pts); + + addInterface("outputtrigger", tr("Outgoing events")); + addActionType("outputtrigger", "trigger", tr("Trigger"), new ParamTypes()); + + addInterface("powersocket", tr("Power sockets")); + addStateType("powersocket", "power", QVariant::Bool, true, tr("Powered"), tr("Turned on/off"), tr("Turn on/off")); + + addInterface("powerswitch", tr("Power switches"), {"button", "power"}); + + addInterface("presencesensor", tr("Presence sensors"), {"sensor"}); + addStateType("presencesensor", "isPresent", QVariant::Bool, false, tr("Is present"), tr("Presence changed")); + + addInterface("pressuresensor", tr("Pressure sensors"), {"sensor"}); + addStateType("pressuresensor", "pressure", QVariant::Double, false, tr("Pressure"), tr("Pressure changed")); + + addInterface("shufflerepeat", tr("Media player")); + addStateType("shufflerepeat", "shuffle", QVariant::Bool, true, tr("Shuffle"), tr("Shuffle changed"), tr("Set shuffle")); + addStateType("shufflerepeat", "repeat", QVariant::Bool, true, tr("Repeat"), tr("Repeat changed"), tr("Set repeat")); + + addInterface("smartlock", tr("Smart locks")); + addStateType("smartlock", "state", QVariant::String, false, tr("State"), tr("State changed")); + addActionType("smartlock", "unlatch", tr("Unlatch"), new ParamTypes()); + + addInterface("temperaturesensor", tr("Temperature sensors"), {"sensor"}); + addStateType("temperaturesensor", "temperature", QVariant::Double, false, tr("Temperature"), tr("Temperature has changed")); + + addInterface("thermostat", tr("Thermostats")); + addStateType("thermostat", "targetTemperature", QVariant::Double, true, tr("Target temperature"), tr("Target temperature changed"), tr("Set target temperature")); + + addInterface("volumecontroller", tr("Speakers")); + addActionType("volumecontroller", "increaseVolume", tr("Increase volume"), new ParamTypes()); + addActionType("volumecontroller", "decreaseVolume", tr("Decrease volume"), new ParamTypes()); + + addInterface("weather", tr("Weather")); + addStateType("weather", "weatherCondition", QVariant::String, false, tr("Weather description"), tr("Weather description changed")); + addStateType("weather", "weatherDescription", QVariant::String, false, tr("Weather condition"), tr("Weather condition changed")); + addStateType("weather", "temperature", QVariant::Double, false, tr("Temperature"), tr("Temperature changed")); + addStateType("weather", "humidity", QVariant::Double, false, tr("Humidity"), tr("Humidity changed")); + addStateType("weather", "humidity", QVariant::Double, false, tr("Pressure"), tr("Pressure changed")); + addStateType("weather", "windSpeed", QVariant::Double, false, tr("Wind seed"), tr("Wind speed changed")); + addStateType("weather", "windDirection", QVariant::Int, false, tr("Wind direction"), tr("Wind direction changed")); + + addInterface("windspeedsensor", tr("Wind speed sensors"), {"sensor"}); + addStateType("windspeedsensor", "windSpeed", QVariant::Double, false, tr("Wind speed"), tr("Wind speed change")); + + addInterface("wirelessconnectable", tr("Wireless devices"), {"connectable"}); + addStateType("wirelessconnectable", "signalStrength", QVariant::UInt, false, tr("Signal strength"), tr("Signal strength changed")); - addInterface("account", tr("Accounts"), {"gateway"}); - addStateType("account", "loggedIn", QVariant::Bool, false, - tr("User is logged in"), - tr("User login changed")); } int Interfaces::rowCount(const QModelIndex &parent) const @@ -348,6 +422,16 @@ ParamTypes *Interfaces::createParamTypes(const QString &name, const QString &dis return pts; } +ParamTypes *Interfaces::createParamTypes(const QString &name, const QString &displayName, QVariant::Type type, const QVariant &defaultValue, const QVariantList &allowedValues) +{ + ParamTypes *pts = new ParamTypes(); + ParamType *pt = new ParamType(name, type, defaultValue); + pt->setDisplayName(displayName); + pt->setAllowedValues(allowedValues); + pts->addParamType(pt); + return pts; +} + void Interfaces::addParamType(ParamTypes *paramTypes, const QString &name, const QString &displayName, QVariant::Type type, const QVariant &defaultValue, const QVariant &minValue, const QVariant &maxValue) { ParamType *pt = new ParamType(name, type, defaultValue); diff --git a/libnymea-app/types/interfaces.h b/libnymea-app/types/interfaces.h index 14c05f14..23b666e6 100644 --- a/libnymea-app/types/interfaces.h +++ b/libnymea-app/types/interfaces.h @@ -70,6 +70,7 @@ private: void addStateType(const QString &interfaceName, const QString &name, QVariant::Type type, bool writable, const QString &displayName, const QString &displayNameEvent, const QString &displayNameAction = QString(), const QVariant &min = QVariant(), const QVariant &max = QVariant()); ParamTypes* createParamTypes(const QString &name, const QString &displayName, QVariant::Type type, const QVariant &defaultValue = QVariant(), const QVariant &minValue = QVariant(), const QVariant &maxValue = QVariant()); + ParamTypes* createParamTypes(const QString &name, const QString &displayName, QVariant::Type type, const QVariant &defaultValue, const QVariantList &allowedValues); void addParamType(ParamTypes* paramTypes, const QString &name, const QString &displayName, QVariant::Type type, const QVariant &defaultValue = QVariant(), const QVariant &minValue = QVariant(), const QVariant &maxValue = QVariant()); }; diff --git a/nymea-app/ui/mainviews/DevicesPageDelegate.qml b/nymea-app/ui/mainviews/DevicesPageDelegate.qml index 95764ad3..9bc80340 100644 --- a/nymea-app/ui/mainviews/DevicesPageDelegate.qml +++ b/nymea-app/ui/mainviews/DevicesPageDelegate.qml @@ -37,8 +37,8 @@ import "../components" MainPageTile { id: root - text: interfaceToString(iface.name).toUpperCase() - iconName: interfaceToIcon(iface.name) + text: iface ? iface.displayName.toUpperCase() : qsTr("uncategorized").toUpperCase() + iconName: iface ? interfaceToIcon(iface.name) : interfaceToIcon("uncategorized") iconColor: app.accentColor disconnected: devicesSubProxyConnectables.count > 0 batteryCritical: devicesSubProxyBattery.count > 0 @@ -50,6 +50,12 @@ MainPageTile { onClicked: { var page; + if (!iface) { + page = "GenericDeviceListPage.qml" + pageStack.push(Qt.resolvedUrl("../devicelistpages/" + page), {hiddenInterfaces: app.supportedInterfaces, filterTagId: root.filterTagId}) + return; + } + switch (iface.name) { case "heating": case "sensor": @@ -88,12 +94,8 @@ MainPageTile { default: page = "GenericDeviceListPage.qml" } - if (iface.name === "uncategorized") { - pageStack.push(Qt.resolvedUrl("../devicelistpages/" + page), {hiddenInterfaces: app.supportedInterfaces, filterTagId: root.filterTagId}) - } else { - print("