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"