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.
This commit is contained in:
jacob1 2025-02-12 23:03:11 -05:00
parent 9c45e99c36
commit a153b614ea
No known key found for this signature in database
GPG Key ID: 4E58A32D510E1995

View File

@ -361,6 +361,21 @@ AnyType CommandInterface::tptS_set(std::deque<String> * 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)
{