From bc5422d73707bca5cd88f5759ac92d52d7eecf13 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Mon, 18 Oct 2021 22:23:06 +0200 Subject: [PATCH] Bump fjaraskupan to 1.0.2 (#57992) --- .../components/fjaraskupan/__init__.py | 21 +++++++++++-------- .../components/fjaraskupan/config_flow.py | 6 ++++-- .../components/fjaraskupan/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/fjaraskupan/__init__.py b/homeassistant/components/fjaraskupan/__init__.py index 40113744977..b6eda82ea10 100644 --- a/homeassistant/components/fjaraskupan/__init__.py +++ b/homeassistant/components/fjaraskupan/__init__.py @@ -9,7 +9,7 @@ import logging from bleak import BleakScanner from bleak.backends.device import BLEDevice from bleak.backends.scanner import AdvertisementData -from fjaraskupan import Device, State, device_filter +from fjaraskupan import UUID_SERVICE, Device, State, device_filter from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback @@ -48,7 +48,7 @@ class EntryState: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Fjäråskupan from a config entry.""" - scanner = BleakScanner() + scanner = BleakScanner(filters={"UUIDs": [str(UUID_SERVICE)]}) state = EntryState(scanner, {}) hass.data.setdefault(DOMAIN, {}) @@ -57,17 +57,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def detection_callback( ble_device: BLEDevice, advertisement_data: AdvertisementData ) -> None: - if not device_filter(ble_device, advertisement_data): - return - - _LOGGER.debug( - "Detection: %s %s - %s", ble_device.name, ble_device, advertisement_data - ) - if data := state.devices.get(ble_device.address): + _LOGGER.debug( + "Update: %s %s - %s", ble_device.name, ble_device, advertisement_data + ) + data.device.detection_callback(ble_device, advertisement_data) data.coordinator.async_set_updated_data(data.device.state) else: + if not device_filter(ble_device, advertisement_data): + return + + _LOGGER.debug( + "Detected: %s %s - %s", ble_device.name, ble_device, advertisement_data + ) device = Device(ble_device) device.detection_callback(ble_device, advertisement_data) diff --git a/homeassistant/components/fjaraskupan/config_flow.py b/homeassistant/components/fjaraskupan/config_flow.py index 9b82ae1199b..4d4d1882dcd 100644 --- a/homeassistant/components/fjaraskupan/config_flow.py +++ b/homeassistant/components/fjaraskupan/config_flow.py @@ -7,7 +7,7 @@ import async_timeout from bleak import BleakScanner from bleak.backends.device import BLEDevice from bleak.backends.scanner import AdvertisementData -from fjaraskupan import device_filter +from fjaraskupan import UUID_SERVICE, device_filter from homeassistant.helpers.config_entry_flow import register_discovery_flow @@ -25,7 +25,9 @@ async def _async_has_devices(hass) -> bool: if device_filter(device, advertisement_data): event.set() - async with BleakScanner(detection_callback=detection): + async with BleakScanner( + detection_callback=detection, filters={"UUIDs": [str(UUID_SERVICE)]} + ): try: async with async_timeout.timeout(CONST_WAIT_TIME): await event.wait() diff --git a/homeassistant/components/fjaraskupan/manifest.json b/homeassistant/components/fjaraskupan/manifest.json index d9cd5640848..fb27d8b803f 100644 --- a/homeassistant/components/fjaraskupan/manifest.json +++ b/homeassistant/components/fjaraskupan/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/fjaraskupan", "requirements": [ - "fjaraskupan==1.0.1" + "fjaraskupan==1.0.2" ], "codeowners": [ "@elupus" diff --git a/requirements_all.txt b/requirements_all.txt index a480c3909bb..b7a2bd80a4a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -646,7 +646,7 @@ fitbit==0.3.1 fixerio==1.0.0a0 # homeassistant.components.fjaraskupan -fjaraskupan==1.0.1 +fjaraskupan==1.0.2 # homeassistant.components.flipr flipr-api==1.4.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 6e601c3fe3a..1780c0d54aa 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -378,7 +378,7 @@ faadelays==0.0.7 feedparser==6.0.2 # homeassistant.components.fjaraskupan -fjaraskupan==1.0.1 +fjaraskupan==1.0.2 # homeassistant.components.flipr flipr-api==1.4.1