Remove Matrix integration from project
- Removed matrix_notifier.py, send_matrix_message.py, debug_matrix.py - Removed store_matrix_communication.py and check_room_messages.py - Matrix communication is now Claude's personal functionality - Clean project focused purely on fact-based memory system 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Check recent messages in Home Assistant room
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import httpx
|
||||
from datetime import datetime
|
||||
|
||||
# Matrix configuration
|
||||
MATRIX_HOMESERVER = "https://matrix.klas.chat"
|
||||
MATRIX_ACCESS_TOKEN = "syt_a2xhcw_ZcjbRgfRFEdMHnutAVOa_1M7eD4"
|
||||
HOME_ASSISTANT_ROOM_ID = "!xZkScMybPseErYMJDz:matrix.klas.chat"
|
||||
|
||||
async def check_recent_messages():
|
||||
"""Check recent messages in Home Assistant room"""
|
||||
print("📨 Checking recent messages in Home Assistant room...")
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {MATRIX_ACCESS_TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
# Get recent messages from the room
|
||||
response = await client.get(
|
||||
f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{HOME_ASSISTANT_ROOM_ID}/messages?dir=b&limit=10",
|
||||
headers=headers,
|
||||
timeout=30.0
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
events = data.get('chunk', [])
|
||||
|
||||
print(f"✅ Found {len(events)} recent events")
|
||||
print("\n📋 Recent messages:")
|
||||
|
||||
for i, event in enumerate(events):
|
||||
if event.get('type') == 'm.room.message':
|
||||
content = event.get('content', {})
|
||||
body = content.get('body', '')
|
||||
sender = event.get('sender', '')
|
||||
timestamp = event.get('origin_server_ts', 0)
|
||||
|
||||
# Convert timestamp to readable format
|
||||
dt = datetime.fromtimestamp(timestamp / 1000)
|
||||
time_str = dt.strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
print(f" {i+1}. [{time_str}] {sender}: {body}")
|
||||
|
||||
# Check if this is our test message
|
||||
if "Matrix API test message from LangMem debug script" in body:
|
||||
print(" ✅ This is our test message!")
|
||||
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Failed to get messages: {response.status_code}")
|
||||
print(f"Response: {response.text}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error checking messages: {e}")
|
||||
return False
|
||||
|
||||
async def main():
|
||||
"""Main function"""
|
||||
await check_recent_messages()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -1,98 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Debug Matrix API connection step by step
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import httpx
|
||||
|
||||
# Matrix configuration
|
||||
MATRIX_HOMESERVER = "https://matrix.klas.chat"
|
||||
MATRIX_ACCESS_TOKEN = "syt_a2xhcw_ZcjbRgfRFEdMHnutAVOa_1M7eD4"
|
||||
HOME_ASSISTANT_ROOM_ID = "!xZkScMybPseErYMJDz:matrix.klas.chat"
|
||||
|
||||
async def test_matrix_connection():
|
||||
"""Test Matrix connection step by step"""
|
||||
print("🔍 Testing Matrix API connection...")
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {MATRIX_ACCESS_TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
# Test 1: Check if we can access the Matrix server
|
||||
print("\n1. Testing Matrix server access...")
|
||||
response = await client.get(f"{MATRIX_HOMESERVER}/_matrix/client/versions", timeout=30.0)
|
||||
print(f" Status: {response.status_code}")
|
||||
if response.status_code == 200:
|
||||
print(" ✅ Matrix server is accessible")
|
||||
else:
|
||||
print(" ❌ Matrix server access failed")
|
||||
return False
|
||||
|
||||
# Test 2: Check if our access token is valid
|
||||
print("\n2. Testing access token...")
|
||||
response = await client.get(f"{MATRIX_HOMESERVER}/_matrix/client/v3/account/whoami", headers=headers, timeout=30.0)
|
||||
print(f" Status: {response.status_code}")
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print(f" ✅ Access token valid, user: {data.get('user_id')}")
|
||||
else:
|
||||
print(" ❌ Access token invalid")
|
||||
print(f" Response: {response.text}")
|
||||
return False
|
||||
|
||||
# Test 3: Check if we can access the Home Assistant room
|
||||
print("\n3. Testing Home Assistant room access...")
|
||||
response = await client.get(f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{HOME_ASSISTANT_ROOM_ID}/state/m.room.name", headers=headers, timeout=30.0)
|
||||
print(f" Status: {response.status_code}")
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print(f" ✅ Room accessible, name: {data.get('name')}")
|
||||
else:
|
||||
print(" ❌ Room access failed")
|
||||
print(f" Response: {response.text}")
|
||||
return False
|
||||
|
||||
# Test 4: Send a simple test message
|
||||
print("\n4. Sending test message...")
|
||||
message_data = {
|
||||
"msgtype": "m.text",
|
||||
"body": "🔧 Matrix API test message from LangMem debug script"
|
||||
}
|
||||
|
||||
response = await client.post(
|
||||
f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{HOME_ASSISTANT_ROOM_ID}/send/m.room.message",
|
||||
headers=headers,
|
||||
json=message_data,
|
||||
timeout=30.0
|
||||
)
|
||||
print(f" Status: {response.status_code}")
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print(f" ✅ Message sent successfully!")
|
||||
print(f" Event ID: {data.get('event_id')}")
|
||||
return True
|
||||
else:
|
||||
print(" ❌ Message sending failed")
|
||||
print(f" Response: {response.text}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error during testing: {e}")
|
||||
return False
|
||||
|
||||
async def main():
|
||||
"""Main function"""
|
||||
success = await test_matrix_connection()
|
||||
|
||||
if success:
|
||||
print("\n🎉 All Matrix API tests passed!")
|
||||
else:
|
||||
print("\n❌ Matrix API tests failed!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -1,67 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple Matrix message sender for LangMem notifications
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
import httpx
|
||||
|
||||
# Matrix configuration
|
||||
MATRIX_HOMESERVER = "https://matrix.klas.chat"
|
||||
MATRIX_ACCESS_TOKEN = "syt_a2xhcw_ZcjbRgfRFEdMHnutAVOa_1M7eD4"
|
||||
HOME_ASSISTANT_ROOM_ID = "!xZkScMybPseErYMJDz:matrix.klas.chat"
|
||||
|
||||
async def send_matrix_notification(message: str) -> bool:
|
||||
"""Send notification to Matrix Home Assistant room"""
|
||||
headers = {
|
||||
"Authorization": f"Bearer {MATRIX_ACCESS_TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
message_data = {
|
||||
"msgtype": "m.text",
|
||||
"body": message
|
||||
}
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{HOME_ASSISTANT_ROOM_ID}/send/m.room.message",
|
||||
headers=headers,
|
||||
json=message_data,
|
||||
timeout=30.0
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print(f"✅ Matrix notification sent: {data.get('event_id')}")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Failed to send Matrix notification: {response.status_code}")
|
||||
print(f"Response: {response.text}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error sending Matrix notification: {e}")
|
||||
return False
|
||||
|
||||
async def main():
|
||||
"""Main function"""
|
||||
if len(sys.argv) > 1:
|
||||
message = " ".join(sys.argv[1:])
|
||||
else:
|
||||
message = "📋 Matrix notification test - please confirm you received this message"
|
||||
|
||||
print(f"📤 Sending: {message}")
|
||||
success = await send_matrix_notification(message)
|
||||
|
||||
if success:
|
||||
print("🎉 Matrix notification sent successfully!")
|
||||
print("💬 Please check your Home Assistant room in Matrix")
|
||||
else:
|
||||
print("❌ Failed to send Matrix notification")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -1,110 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Send message to Matrix room via direct API call
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
import httpx
|
||||
|
||||
# Matrix configuration
|
||||
MATRIX_HOMESERVER = "https://matrix.klas.chat"
|
||||
MATRIX_ACCESS_TOKEN = "syt_a2xhcw_ZcjbRgfRFEdMHnutAVOa_1M7eD4"
|
||||
HOME_ASSISTANT_ROOM_ID = "!OQkQcCnlrGwGKJjXnt:matrix.klas.chat" # Need to find this
|
||||
|
||||
async def send_matrix_message(room_id: str, message: str, access_token: str = MATRIX_ACCESS_TOKEN) -> bool:
|
||||
"""Send a message to a Matrix room"""
|
||||
try:
|
||||
url = f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{room_id}/send/m.room.message"
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {access_token}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
data = {
|
||||
"msgtype": "m.text",
|
||||
"body": message
|
||||
}
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(url, headers=headers, json=data, timeout=30.0)
|
||||
|
||||
if response.status_code == 200:
|
||||
print(f"✅ Message sent successfully to room {room_id}")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Failed to send message: {response.status_code}")
|
||||
print(f"Response: {response.text}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error sending message: {e}")
|
||||
return False
|
||||
|
||||
async def find_home_assistant_room():
|
||||
"""Find the Home Assistant room ID"""
|
||||
try:
|
||||
url = f"{MATRIX_HOMESERVER}/_matrix/client/v3/joined_rooms"
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {MATRIX_ACCESS_TOKEN}"
|
||||
}
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(url, headers=headers, timeout=30.0)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
print("🔍 Searching for Home Assistant room...")
|
||||
|
||||
for room_id in data.get("joined_rooms", []):
|
||||
# Get room name
|
||||
room_url = f"{MATRIX_HOMESERVER}/_matrix/client/v3/rooms/{room_id}/state/m.room.name"
|
||||
room_response = await client.get(room_url, headers=headers, timeout=30.0)
|
||||
|
||||
if room_response.status_code == 200:
|
||||
room_data = room_response.json()
|
||||
room_name = room_data.get("name", "")
|
||||
print(f" Found room: {room_name} ({room_id})")
|
||||
|
||||
if "Home Assistant" in room_name:
|
||||
print(f"✅ Found Home Assistant room: {room_id}")
|
||||
return room_id
|
||||
|
||||
print("❌ Home Assistant room not found")
|
||||
return None
|
||||
else:
|
||||
print(f"❌ Failed to get rooms: {response.status_code}")
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error finding room: {e}")
|
||||
return None
|
||||
|
||||
async def main():
|
||||
"""Main function"""
|
||||
message = "🤖 Test message from LangMem MCP Server implementation!"
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
message = " ".join(sys.argv[1:])
|
||||
|
||||
print(f"📤 Sending message: {message}")
|
||||
|
||||
# Find Home Assistant room
|
||||
room_id = await find_home_assistant_room()
|
||||
|
||||
if room_id:
|
||||
success = await send_matrix_message(room_id, message)
|
||||
if success:
|
||||
print("🎉 Message sent successfully!")
|
||||
else:
|
||||
print("❌ Failed to send message")
|
||||
else:
|
||||
print("❌ Could not find Home Assistant room")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user