Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve retry #62

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions custom_components/hass_nuki_bt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
from __future__ import annotations
import logging
from bleak import BleakError

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform, CONF_NAME, CONF_PIN
Expand Down Expand Up @@ -70,6 +71,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass, addr, connectable=True
),
)
try:
await device.connect()
except BleakError:
raise ConfigEntryNotReady(f"Could not connect to {address}")

hass.data[DOMAIN][entry.entry_id] = coordinator = NukiDataUpdateCoordinator(
hass=hass,
Expand Down
1 change: 1 addition & 0 deletions custom_components/hass_nuki_bt/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ async def async_step_pair(
self.hass, addr, connectable=True
),
)
await device.connect()
try:
ret = await device.pair()
except NukiErrorException as ex:
Expand Down
6 changes: 4 additions & 2 deletions custom_components/hass_nuki_bt/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ async def _async_update(
self, service_info: bluetooth.BluetoothServiceInfoBleak = None
) -> None:
"""Poll the device."""
if service_info:
self.device.set_ble_device(service_info.device)
await self.device.update_state()
if self._security_pin:
# get the latest log enrty
# todo: check if Nuki looging is enabled
# get the latest log entry
# todo: check if Nuki logging is enabled
logs = await self.device.request_log_entries(
security_pin=self._security_pin, count=1
)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/hass_nuki_bt/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"pyNukiBT"
],
"requirements": [
"pyNukiBT==0.0.12"
"pyNukiBT==0.0.13"
],
"version": "0.0.0"
}