完善模式卡片、NFC及多设备控制流程

This commit is contained in:
minghanchen
2026-09-01 16:18:57 +08:00
parent ca26259e63
commit cbf230182d
15 changed files with 1092 additions and 191 deletions
@@ -112,10 +112,16 @@ class ModeOperation:
)
def to_request(self, mode_name: str) -> dict[str, Any]:
target_scope = self.target_scope
if self.domain == "seat" and target_scope == "front_right":
# Compiled seat operations use the physical zone name, while the
# model-plan adapter exposes the logical passenger target. Normalize
# persisted cards so a validated target is not queried again.
target_scope = "passenger"
return {
"domain": self.domain,
"capability": self.capability,
"target_scope": self.target_scope,
"target_scope": target_scope,
"operation": self.operation,
"parameters": [
{"name": name, "value": value}
@@ -450,6 +456,26 @@ class ModeProfileRegistry:
public.append(item)
return public
def get_profile(
self,
mode_id: str,
vehicle_id: str | None = None,
) -> ModeProfile:
"""Resolve the effective preset or user override by its stable ID."""
clean_mode_id = str(mode_id).strip()
profile = next(
(
item
for item in self._profiles_for_vehicle(vehicle_id)
if item.id == clean_mode_id
),
None,
)
if profile is None:
raise KeyError(clean_mode_id)
return profile
def match_text(
self,
utterance: str,