1 """Integration to integrate Keymitt BLE devices with Home Assistant."""
3 from __future__
import annotations
6 from typing
import TYPE_CHECKING, Any
8 from microbot
import MicroBotApiClient, parse_advertisement_data
12 PassiveBluetoothDataUpdateCoordinator,
18 from bleak.backends.device
import BLEDevice
20 _LOGGER: logging.Logger = logging.getLogger(__package__)
21 PLATFORMS: list[str] = [Platform.SWITCH]
25 """Class to manage fetching data from the MicroBot."""
30 client: MicroBotApiClient,
31 ble_device: BLEDevice,
34 self.api: MicroBotApiClient = client
35 self.
datadata: dict[str, Any] = {}
41 bluetooth.BluetoothScanningMode.ACTIVE,
47 service_info: bluetooth.BluetoothServiceInfoBleak,
48 change: bluetooth.BluetoothChange,
50 """Handle a Bluetooth event."""
51 if adv := parse_advertisement_data(
52 service_info.device, service_info.advertisement
55 _LOGGER.debug(
"%s: MicroBot data: %s", self.
ble_deviceble_device.address, self.
datadata)
56 self.api.update_from_advertisement(adv)
None _async_handle_bluetooth_event(self, bluetooth.BluetoothServiceInfoBleak service_info, bluetooth.BluetoothChange change)
None __init__(self, HomeAssistant hass, MicroBotApiClient client, BLEDevice ble_device)