Skip to content

Commit

Permalink
Fix airthings-ble data drop outs when Bluetooth connection is flakey (#…
Browse files Browse the repository at this point in the history
…116805)

* Fix airthings-ble data drop outs when Bluetooth adapter is flakey

fixes #116770

* add missing file

* update
  • Loading branch information
bdraco authored May 5, 2024
1 parent 2964471 commit d970c19
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion homeassistant/components/airthings_ble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from homeassistant.util.unit_system import METRIC_SYSTEM

from .const import DEFAULT_SCAN_INTERVAL, DOMAIN
from .const import DEFAULT_SCAN_INTERVAL, DOMAIN, MAX_RETRIES_AFTER_STARTUP

PLATFORMS: list[Platform] = [Platform.SENSOR]

Expand Down Expand Up @@ -66,6 +66,12 @@ async def _async_update_method() -> AirthingsDevice:

await coordinator.async_config_entry_first_refresh()

# Once its setup and we know we are not going to delay
# the startup of Home Assistant, we can set the max attempts
# to a higher value. If the first connection attempt fails,
# Home Assistant's built-in retry logic will take over.
airthings.set_max_attempts(MAX_RETRIES_AFTER_STARTUP)

entry.runtime_data = coordinator

await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/airthings_ble/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
VOLUME_PICOCURIE = "pCi/L"

DEFAULT_SCAN_INTERVAL = 300

MAX_RETRIES_AFTER_STARTUP = 5
2 changes: 1 addition & 1 deletion homeassistant/components/airthings_ble/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
"dependencies": ["bluetooth_adapters"],
"documentation": "https://www.home-assistant.io/integrations/airthings_ble",
"iot_class": "local_polling",
"requirements": ["airthings-ble==0.8.0"]
"requirements": ["airthings-ble==0.9.0"]
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ aioymaps==1.2.2
airly==1.1.0

# homeassistant.components.airthings_ble
airthings-ble==0.8.0
airthings-ble==0.9.0

# homeassistant.components.airthings
airthings-cloud==0.2.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ aioymaps==1.2.2
airly==1.1.0

# homeassistant.components.airthings_ble
airthings-ble==0.8.0
airthings-ble==0.9.0

# homeassistant.components.airthings
airthings-cloud==0.2.0
Expand Down

0 comments on commit d970c19

Please sign in to comment.