Files
rpi-tulivision/test_controller_setup.py
2025-09-27 22:46:20 +02:00

74 lines
2.4 KiB
Python

#!/usr/bin/env python3
"""
Test script for controller setup
Verifies that the setup is working correctly
"""
import os
import json
import sys
def test_setup():
"""Test the controller setup"""
print("Testing IR Controller Setup")
print("=" * 40)
# Check if custom protocol decoder exists
if os.path.exists("custom_ir_protocol_final.py"):
print("✅ Custom protocol decoder found")
else:
print("❌ Custom protocol decoder not found")
return False
# Check if mapping file exists
if os.path.exists("ir_mapping.json"):
print("✅ IR mapping file found")
# Load and display mappings
try:
with open("ir_mapping.json", 'r') as f:
mappings = json.load(f)
print(f" Found {len(mappings)} command mappings:")
for ir_command, mapping in mappings.items():
if ir_command.startswith("CUSTOM_"):
print(f" - {ir_command} -> {mapping.get('command', 'unknown')}")
except Exception as e:
print(f" Error reading mappings: {e}")
else:
print("⚠️ IR mapping file not found (run setup first)")
# Check if IR listeners exist
listeners = ["simple_ir_listener.py", "simple_ir_listener_polling.py"]
for listener in listeners:
if os.path.exists(listener):
print(f"{listener} found")
else:
print(f"{listener} not found")
# Check if custom protocol is integrated
integration_files = ["ir_remote.py", "simple_ir_listener_polling.py"]
for file in integration_files:
if os.path.exists(file):
try:
with open(file, 'r') as f:
content = f.read()
if "CustomIRProtocol" in content:
print(f"✅ Custom protocol integrated in {file}")
else:
print(f"⚠️ Custom protocol not integrated in {file}")
except Exception as e:
print(f"❌ Error checking {file}: {e}")
print("\n" + "=" * 40)
print("Setup test complete!")
print("\nTo run the controller setup:")
print(" ./setup_controller.sh")
print("\nTo test IR commands:")
print(" python3 simple_ir_listener_polling.py --verbose")
return True
if __name__ == "__main__":
test_setup()