File tree Expand file tree Collapse file tree
custom_components/realme_scale Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ## [ 0.8.1] - 2026-09-08
11+
12+ ### Fixed
13+ - ** Sensor state persistence across BLE disconnects** : user measurement and
14+ derived sensors no longer gate availability on the BLE connection state.
15+ Once a valid measurement exists, entities keep their last known value
16+ (and stay ` available ` ) while the scale sleeps/disconnects, so history
17+ graphs keep a continuous line instead of showing a gap. The scale-level
18+ ` Connected ` binary sensor still reports link state independently.
19+
1020## [ 0.8.0] - 2026-09-08
1121
1222### Changed (UI/UX polish only - no functionality/storage changes)
Original file line number Diff line number Diff line change 88 "issue_tracker" : " https://github.com/kapilmahawar/realme-scale-ha/issues" ,
99 "iot_class" : " local_push" ,
1010 "integration_type" : " device" ,
11- "version" : " 0.8.0 " ,
11+ "version" : " 0.8.1 " ,
1212 "bluetooth" : [
1313 {
1414 "service_uuid" : " 0000a602-0000-1000-8000-00805f9b34fb"
Original file line number Diff line number Diff line change @@ -277,9 +277,13 @@ def _measurement(self):
277277
278278 @property
279279 def available (self ) -> bool :
280- """Only available while the scale link is up and we have a value."""
281- if not self .coordinator .connected :
282- return False
280+ """Available whenever we have a (last known) measurement value.
281+
282+ Intentionally independent of the BLE link state: once a valid
283+ measurement exists it stays available during disconnects so history
284+ graphs keep the last known value instead of showing a gap. Link
285+ state is reported by the scale-level ``Connected`` binary sensor.
286+ """
283287 measurement = self ._measurement ()
284288 if measurement is None :
285289 return False
@@ -403,9 +407,11 @@ def _computed(self) -> object | None:
403407
404408 @property
405409 def available (self ) -> bool :
406- """Available when the scale link is up and a value can be derived."""
407- if not self .coordinator .connected :
408- return False
410+ """Available whenever a value can be derived from the last reading.
411+
412+ Independent of the BLE link state so derived metrics keep their last
413+ known value across disconnects (see RealmeScaleUserSensor).
414+ """
409415 return self ._computed () is not None
410416
411417 @property
Original file line number Diff line number Diff line change @@ -84,3 +84,16 @@ def test_select_hides_internal_user_ids() -> None:
8484 # The plain (non-duplicate) option never embeds the stable user id.
8585 assert 'return f"{name} ({user.user_id[-6:]})"' in select
8686 assert 'return name' in select
87+
88+
89+ def test_sensor_availability_does_not_depend_on_ble_connection () -> None :
90+ """Measurement sensors stay available with last-known data when the
91+ scale disconnects; only the Connected binary sensor reports link state.
92+ """
93+ sensor = SENSOR .read_text (encoding = "utf-8" )
94+ assert "coordinator.connected" not in sensor , (
95+ "measurement sensors must not gate availability on BLE link state"
96+ )
97+ assert "Available whenever we have a (last known) measurement value." in sensor
98+ binary = BINARY .read_text (encoding = "utf-8" )
99+ assert "coordinator.connected" in binary
You can’t perform that action at this time.
0 commit comments