From ab9bd057e83016710f0c008ae2a75c30a2bbdc96 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 20 Dec 2025 12:21:47 -0600 Subject: [PATCH] Fallback memory scope when device/user id missing --- custom_components/groqd/conversation.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/custom_components/groqd/conversation.py b/custom_components/groqd/conversation.py index 7f55645..c5309c5 100644 --- a/custom_components/groqd/conversation.py +++ b/custom_components/groqd/conversation.py @@ -190,10 +190,18 @@ class GroqdConversationEntity( memory_scope = options.get(CONF_MEMORY_SCOPE, DEFAULT_MEMORY_SCOPE) memory_key = None - if memory_scope == "device" and user_input.device_id: - memory_key = f"device:{user_input.device_id}" - elif memory_scope == "user" and user_input.context and user_input.context.user_id: - memory_key = f"user:{user_input.context.user_id}" + if memory_scope == "device": + if user_input.device_id: + memory_key = f"device:{user_input.device_id}" + elif user_input.context and user_input.context.user_id: + memory_key = f"user:{user_input.context.user_id}" + else: + memory_key = "global" + elif memory_scope == "user": + if user_input.context and user_input.context.user_id: + memory_key = f"user:{user_input.context.user_id}" + else: + memory_key = "global" elif memory_scope == "global": memory_key = "global"