Skip to content

feat: add current_room sensor from working_status field 6#24

Open
clawtom wants to merge 1 commit into
sjmotew:masterfrom
clawtom:current-room-sensor
Open

feat: add current_room sensor from working_status field 6#24
clawtom wants to merge 1 commit into
sjmotew:masterfrom
clawtom:current-room-sensor

Conversation

@clawtom

@clawtom clawtom commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Exposes the current room the Narwal is actively cleaning as a new Current room text sensor in Home Assistant. The room name updates in real-time as the robot moves between rooms.

Source: working_status field 6 (room_id) — confirmed via live capture on Flow 2 (firmware v01.07.16.01). Field 6 changes value as the robot transitions between rooms; cross-referenced against the room list from get_map to resolve the display name.

Changes

  • narwal_client/models.py — add current_room_id: int | None to NarwalState; parse field 6 in update_from_working_status(); add current_room_name property that resolves the ID via the cached room map
  • sensor.py — add NarwalCurrentRoomSensor entity description
  • strings.json / translations/en.json — add current_room sensor strings
  • tests/test_models.py — 133 lines of new tests covering field 6 parsing, name resolution, edge cases (unknown room, no map, duplicate room type names)

Behavior

  • Sensor shows the display name of the room currently being cleaned (e.g. "Living Room", "Phoebe's room", "Bathroom 2")
  • Shows unavailable when the robot is docked, idle, or before the map has loaded
  • Uses the same display_name logic as the existing room segment selector — user-assigned names take priority over type-derived names; duplicate type names get numbered suffixes ("Bathroom 1", "Bathroom 2", "Bathroom 3")

Testing

152 tests pass (pytest tests/). 12 new tests specifically for the current room feature.

Closes #21

Adds a 'Current room' text sensor that shows which room the Narwal
vacuum is actively cleaning, updated in real-time as the robot moves
between rooms.

**Protocol source (confirmed 2026-04-24 from live Flow 2 capture):**
working_status field 6 carries the current target room_id as a varint.
The value changed from 4 (Corridor) to 1 (Living Room) mid-cleaning,
matching the Narwal app display exactly.

**Changes:**
- `NarwalState.current_room_id` — populated from working_status field 6
  during active cleaning; None when idle or field absent
- `NarwalState.current_room_name` — resolves room_id to a display name
  via the cached room map from get_map; None if map not loaded yet
- New `current_room` sensor entity (string, mdi:map-marker)
- Translation strings for both strings.json and en.json
- 12 new tests covering field parsing, name lookup, live capture replay,
  and edge cases (zero room_id, absent field, unknown room_id)

Closes sjmotew#21

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sjmotew

sjmotew commented May 17, 2026

Copy link
Copy Markdown
Owner

Reviewed. Clean scoped change — 12 new tests, +207/0, reuses the existing display_name resolution from #21. Closes #21.

One thing before I merge: working_status field 6 was confirmed on Flow 2 only. Want to sanity-check that field 6 carries the same semantics on Flow 1 (AX12) before this ships — I'll test on my Flow 1 (firmware v01.07.x) and merge if it parses identically. If field 6 is empty/different on Flow 1, the sensor needs an unavailable fallback so Flow 1 users don't see junk.

Related: blocked-then-unblocks for PR #35 (which also touches Flow 2 state decoding) — let's merge this first since it's narrow.

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.

[Feature]: Add current_room sensor from working_status broadcast

2 participants