Skip to content

feat: add current_room sensor from working_status field 6 - #24

Merged
sjmotew merged 1 commit into
sjmotew:masterfrom
clawtom:current-room-sensor
Aug 8, 2026
Merged

feat: add current_room sensor from working_status field 6#24
sjmotew merged 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.

wawtor added a commit to wawtor/NarwalIntegration that referenced this pull request Jul 9, 2026
…-room sensor (sjmotew#24)

- Cleaning area read working_status field 13 (totalDryStationBagTime, a station
  timer stuck at 18000) and divided by 10000 -> permanently 1.8 m2. Read field 2
  (coveredArea, float32 m2) instead; correct the WorkingStatusField names.
- Add a current-room sensor from working_status field 6 (cleaningZoneId), resolved
  to a room name via the cached map.
- Pass config_entry to DataUpdateCoordinator so entities resolve device info.
@sjmotew

sjmotew commented Jul 27, 2026

Copy link
Copy Markdown
Owner

@clawtom — this is still the version of current_room I want. It overlaps @Sean-StarLabs's #59, but yours is standalone, tested, and already closes #21. Merge sequencing for all the overlapping fork work is in #66.

Ask: please rebase after #52 lands (step 4 in #66 — the base_status field audit, which corrects several mislabeled fields in models.py and will touch code near yours). I'll merge this right after.

Separately, two things you found earlier deserve an update:

@sjmotew

sjmotew commented Jul 30, 2026

Copy link
Copy Markdown
Owner

@clawtom — merging #48 and #51 has put this into conflict; models.py and sensor.py both changed under you. A rebase onto current master should sort it.

This is the rebase point I mentioned in #66, so the target is real now rather than hypothetical. Your current_room sensor is still the version I want over the alternatives — standalone, tested, and it closes #21.

I've also approved CI on the fork PRs, so you'll get actual check results this time.

Separately, if you get a chance: the room-clean fix (#49) is close, and you're the original reporter on #25. A retest on your Flow 2 once it lands would be valuable.

@sjmotew

sjmotew commented Jul 31, 2026

Copy link
Copy Markdown
Owner

@clawtom — one more rebase needed, and then I'm done asking. Sorry.

Today's merges moved models.py and sensor.py under you again: #52 (68b5e0d, base_status field audit), #72 (a3edc57, log flooding), and the #48 reland (17ba151). Master is at 17ba151.

The good news is the churn is over. The room-type table was the thing causing repeated conflicts in this area, and it's now settled with decompiled evidence rather than inference — see #48 and #22. It isn't going to move again. Likewise the base_status field labels are now audited, so models.py should be stable from here.

One thing worth checking while you're in there: #52 added station and consumable diagnostic entities and touched how base_status fields are named. If current_room reads any field that #52 relabelled, the rebase may look clean but be semantically wrong. Worth a glance at the field you're parsing out of working_status field 6 against the new labels.

To restate what I said on 07-27, since it's been a while: this is still the version of current_room I want. It overlaps @Sean-StarLabs's #59, but yours is standalone, already tested, and doesn't drag the rest of the Flow 2 series in with it. It goes in on its own merits.

Once rebased I'll take it straight in — it's not gated on #49 or anything else in the queue.

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