From 41398e88c9391cbcf044b2da8e56f2f9cbf73d75 Mon Sep 17 00:00:00 2001 From: fatmehosseini <92212868+fatmehosseini@users.noreply.github.com> Date: Fri, 23 Jun 2023 18:01:16 +0330 Subject: [PATCH 1/2] property wont set if it is read only --- Thing.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Thing.h b/Thing.h index 25a6ea3..b041762 100644 --- a/Thing.h +++ b/Thing.h @@ -360,6 +360,10 @@ class ThingProperty : public ThingItem { callback(newValue); } } + bool isInRange(ThingDataValue value){ + return (this->maximum < this->minimum) //to check if minimum and maximum values are asigned + || (this->maximum > value.) + } }; #ifndef WITHOUT_WS @@ -578,7 +582,8 @@ class ThingDevice { void setProperty(const char *name, const JsonVariant &newValue) { ThingProperty *property = findProperty(name); - + if(property->readOnly) + return; if (property == nullptr) { return; } @@ -597,15 +602,19 @@ class ThingDevice { case NUMBER: { ThingDataValue value; value.number = newValue.as(); - property->setValue(value); - property->changed(value); + if((property->maximum < property->minimum) || (property->maximum > value && property->minimum < value)){ + property->setValue(value); + property->changed(value); + } break; } case INTEGER: { ThingDataValue value; value.integer = newValue.as(); - property->setValue(value); - property->changed(value); + if((property->maximum < property->minimum) || (property->maximum > value && property->minimum < value)){ + property->setValue(value); + property->changed(value); + } break; } case STRING: From 0eadace04307c7f6a0230c360766e7f5db713f20 Mon Sep 17 00:00:00 2001 From: fatmehosseini <92212868+fatmehosseini@users.noreply.github.com> Date: Sat, 24 Jun 2023 12:32:35 +0330 Subject: [PATCH 2/2] unused function deleted --- Thing.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Thing.h b/Thing.h index b041762..8311fce 100644 --- a/Thing.h +++ b/Thing.h @@ -360,10 +360,6 @@ class ThingProperty : public ThingItem { callback(newValue); } } - bool isInRange(ThingDataValue value){ - return (this->maximum < this->minimum) //to check if minimum and maximum values are asigned - || (this->maximum > value.) - } }; #ifndef WITHOUT_WS @@ -602,7 +598,7 @@ class ThingDevice { case NUMBER: { ThingDataValue value; value.number = newValue.as(); - if((property->maximum < property->minimum) || (property->maximum > value && property->minimum < value)){ + if((property->maximum < property->minimum) || (property->maximum > value.number && property->minimum < value.number)){ property->setValue(value); property->changed(value); } @@ -611,7 +607,7 @@ class ThingDevice { case INTEGER: { ThingDataValue value; value.integer = newValue.as(); - if((property->maximum < property->minimum) || (property->maximum > value && property->minimum < value)){ + if((property->maximum < property->minimum) || (property->maximum > value.integer && property->minimum < value.integer)){ property->setValue(value); property->changed(value); }