use unit for attribute if it is provided

This commit is contained in:
Alex O'Connell
2024-12-15 14:01:47 -05:00
parent 9fa795bbd9
commit 4b19df7c40

View File

@@ -755,12 +755,14 @@ class LocalLLMAgent(ConversationEntity, AbstractConversationAgent):
value = attributes[attribute_name]
if value is not None:
if attribute_name == "temperature":
value = int(value)
if value > 50:
value = f"{value}F"
else:
value = f"{value}C"
# try to apply unit if present
unit_suffix = attributes.get(f"{attribute_name}_unit")
if unit_suffix:
value = f"{value} {unit_suffix}"
elif attribute_name == "temperature":
# try to get unit or guess otherwise
suffix = "F" if value > 50 else "C"
value = F"{int(value)} {suffix}"
elif attribute_name == "rgb_color":
value = F"{closest_color(value)} {value}"
elif attribute_name == "volume_level":