From d293a03cc1b2664b3d4fec31d906dcee875fc525 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 21 Apr 2024 21:31:45 +0200 Subject: [PATCH] Check value set --- NukiOpenerWrapper.cpp | 12 ++++++++++++ NukiWrapper.cpp | 12 ++++++++++++ README.md | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/NukiOpenerWrapper.cpp b/NukiOpenerWrapper.cpp index e8fff1c..aa8eae1 100644 --- a/NukiOpenerWrapper.cpp +++ b/NukiOpenerWrapper.cpp @@ -749,6 +749,12 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value) if(json[basicKeys[i]]) { const char *jsonchar = json[basicKeys[i]].as(); + + if(strlen(jsonchar) == 0) + { + jsonResult[basicKeys[i]] = "noValueSet"; + continue; + } if((int)basicOpenerConfigAclPrefs[i] == 1) { @@ -924,6 +930,12 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value) if(json[advancedKeys[i]]) { const char *jsonchar = json[advancedKeys[i]].as(); + + if(strlen(jsonchar) == 0) + { + jsonResult[advancedKeys[i]] = "noValueSet"; + continue; + } if((int)advancedOpenerConfigAclPrefs[i] == 1) { diff --git a/NukiWrapper.cpp b/NukiWrapper.cpp index a9b4f0f..83be572 100644 --- a/NukiWrapper.cpp +++ b/NukiWrapper.cpp @@ -686,6 +686,12 @@ void NukiWrapper::onConfigUpdateReceived(const char *value) if(json[basicKeys[i]]) { const char *jsonchar = json[basicKeys[i]].as(); + + if(strlen(jsonchar) == 0) + { + jsonResult[basicKeys[i]] = "noValueSet"; + continue; + } if((int)basicLockConfigAclPrefs[i] == 1) { @@ -883,6 +889,12 @@ void NukiWrapper::onConfigUpdateReceived(const char *value) if(json[advancedKeys[i]]) { const char *jsonchar = json[advancedKeys[i]].as(); + + if(strlen(jsonchar) == 0) + { + jsonResult[advancedKeys[i]] = "noValueSet"; + continue; + } if((int)advancedLockConfigAclPrefs[i] == 1) { diff --git a/README.md b/README.md index 56d952f..5124bc3 100644 --- a/README.md +++ b/README.md @@ -378,7 +378,7 @@ The result of the last configuration change action will be published to the `con
The JSON data will include a node called "general" and a node for every setting that Nuki Hub detected in the action.
Possible values for the "general" node are "noPinSet", "invalidJson", "invalidConfig", "success" and "noChange".
-Possible values for the node per setting are "unchanged", "invalidValue", "valueTooLong", "accessDenied", "success", "failed", "timeOut", "working", "notPaired", "error" and "undefined"
+Possible values for the node per setting are "unchanged", "noValueSet", "invalidValue", "valueTooLong", "accessDenied", "success", "failed", "timeOut", "working", "notPaired", "error" and "undefined"

Example: - `{"advertisingMode":"success","general":"success"}`