Skip to content

Commit 3d614b3

Browse files
committed
Only detect the scale, not other realme BLE devices
Discovery now requires the a602 service UUID or a scale-like name token (scale/rmh2011) instead of any name containing 'realme', so realme Buds Air7 and similar devices are no longer offered as the scale.
1 parent 14ef04c commit 3d614b3

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111
- CI: GitHub Actions workflow runs the pure-python test suite on push/PR.
12+
- **Discovery filtering**: only devices advertising the scale service UUID
13+
(`0000a602`) or a scale-like name token are offered by the integration —
14+
other realme BLE devices (e.g. "realme Buds Air7") are no longer detected
15+
as a scale.
1216
- **Multi-user support**: every scale entry now holds a *list* of user
1317
profiles; users can be added / edited / removed after install from a
1418
menu-driven options flow.

custom_components/realme_scale/config_flow.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,18 @@ def _user_choices(users: list[ScaleUser]) -> dict[str, str]:
162162

163163

164164
def device_matches(discovery: BluetoothServiceInfoBleak) -> bool:
165-
"""Whether a discovered advertisement looks like a Realme scale."""
165+
"""Whether a discovered advertisement looks like a Realme *scale*.
166+
167+
Deliberately stricter than openScale's ``name contains "realme"`` test:
168+
HA auto-discovery would otherwise also offer unrelated realme BLE gear
169+
(e.g. "realme Buds Air7"), which does not speak the scale protocol.
170+
A candidate must advertise the scale service UUID (``a602``) or carry a
171+
scale-ish name token.
172+
"""
166173
name = (discovery.name or "").lower()
167-
return "realme" in name or SVC_A602 in discovery.service_uuids
174+
if SVC_A602 in discovery.service_uuids:
175+
return True
176+
return "scale" in name or "rmh2011" in name
168177

169178

170179
def _discovered_devices(hass: HomeAssistant) -> list[BluetoothServiceInfoBleak]:

custom_components/realme_scale/manifest.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@
1313
"service_uuid": "0000a602-0000-1000-8000-00805f9b34fb"
1414
},
1515
{
16-
"local_name": "realme*"
16+
"connectable": false,
17+
"service_uuid": "0000a602-0000-1000-8000-00805f9b34fb"
1718
},
1819
{
19-
"local_name": "Realme*"
20+
"local_name": "realme*scale*"
2021
},
2122
{
22-
"local_name": "REALME*"
23+
"local_name": "Realme*Scale*"
2324
},
2425
{
25-
"connectable": false,
26-
"service_uuid": "0000a602-0000-1000-8000-00805f9b34fb"
26+
"local_name": "REALME*SCALE*"
2727
},
2828
{
2929
"connectable": false,
30-
"local_name": "realme*"
30+
"local_name": "realme*scale*"
3131
},
3232
{
3333
"connectable": false,
34-
"local_name": "Realme*"
34+
"local_name": "Realme*Scale*"
3535
},
3636
{
3737
"connectable": false,
38-
"local_name": "REALME*"
38+
"local_name": "REALME*SCALE*"
3939
}
4040
]
4141
}

0 commit comments

Comments
 (0)