From 48095b2cedf9ffdd65029d6bce457f9ecb50e32d Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 31 May 2022 17:17:52 +0200 Subject: [PATCH] Print a better warning when setStateValue() is called with a wrong name --- libnymea/integrations/thing.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libnymea/integrations/thing.cpp b/libnymea/integrations/thing.cpp index 36450d9b..3b751962 100644 --- a/libnymea/integrations/thing.cpp +++ b/libnymea/integrations/thing.cpp @@ -423,6 +423,11 @@ void Thing::setStateValue(const StateTypeId &stateTypeId, const QVariant &value) void Thing::setStateValue(const QString &stateName, const QVariant &value) { StateTypeId stateTypeId = m_thingClass.stateTypes().findByName(stateName).id(); + if (stateTypeId.isNull()) { + qCWarning(dcThing()) << "No such state" << stateName << "in" << m_name << "(" + thingClass().name() + ")"; + return; + } + setStateValue(stateTypeId, value); }