Commit 332b86e
fix(messages): skip map-related legacy fallback for mower devices (#1565)
* fix(messages): skip map-related legacy fallback for mower devices
When a mower (e.g. Ecovacs GOAT G1, A1600 RTK, A3000 LiDAR Pro) is
mowing, its firmware pushes spontaneous `onMapTrace` MQTT messages.
They flow through `messages.get_message()` which falls back via
`_LEGACY_USE_GET_COMMAND` to `GetMapTrace`, whose parser does not
support the on-wire format used by recent mower firmware
(observed: 1.15.13). The parse fails inside
`_handle_error_or_analyse` and emits a WARNING per push.
In one user setup this produced 217 520 `Could not parse getMapTrace`
warnings over 3 days (~70 k/day, ~50/min during mowing), bloating the
HA `homeassistant.log` and the recorder DB by ~100 MB.
Mowers do not expose a `map=` capability in their hardware
definitions, so successfully parsed map-trace data would have nowhere
to land anyway — the fallback is pure noise on these devices.
This adds an optional `device_type` argument to `get_message` and
`get_legacy_message`. When the device is a `MOWER`, map-related
legacy messages (`onMapTrace`, `onMapSet`, `onMapSubSet`,
`onMinorMap`, `onCachedMapInfo`, `onMultiMapState` and their
`get/off/report` variants) are skipped silently before reaching the
parser. Vacuums and devices with no specified type fall through
unchanged.
`Device._handle_message` reads `device_type` defensively via `getattr`
so existing test mocks that don't expose the dataclass field on
`spec_set=Capabilities` continue to work — they fall back to the
no-filter path.
Tests:
- `test_get_messages` (existing 7 cases) — pass unchanged.
- `test_get_messages_device_type_filter` (10 new cases) — verify
mowers skip map-related legacy fallbacks while non-map messages
and other device types remain unaffected.
- Full suite: 707/707 pass, no regression.
Refs: #1376 (Disable getMapTrace for Goat)
Refs: #852 (GOAT A1600 RTK Support)
* review: gate on map capability instead of mower device_type
Address review feedback on #1565:
- Drop the explanatory comment block above ``_MAP_LEGACY_COMMANDS``
- Replace the ``device_type == DeviceType.MOWER`` check with a
capability-based one. ``get_message`` now takes ``has_map: bool``
(keyword-only) and ``get_legacy_message`` skips map-related fallbacks
when the device does not expose a ``map`` capability — independent of
whether the device is a mower, vacuum, or future device class.
- ``Device._handle_message`` derives ``has_map`` from
``capabilities.map`` via ``getattr`` so test mocks unaffected.
* review: pass StaticDeviceInfo to get_message, remove getattr
Address review feedback from edenhaus:
- Pass the whole `static: StaticDeviceInfo` object to `get_message()`
instead of extracting `data_type` and `has_map` separately at the
call site.
- Remove `getattr` in device.py — access `capabilities.map` directly
since the attribute is defined on the dataclass.
- Remove `lru_cache` on `get_message` since `StaticDeviceInfo` contains
non-trivially-hashable `Capabilities` objects. The function is cheap
enough without caching (string lookups + one regex).
- Update tests to use real `StaticDeviceInfo` fixtures (yna5xi with map,
xmp9ds without map) instead of passing primitive params.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Minor sorting
* refactor tests
* forgotten prek
* Use realistic bot for test
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Robert Resch <robert@resch.dev>1 parent 7266b58 commit 332b86e
5 files changed
Lines changed: 80 additions & 51 deletions
File tree
- deebot_client
- messages
- json
- tests
- messages
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
232 | 235 | | |
233 | 236 | | |
234 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
| 33 | + | |
32 | 34 | | |
33 | | - | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | | - | |
47 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
88 | 100 | | |
89 | 101 | | |
90 | 102 | | |
| |||
97 | 109 | | |
98 | 110 | | |
99 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
100 | 119 | | |
101 | 120 | | |
102 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
139 | 138 | | |
140 | 139 | | |
141 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
30 | | - | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | | - | |
| 37 | + | |
0 commit comments