Skip to content

feat: inject device area context for room-aware voice responses#12

Open
DarrenBenson wants to merge 16 commits into
techartdev:mainfrom
DarrenBenson:main
Open

feat: inject device area context for room-aware voice responses#12
DarrenBenson wants to merge 16 commits into
techartdev:mainfrom
DarrenBenson:main

Conversation

@DarrenBenson

Copy link
Copy Markdown

Summary

  • Resolves the originating voice satellite's area from the HA device/area registry and injects [Voice command from: <room>] into the system prompt sent to OpenClaw
  • Sends x-openclaw-area and x-openclaw-device-id headers for structured access
  • When no device or area is available, behaviour is identical to the unmodified code

Motivation

When a user speaks to a voice satellite (e.g. Voice PE in the Study), OpenClaw has no way to know which room they're in. This means "turn off the lights" or "what's the temperature in here?" can't be resolved to the correct room.

HA's ConversationInput already carries device_id (since HA 2024.4), and the device registry knows which area each device belongs to. This PR connects those dots.

How it works

  1. Reads device_id from ConversationInput (already provided by the Assist pipeline)
  2. Looks up the device in hass.helpers.device_registry to get its area_id
  3. Looks up the area in hass.helpers.area_registry to get the area name
  4. Prepends [Voice command from: Study] to the system prompt
  5. Adds x-openclaw-area and x-openclaw-device-id headers

Backwards compatible

  • If device_id is not available (e.g. non-satellite input), no context is added
  • If the device has no area assigned, only x-openclaw-device-id is sent
  • If neither is available, the request is identical to the current code

Test plan

  • Voice command from satellite with assigned area -- system prompt includes room context
  • Voice command from device without area -- no room context, device ID header only
  • Non-voice input (dashboard, API) -- no change in behaviour

🤖 Generated with Claude Code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants