Skip to content

Commit dcc3f14

Browse files
pantherale0frenck
authored andcommitted
Add shared BleakScanner to probe_plus (home-assistant#155051)
1 parent 7687d5e commit dcc3f14

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

homeassistant/components/probe_plus/coordinator.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
from pyprobeplus import ProbePlusDevice
99
from pyprobeplus.exceptions import ProbePlusDeviceNotFound, ProbePlusError
1010

11+
from homeassistant.components import bluetooth
1112
from homeassistant.config_entries import ConfigEntry
1213
from homeassistant.const import CONF_ADDRESS
1314
from homeassistant.core import HomeAssistant
15+
from homeassistant.exceptions import ConfigEntryNotReady
1416
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
1517

18+
from .const import DOMAIN
19+
1620
type ProbePlusConfigEntry = ConfigEntry[ProbePlusDataUpdateCoordinator]
1721

1822
_LOGGER = logging.getLogger(__name__)
@@ -39,8 +43,17 @@ def __init__(self, hass: HomeAssistant, entry: ProbePlusConfigEntry) -> None:
3943
config_entry=entry,
4044
)
4145

46+
available_scanners = bluetooth.async_scanner_count(hass, connectable=True)
47+
48+
if available_scanners == 0:
49+
raise ConfigEntryNotReady(
50+
translation_domain=DOMAIN,
51+
translation_key="no_bleak_scanner",
52+
)
53+
4254
self.device: ProbePlusDevice = ProbePlusDevice(
4355
address_or_ble_device=entry.data[CONF_ADDRESS],
56+
scanner=bluetooth.async_get_scanner(hass),
4457
name=entry.title,
4558
notify_callback=self.async_update_listeners,
4659
)

homeassistant/components/probe_plus/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
"integration_type": "device",
1616
"iot_class": "local_push",
1717
"quality_scale": "bronze",
18-
"requirements": ["pyprobeplus==1.1.1"]
18+
"requirements": ["pyprobeplus==1.1.2"]
1919
}

homeassistant/components/probe_plus/strings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,10 @@
4545
"name": "Relay voltage"
4646
}
4747
}
48+
},
49+
"exceptions": {
50+
"no_bleak_scanner": {
51+
"message": "No compatible Bluetooth scanner found."
52+
}
4853
}
4954
}

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)