From f08cd6b09f666446314d094cf6022b07ca44ce8e Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Fri, 25 Jun 2021 13:44:55 +0200 Subject: [PATCH] Add a getter method for thing classes to plugin api --- libnymea/integrations/integrationplugin.cpp | 11 +++++++++++ libnymea/integrations/integrationplugin.h | 1 + nymea.pro | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libnymea/integrations/integrationplugin.cpp b/libnymea/integrations/integrationplugin.cpp index f034bc05..fe80b1f3 100644 --- a/libnymea/integrations/integrationplugin.cpp +++ b/libnymea/integrations/integrationplugin.cpp @@ -152,6 +152,17 @@ ThingClasses IntegrationPlugin::supportedThings() const return m_metaData.thingClasses(); } +/*! Returns a \l{ThingClass}{ThingClass} for the given \a thingClassId */ +ThingClass IntegrationPlugin::thingClass(const ThingClassId &thingClassId) const +{ + foreach (const ThingClass &thingClass, supportedThings()) { + if (thingClass.id() == thingClassId) { + return thingClass; + } + } + return ThingClass(); +} + /*! Override this if your plugin supports things with ThingClass::CreationMethodAuto. This will be called at startup, after the configured things have been loaded. This is the earliest time you should start emitting autoThingsAppeared(). If you diff --git a/libnymea/integrations/integrationplugin.h b/libnymea/integrations/integrationplugin.h index 81555729..271818c2 100644 --- a/libnymea/integrations/integrationplugin.h +++ b/libnymea/integrations/integrationplugin.h @@ -93,6 +93,7 @@ public: QString pluginDisplayName() const; Vendors supportedVendors() const; ThingClasses supportedThings() const; + ThingClass thingClass(const ThingClassId &thingClassId) const; virtual void startMonitoringAutoThings(); virtual void discoverThings(ThingDiscoveryInfo *info); diff --git a/nymea.pro b/nymea.pro index f51820af..44b245e1 100644 --- a/nymea.pro +++ b/nymea.pro @@ -8,7 +8,7 @@ JSON_PROTOCOL_VERSION_MAJOR=5 JSON_PROTOCOL_VERSION_MINOR=5 JSON_PROTOCOL_VERSION="$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}" LIBNYMEA_API_VERSION_MAJOR=7 -LIBNYMEA_API_VERSION_MINOR=0 +LIBNYMEA_API_VERSION_MINOR=1 LIBNYMEA_API_VERSION_PATCH=0 LIBNYMEA_API_VERSION="$${LIBNYMEA_API_VERSION_MAJOR}.$${LIBNYMEA_API_VERSION_MINOR}.$${LIBNYMEA_API_VERSION_PATCH}"