From a153b614ea682961159e9f58bbd9fd1e7cc7baba Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 12 Feb 2025 23:03:11 -0500 Subject: [PATCH] Fix !set commands defaulting to Kelvin, instead of to current temperature scale An old hack got deleted that converted values for "temp" to StringType, to force it down the string conversion flow which handles temperature scales. I added that code back. --- src/lua/CommandInterface.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/lua/CommandInterface.cpp b/src/lua/CommandInterface.cpp index e6adbe066..30fde5644 100644 --- a/src/lua/CommandInterface.cpp +++ b/src/lua/CommandInterface.cpp @@ -361,6 +361,21 @@ AnyType CommandInterface::tptS_set(std::deque * words) } auto &propInfo = Particle::GetProperties()[*prop]; + // convert non-string temperature values to strings so format::StringToTemperature can take care of them + if (property.Value() == "temp") + { + switch (value.GetType()) + { + case TypeNumber: + value = StringType(String::Build(((NumberType)value).Value())); + break; + case TypeFloat: + value = StringType(String::Build(((FloatType)value).Value())); + break; + default: + break; + } + } // assume that value can be anything if (value.GetType() == TypeNumber && propInfo.Type == StructProperty::Float) {