Ignore ble name for gardena (#98126)

This commit is contained in:
Joakim Plate 2023-08-21 08:43:52 +02:00 committed by GitHub
parent a29e4a5f02
commit 687bf5e808
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 21 deletions

View file

@ -5,9 +5,9 @@ import logging
from typing import Any from typing import Any
from gardena_bluetooth.client import Client from gardena_bluetooth.client import Client
from gardena_bluetooth.const import DeviceInformation, ScanService from gardena_bluetooth.const import PRODUCT_NAMES, DeviceInformation, ScanService
from gardena_bluetooth.exceptions import CharacteristicNotFound, CommunicationFailure from gardena_bluetooth.exceptions import CharacteristicNotFound, CommunicationFailure
from gardena_bluetooth.parse import ManufacturerData, ProductGroup from gardena_bluetooth.parse import ManufacturerData, ProductType
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
@ -34,7 +34,13 @@ def _is_supported(discovery_info: BluetoothServiceInfo):
return False return False
manufacturer_data = ManufacturerData.decode(data) manufacturer_data = ManufacturerData.decode(data)
if manufacturer_data.group != ProductGroup.WATER_CONTROL: product_type = ProductType.from_manufacturer_data(manufacturer_data)
if product_type not in (
ProductType.PUMP,
ProductType.VALVE,
ProductType.WATER_COMPUTER,
):
_LOGGER.debug("Unsupported device: %s", manufacturer_data) _LOGGER.debug("Unsupported device: %s", manufacturer_data)
return False return False
@ -42,9 +48,11 @@ def _is_supported(discovery_info: BluetoothServiceInfo):
def _get_name(discovery_info: BluetoothServiceInfo): def _get_name(discovery_info: BluetoothServiceInfo):
if discovery_info.name and discovery_info.name != discovery_info.address: data = discovery_info.manufacturer_data[ManufacturerData.company]
return discovery_info.name manufacturer_data = ManufacturerData.decode(data)
return "Gardena Device" product_type = ProductType.from_manufacturer_data(manufacturer_data)
return PRODUCT_NAMES.get(product_type, "Gardena Device")
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):

View file

@ -13,5 +13,5 @@
"dependencies": ["bluetooth_adapters"], "dependencies": ["bluetooth_adapters"],
"documentation": "https://www.home-assistant.io/integrations/gardena_bluetooth", "documentation": "https://www.home-assistant.io/integrations/gardena_bluetooth",
"iot_class": "local_polling", "iot_class": "local_polling",
"requirements": ["gardena_bluetooth==1.0.2"] "requirements": ["gardena_bluetooth==1.2.0"]
} }

View file

@ -829,7 +829,7 @@ fritzconnection[qr]==1.12.2
gTTS==2.2.4 gTTS==2.2.4
# homeassistant.components.gardena_bluetooth # homeassistant.components.gardena_bluetooth
gardena_bluetooth==1.0.2 gardena_bluetooth==1.2.0
# homeassistant.components.google_assistant_sdk # homeassistant.components.google_assistant_sdk
gassist-text==0.0.10 gassist-text==0.0.10

View file

@ -648,7 +648,7 @@ fritzconnection[qr]==1.12.2
gTTS==2.2.4 gTTS==2.2.4
# homeassistant.components.gardena_bluetooth # homeassistant.components.gardena_bluetooth
gardena_bluetooth==1.0.2 gardena_bluetooth==1.2.0
# homeassistant.components.google_assistant_sdk # homeassistant.components.google_assistant_sdk
gassist-text==0.0.10 gassist-text==0.0.10

View file

@ -3,7 +3,7 @@
FlowResultSnapshot({ FlowResultSnapshot({
'data_schema': None, 'data_schema': None,
'description_placeholders': dict({ 'description_placeholders': dict({
'name': 'Timer', 'name': 'Gardena Water Computer',
}), }),
'errors': None, 'errors': None,
'flow_id': <ANY>, 'flow_id': <ANY>,
@ -19,7 +19,7 @@
'confirm_only': True, 'confirm_only': True,
'source': 'bluetooth', 'source': 'bluetooth',
'title_placeholders': dict({ 'title_placeholders': dict({
'name': 'Timer', 'name': 'Gardena Water Computer',
}), }),
'unique_id': '00000000-0000-0000-0000-000000000001', 'unique_id': '00000000-0000-0000-0000-000000000001',
}), }),
@ -44,11 +44,11 @@
'pref_disable_new_entities': False, 'pref_disable_new_entities': False,
'pref_disable_polling': False, 'pref_disable_polling': False,
'source': 'bluetooth', 'source': 'bluetooth',
'title': 'Timer', 'title': 'Gardena Water Computer',
'unique_id': '00000000-0000-0000-0000-000000000001', 'unique_id': '00000000-0000-0000-0000-000000000001',
'version': 1, 'version': 1,
}), }),
'title': 'Timer', 'title': 'Gardena Water Computer',
'type': <FlowResultType.CREATE_ENTRY: 'create_entry'>, 'type': <FlowResultType.CREATE_ENTRY: 'create_entry'>,
'version': 1, 'version': 1,
}) })
@ -124,7 +124,7 @@
'options': list([ 'options': list([
tuple( tuple(
'00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000001',
'Timer', 'Gardena Water Computer',
), ),
]), ]),
'required': True, 'required': True,
@ -144,7 +144,7 @@
FlowResultSnapshot({ FlowResultSnapshot({
'data_schema': None, 'data_schema': None,
'description_placeholders': dict({ 'description_placeholders': dict({
'name': 'Timer', 'name': 'Gardena Water Computer',
}), }),
'errors': None, 'errors': None,
'flow_id': <ANY>, 'flow_id': <ANY>,
@ -182,11 +182,11 @@
'options': list([ 'options': list([
tuple( tuple(
'00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000001',
'Timer', 'Gardena Water Computer',
), ),
tuple( tuple(
'00000000-0000-0000-0000-000000000002', '00000000-0000-0000-0000-000000000002',
'Gardena Device', 'Gardena Water Computer',
), ),
]), ]),
'required': True, 'required': True,
@ -206,7 +206,7 @@
FlowResultSnapshot({ FlowResultSnapshot({
'data_schema': None, 'data_schema': None,
'description_placeholders': dict({ 'description_placeholders': dict({
'name': 'Timer', 'name': 'Gardena Water Computer',
}), }),
'errors': None, 'errors': None,
'flow_id': <ANY>, 'flow_id': <ANY>,
@ -222,7 +222,7 @@
'confirm_only': True, 'confirm_only': True,
'source': 'user', 'source': 'user',
'title_placeholders': dict({ 'title_placeholders': dict({
'name': 'Timer', 'name': 'Gardena Water Computer',
}), }),
'unique_id': '00000000-0000-0000-0000-000000000001', 'unique_id': '00000000-0000-0000-0000-000000000001',
}), }),
@ -247,11 +247,11 @@
'pref_disable_new_entities': False, 'pref_disable_new_entities': False,
'pref_disable_polling': False, 'pref_disable_polling': False,
'source': 'user', 'source': 'user',
'title': 'Timer', 'title': 'Gardena Water Computer',
'unique_id': '00000000-0000-0000-0000-000000000001', 'unique_id': '00000000-0000-0000-0000-000000000001',
'version': 1, 'version': 1,
}), }),
'title': 'Timer', 'title': 'Gardena Water Computer',
'type': <FlowResultType.CREATE_ENTRY: 'create_entry'>, 'type': <FlowResultType.CREATE_ENTRY: 'create_entry'>,
'version': 1, 'version': 1,
}) })