Skip to content

fix: make Tesla action commands case-insensitive#1522

Merged
openminddev merged 3 commits intoOpenMind:mainfrom
0xbyt4:bugfix/tesla-case-insensitive-commands
Jan 19, 2026
Merged

fix: make Tesla action commands case-insensitive#1522
openminddev merged 3 commits intoOpenMind:mainfrom
0xbyt4:bugfix/tesla-case-insensitive-commands

Conversation

@0xbyt4
Copy link
Copy Markdown
Contributor

@0xbyt4 0xbyt4 commented Jan 16, 2026

Summary

This PR fixes case-sensitive string comparison in DIMOTeslaConnector that caused Tesla commands to fail when LLM output had different capitalization.

Problem

File: src/actions/dimo/connector/tesla.py

The connector compared action strings with exact match:

if output_interface.action == "lock doors":  # Only lowercase worked
    ...

Impact:

  • LLM outputs like "Lock Doors", "LOCK DOORS", "Lock doors" all failed
  • Commands silently failed with "Unknown action" error
  • Users had no indication why their command didn't work

Root Cause

LLM models don't guarantee consistent casing in their outputs. The same prompt might return:

  • "lock doors" (lowercase)
  • "Lock Doors" (title case)
  • "LOCK DOORS" (uppercase)
  • "Lock doors" (sentence case)

Solution

Normalize the action string to lowercase before comparison:

# Normalize action to lowercase for case-insensitive comparison
action = str(output_interface.action).lower()

if action == "lock doors":
    ...

Testing

Added comprehensive test suite in tests/actions/dimo/test_tesla.py with 19 test cases:

Command Test Cases
lock doors "lock doors", "Lock Doors", "LOCK DOORS", "Lock doors", "lOcK dOoRs"
unlock doors "unlock doors", "Unlock Doors", "UNLOCK DOORS"
open frunk "open frunk", "Open Frunk", "OPEN FRUNK"
open trunk "open trunk", "Open Trunk", "OPEN TRUNK"
idle "idle", "Idle", "IDLE"

Plus basic tests for unknown actions and missing JWT handling.

Test Results:

tests/actions/dimo/test_tesla.py ... 19 passed

Before & After

Input Before After
"lock doors" ✅ Works ✅ Works
"Lock Doors" ❌ "Unknown action" ✅ Works
"LOCK DOORS" ❌ "Unknown action" ✅ Works
"lOcK dOoRs" ❌ "Unknown action" ✅ Works

Checklist

  • Tests written and passing (19 tests)
  • pyright passes with 0 errors
  • pre-commit hooks pass (black, ruff, isort)
  • Follows OM1 coding patterns
  • Backward compatible (lowercase still works)

@0xbyt4 0xbyt4 requested review from a team as code owners January 16, 2026 18:05
@github-actions github-actions Bot added robotics Robotics code changes python Python code tests Test files labels Jan 16, 2026
Commands from LLM output may have varying capitalization (e.g., "Lock Doors",
"LOCK DOORS", "lock doors"). Previously, only exact lowercase match worked.

Changes:
- Normalize action string to lowercase before comparison
- Add comprehensive test suite with 19 test cases covering all commands
- Test various case combinations: lowercase, Title Case, UPPERCASE, mixed

This ensures reliable command execution regardless of LLM output formatting.
@0xbyt4 0xbyt4 force-pushed the bugfix/tesla-case-insensitive-commands branch from 6f8d8ce to f00b4f7 Compare January 16, 2026 18:08
openminddev and others added 2 commits January 18, 2026 20:33
Consolidated and refactored case-insensitive command tests for the Tesla connector, removing redundant class wrappers and improving test parametrization. Added tests for error logging on unknown actions and missing JWT. Removed unnecessary comments and docstrings for brevity.
@openminddev openminddev merged commit 4ebd380 into OpenMind:main Jan 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants