Keep showing last known values when the bike is out of range
Setup no longer depends on the bike being reachable. The coordinator is built from an address and resolves the BLEDevice per connect attempt, so a parked or switched-off bike loads the entry instead of raising ConfigEntryNotReady and leaving every entity unavailable. Parser state is persisted through helpers.storage.Store and restored before the platforms are set up, so entities carry their last values and the VIN on their first state write. What survives is a whitelist: battery and EBM counters yes, motor and assist no - a restored speed reading is indistinguishable from live data on a parked bike. The connection switch position is restored too, so a restart no longer wakes a bike the user deliberately disconnected. Also fixes three defects found while building this: - Store.async_delay_save debounces rather than throttles, so re-arming on every notification postponed the write for as long as the bike stayed connected and nothing reached disk except on a clean shutdown. - establish_connection had no disconnected_callback, so a dropped link left _is_connected True: the connectivity sensor lied and the poll never retried. - _connect read self._client back across the 200ms handshake, which a concurrent teardown could clear underneath it. Connecting now starts on the bike's advertisement instead of the next poll tick, and an unreachable bike says why - distinguishing "switched off" from "seen only by a passive proxy that cannot connect". Renames the connection switch to Auto-connect and drops the hardcoded English name on the connectivity sensor, which had been defeating its translation key. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FyabWZzd7HoLpyBwEa5Zzh
This commit is contained in:
co-authored by
Claude Opus 5
parent
c539823c1a
commit
ac0baffe74
@@ -49,6 +49,10 @@ This integration provides real-time monitoring of your E-Bike through Bluetooth
|
||||
- **Range** (km)
|
||||
- **Light Status**
|
||||
|
||||
### Diagnostics
|
||||
- **Last Seen** (Timestamp) - When the bike last sent data, so you can tell how fresh the values are
|
||||
- **Signal Strength** (dBm) - disabled by default
|
||||
|
||||
### Device Information
|
||||
The integration automatically retrieves and displays:
|
||||
- **Serial Number** (VIN) - 17-character bike serial number
|
||||
@@ -115,6 +119,19 @@ The integration will automatically discover iWoc and HUS devices in range via Bl
|
||||
- Some sensors may show "Unknown" until the bike sends that specific data
|
||||
- Check if the bike is actively transmitting data (try riding or using the display)
|
||||
|
||||
### Values after a Home Assistant restart
|
||||
|
||||
The integration keeps working when the bike is switched off or out of range:
|
||||
|
||||
- Counters and battery values (odometer, trip distance, range, state of charge,
|
||||
remaining energy, light) are stored and shown again after a restart
|
||||
- Momentary readings (speed, motor temperature, assist level, battery current)
|
||||
are **not** restored and show "Unknown" until the bike connects again — a
|
||||
stale speed reading would look like live data from a parked bike
|
||||
- Use **Connected** and **Last Seen** to tell live data from last known values
|
||||
- The connection switch keeps its position across restarts, so a bike you
|
||||
deliberately disconnected is not woken up again by a Home Assistant restart
|
||||
|
||||
### Connection Switch
|
||||
|
||||
- **To disconnect**: Turn off the "Connection" switch in Home Assistant
|
||||
|
||||
Reference in New Issue
Block a user