Ignore ble name for gardena (#98126)

pull/98737/head
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 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.parse import ManufacturerData, ProductGroup
from gardena_bluetooth.parse import ManufacturerData, ProductType
import voluptuous as vol
from homeassistant import config_entries
@ -34,7 +34,13 @@ def _is_supported(discovery_info: BluetoothServiceInfo):
return False
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)
return False
@ -42,9 +48,11 @@ def _is_supported(discovery_info: BluetoothServiceInfo):
def _get_name(discovery_info: BluetoothServiceInfo):
if discovery_info.name and discovery_info.name != discovery_info.address:
return discovery_info.name
return "Gardena Device"
data = discovery_info.manufacturer_data[ManufacturerData.company]
manufacturer_data = ManufacturerData.decode(data)
product_type = ProductType.from_manufacturer_data(manufacturer_data)
return PRODUCT_NAMES.get(product_type, "Gardena Device")
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):

View File

@ -13,5 +13,5 @@
"dependencies": ["bluetooth_adapters"],
"documentation": "https://www.home-assistant.io/integrations/gardena_bluetooth",
"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
# homeassistant.components.gardena_bluetooth
gardena_bluetooth==1.0.2
gardena_bluetooth==1.2.0
# homeassistant.components.google_assistant_sdk
gassist-text==0.0.10

View File

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

View File

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