Skip to content

Show specific config flow errors for connection failures - #27

Merged
Nailik merged 5 commits into
mainfrom
fix/config-flow-errors
Oct 17, 2026
Merged

Nailik merged 5 commits into
mainfrom
fix/config-flow-errors

Conversation

@Nailik

@Nailik Nailik commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Every failure while connecting or validating the PIN during setup, reauth or reconfigure ended up as error_unknown ("Failed to connect to the device: …"). The failures a user can act on now get their own message.

Failure Error key Message (en)
BleakNotFoundError, device went away between discovery and connecting error_device_not_found (existing) Device not found. Please ensure the Blanco Unit is powered on and in Bluetooth range.
BleakOutOfConnectionSlotsError error_no_connection_slot (new) No free Bluetooth connection slot. Disconnect another Bluetooth device from the adapter or proxy, or add a Bluetooth proxy, then try again.
BlancoUnitGattTimeoutError, still stuck after reconnecting (and removing the device from BlueZ on a local adapter) error_device_not_responding (new) The Blanco Unit did not respond over Bluetooth, even after reconnecting. Reboot the Home Assistant host (restarting only Home Assistant is not enough) or restart the Bluetooth proxy, then try again. If that does not help, restart the Blanco Unit.
BlancoUnitConnectionError (including the new BlancoUnitProtocolError), BleakError, OSError, TimeoutError error_connection (new) Communication with the Blanco Unit failed. Please move it closer to the Bluetooth adapter or proxy and try again. ({error})
anything else error_unknown An unexpected error occurred: {error}
  • {error} now includes the exception type (TimeoutError, BleakError: …), since a TimeoutError has no message of its own.
  • A response the device sends that cannot be parsed (Invalid chunk stream, Chunk message ID mismatch, Failed to parse JSON response) raised ValueError before. The config flow maps ValueError to invalid_pin_format, so it was shown as "PIN must be exactly 5 digits", although the PIN format is checked before connecting. parse_response now raises BlancoUnitProtocolError, a BlancoUnitConnectionError, which ends up as error_connection.
  • The not responding message points at the host (BlueZ) or the proxy first, since that is where a stuck GATT operation lives.
  • All new keys are in en.json and de.json.
  • A wrong PIN still shows error_invalid_authentication. validate_pin reports it as a result, not as an exception, so nothing changes there.

Besides config_flow.py, the two translation files and tests/test_config_flow.py, only parse_response in client.py (and its tests) changes.

Test plan

  • pytest tests: 383 passed, 68 snapshots passed
  • A garbled response through the real validate_pin and parse_response shows error_connection, not invalid_pin_format
  • New parametrized test covers each mapping, raised where it really comes from (connecting or the PIN check)
  • Read the new strings in the setup dialog, in English and German

🤖 Generated with Claude Code

Nailik and others added 4 commits October 17, 2026 22:27
Every failure while connecting or validating the PIN ended up as
error_unknown, shown as "Failed to connect to the device". Map the
failures a user can act on to their own message:

- BleakNotFoundError -> error_device_not_found
- BleakOutOfConnectionSlotsError -> error_no_connection_slot
- BlancoUnitGattTimeoutError, still stuck after removing the device from
  BlueZ -> error_device_not_responding
- BlancoUnitConnectionError, BleakError, OSError, TimeoutError ->
  error_connection

error_unknown stays for anything else. Both placeholders now carry the
exception type, since a TimeoutError has no message of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parse_response raised ValueError, which the config flow maps to
invalid_pin_format. The PIN format is checked before connecting, so a
garbled or mismatched response from the device was shown as "PIN must be
exactly 5 digits". It now raises BlancoUnitProtocolError, a
BlancoUnitConnectionError, and ends up as error_connection.

The not responding message pointed at the Blanco Unit, but the stuck GATT
operation lives in BlueZ on the host. Suggest rebooting the host or
restarting the proxy first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from fix/stuck-gatt-recovery to main October 17, 2026 21:12
@Nailik
Nailik merged commit 4ba337f into main Oct 17, 2026
3 checks passed
@Nailik
Nailik deleted the fix/config-flow-errors branch October 17, 2026 21:18
github-actions Bot pushed a commit to alexhaller/blanco_unit that referenced this pull request Nov 9, 2026
## [2.0.2](v2.0.1...v2.0.2) (2026-11-09)

### Bug Fixes

* harden the BLE connection against leaks and stuck GATT operations ([ef3c1fa](ef3c1fa)), closes [Nailik#24](https://github.com/alexhaller/blanco_unit/issues/24) [Nailik#25](https://github.com/alexhaller/blanco_unit/issues/25) [Nailik#27](https://github.com/alexhaller/blanco_unit/issues/27)
* point the documentation and issue links at this repository ([d423f16](d423f16)), closes [hacs/default#13647](hacs/default#13647)
* stop reporting the filter and CO2 capacity as a battery ([5311f42](5311f42))
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.

1 participant