From 301b121df49c473cfb8411280fdd044049a56f76 Mon Sep 17 00:00:00 2001 From: patman15 <14628713+patman15@users.noreply.github.com> Date: Tue, 31 Dec 2024 16:53:57 +0100 Subject: [PATCH] adapted Ective identification --- custom_components/bms_ble/manifest.json | 8 +++----- custom_components/bms_ble/plugins/ective_bms.py | 1 - tests/advertisement_data.py | 17 +++++++++++++++++ tests/test_config_flow.py | 6 +++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/custom_components/bms_ble/manifest.json b/custom_components/bms_ble/manifest.json index ca00576..0903930 100644 --- a/custom_components/bms_ble/manifest.json +++ b/custom_components/bms_ble/manifest.json @@ -73,13 +73,11 @@ }, { "local_name": "$PFLAC*", - "service_uuid": "0000ffe0-0000-1000-8000-00805f9b34fb", - "manufacturer_id": 65535 + "service_uuid": "0000ffe0-0000-1000-8000-00805f9b34fb" }, { "local_name": "NWJ20*", - "service_uuid": "0000ffe0-0000-1000-8000-00805f9b34fb", - "manufacturer_id": 65535 + "service_uuid": "0000ffe0-0000-1000-8000-00805f9b34fb" }, { "manufacturer_id": 54976 @@ -98,5 +96,5 @@ "issue_tracker": "https://github.com/patman15/BMS_BLE-HA/issues", "loggers": ["bleak_retry_connector"], "requirements": [], - "version": "1.11.3" + "version": "1.11.4" } diff --git a/custom_components/bms_ble/plugins/ective_bms.py b/custom_components/bms_ble/plugins/ective_bms.py index 914de4f..8eedf09 100644 --- a/custom_components/bms_ble/plugins/ective_bms.py +++ b/custom_components/bms_ble/plugins/ective_bms.py @@ -55,7 +55,6 @@ def matcher_dict_list() -> list[dict[str, Any]]: { "local_name": pattern, "service_uuid": BMS.uuid_services()[0], - "manufacturer_id": 65535, "connectable": True, } for pattern in ["$PFLAC*", "NWJ20*"] ] diff --git a/tests/advertisement_data.py b/tests/advertisement_data.py index f688c29..ef53248 100644 --- a/tests/advertisement_data.py +++ b/tests/advertisement_data.py @@ -23,6 +23,23 @@ ), "ective_bms", ), + ( # nRF Connect (https://github.com/patman15/BMS_BLE-HA/issues/82#issuecomment-2498299433) + generate_advertisement_data( + local_name="$PFLAC,R,RADIOID\x0D\x0A", + manufacturer_data={65535: b"\x10\x55\x44\x33\xE8\xB4"}, + service_uuids=["0000ffe0-0000-1000-8000-00805f9b34fb"], + rssi=-47, + ), + "ective_bms", + ), + ( # bluetoothctl (https://github.com/patman15/BMS_BLE-HA/issues/137) + generate_advertisement_data( + local_name="NWJ20200720020539", + manufacturer_data={0: b"\x34\x14\xb5\x9d\x78\xE7\x4c"}, + service_uuids=["0000ffe0-0000-1000-8000-00805f9b34fb"], + ), + "ective_bms", + ), ( generate_advertisement_data( local_name="BatteryOben-00", diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 43708a7..2a53aa8 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -64,7 +64,11 @@ async def test_bluetooth_discovery( inject_bluetooth_service_info_bleak(hass, advertisement) await hass.async_block_till_done(wait_background_tasks=True) - result: ConfigFlowResult = hass.config_entries.flow.async_progress_by_handler(DOMAIN)[0] + flowresults: list[ConfigFlowResult] = ( + hass.config_entries.flow.async_progress_by_handler(DOMAIN) + ) + assert len(flowresults) == 1, f"Expected one flow result for {advertisement}" + result: ConfigFlowResult = flowresults[0] assert result.get("step_id") == "bluetooth_confirm" assert result.get("context", {}).get("unique_id") == advertisement.address